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.
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.