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

admin2025-04-20  0

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.

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.

Share Improve this question edited Aug 7, 2014 at 18:34 Humayun Shabbir 3,2694 gold badges22 silver badges33 bronze badges asked Aug 7, 2014 at 15:45 batdavebatdave 7657 silver badges17 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 4

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./tips/retaining-map-zoom-level-position-data-update/

In addition to Maertz answer, remember to set zoomLatitude and zoomLongitude to zero so you won't get the "Cannot read property 'scale' of undefined" error.

Try to add var map = event.chart; at the method start.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745114462a285780.html

最新回复(0)