6

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.

Humayun Shabbir
  • 2,961
  • 4
  • 20
  • 33
combatdave
  • 765
  • 7
  • 17

3 Answers3

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

Maertz
  • 4,952
  • 2
  • 18
  • 27
  • the zoomLevel method doesn't seem to be working, I get a "Cannot read property 'scale' of undefined" error. Any ideas? – j_d Oct 01 '15 at 14:23
1

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.

Community
  • 1
  • 1
Hans Gansowen
  • 21
  • 1
  • 4
0

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