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

I update the map areas on the AmMap map, but the zoom level and position reset when I do this.

My map updating function:

function setData(data) { var parsedData = JSON.parse(data); map.dataProvider.areas = parsedData.areas; map.validateData(); } 

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

Cheers for any help.

+6
source share
3 answers

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

+3
source

Try adding var map = event.chart; when the method starts.

0
source

In addition to Maertz's answer, don't forget to set zoomLatitude and zoomLongitude to zero so you don't get the “Unable to read” error bar “undefined” property bar.

0
source

Source: https://habr.com/ru/post/973506/


All Articles