Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AmMap - keeping the same zoom level and position after updating map data

I am updating the map areas of an AmMap map, but the zoom level and position is reset whenever I do.

My function which is updating the map is:

function setData(data) {
    var parsedData = JSON.parse(data);

    map.dataProvider.areas = parsedData.areas;
    map.validateData();
}

I have tried a bunch of things, but I can't get this to work.

Cheers for any help.

like image 844
combatdave Avatar asked Aug 07 '14 15:08

combatdave


1 Answers

before you update your data, get the current zoom values and pass them into the dataprovider. Take a look to following sample http://www.amcharts.com/tips/retaining-map-zoom-level-position-data-update/

like image 54
Maertz Avatar answered Nov 05 '22 16:11

Maertz