Imagemapster Map的极慢初始化

时间:2016-05-09 15:41:16

标签: javascript json imagemapster

我正在尝试基于引用ibeam位置的方块初始化地图布局。在某些情况下,有超过500个json对象,它导致地图的初始化永远需要,有时在30到60秒之间。这是我用来初始化它的javascript代码,有没有办法加快这个初始化是否可用?它是一个asp.net网站,如果这有助于任何。提前谢谢。

$(document).ready(function () {
$('img').mapster('resize', screen.width, screen.height, 0);
initialize();
});



function initialize() {
var ibeamid = '';
var status = '';
var redIbeams = [];
var yellowIbeams = [];
var greenIbeams = [];

$.each(json, function () {
    status = this['status'];
    ibeamid = this['ibeamName'];

    if (status.toUpperCase() == 'G') {
        greenIbeams.push(ibeamid);
    }
    else if (status.toUpperCase() == 'Y') {
        yellowIbeams.push(ibeamid);
    }
    else if (status.toUpperCase() == 'R') {
        redIbeams.push(ibeamid);
    }
});

var basic_opts = {
    mapKey: 'name'
};

var initial_opts = $.extend({}, basic_opts, {
    fill: false,
    stroke: true,
    strokeWidth: 2,
    strokeColor: '000000',
    configTimeout: 30000,
    render_select: {
        fade: false,
        //fill: true,
        fillOpacity: 0.5
    }
});


$('img').mapster(initial_opts)
    .mapster('set', true, redIbeams, {
        fill: true,
        fillColor: 'ff0000',
        staticState: true
        //fillOpacity: 0.5
    })
    .mapster('set', true, yellowIbeams, {
        fill: true,
        fillColor: 'ffff00',
        staticState: true
        //fillOpacity: 0.5
    })
    .mapster('set', true, greenIbeams, {
        fill: true,
        fillColor: '00ff00',
        staticState: true
        //fillOpacity: 0.5
    })
    .mapster('snapshot').mapster('rebind', basic_opts);

0 个答案:

没有答案