• Hello guys , recently I’ve been struggling with optimizing a js script of this plugin. I’m working on a project which is build across this plugin.

    The question: I got a few maps where they have 3-5 areas which are loaded pretty fast but there is one pretty large one where 60 or even 70 areas are loaded. They are loading with lag. I mean on the first page load, the page is more likely to freeze on loading all maps.

    I’ve tried to load areas which are placed in array ( as i understood ) dividing them to chunks but i failed , maybe someone already accomplished this ?

    The code that I tried to implemente:

    function chunk(arr, chunkSize) {
    var areas = [];
    for (var i=0,len=arr.length; i<len; i+=chunkSize)
    areas.push(arr.slice(i,i+chunkSize));
    return areas.mapster('highlight', render_highlight.key); 
    }

    Edit: Im trying to load chunks onMouseOut function.

    onMouseout: function(){
    $.each(areas, function(key, render_highlight){
    $(map).mapster('highlight', render_highlight.key);
    }
    }
    • This topic was modified 6 years, 2 months ago by andza1.
    • This topic was modified 6 years, 2 months ago by andza1.
    • This topic was modified 6 years, 2 months ago by andza1.
Viewing 1 replies (of 1 total)
  • Thread Starter andza1

    (@andza1)

    I found a easy solution

    Just add a setTimeout.

    onMouseout: function(){
    $.each(areas, function(key, render_highlight){
    setTimeout(function() {
    $(map).mapster('highlight', render_highlight.key);
    }, 5 * key)
    });
    }
Viewing 1 replies (of 1 total)
  • The topic ‘Load areas(array) in chunks’ is closed to new replies.