Select to view content in your preferred language

Map will not automatically pan and zoom to location when using dynamic map services.

637
1
08-10-2012 08:16 AM
SteveClarke
Emerging Contributor
I have a mobile app that only displays simple features from a dynamic map service.  I have a button on the map that calls the geolocation functionality that will place a marker on the map of the users current location and then automatically pan to that location by using map.centerAndZoom(pt, 4).  But I discovered that if the dynamic service is the only service in the app, the map will not pan to the location (the marker is placed in the right location though, so geolocation is working).  But if I place a tiled map service before the dynamic service in my code, then the geolocation works properly and will pan to the location.  As a workaround, I have set a tiled service in my code first and just set the opacity of it to 0 so that it doesn't display.  This same behavior occurs with geocoding an address on the map.  For this my code also uses centerAndZoom to go to the address location on the map.  Again, if the dynamic service is first in the code then centerAndZoom doesn't work.  Is this expected behavior for centerAndZoom against dynamic map services?
0 Kudos
1 Reply
SteveClarke
Emerging Contributor
The documentation for centerAndZoom states the following:

When using an ArcGISTiledMapServiceLayer, the map is zoomed to the level specified. When using a DynamicMapServiceLayer, the map is zoomed in or out by the specified factor. For example, use 0.5 to zoom in twice as far and 2.0 to zoom out twice as far.

I'm assuming this means that the map is still supposed to center on the x,y location when using a dynamic service.  My map will zoom out but will not center on the location.
0 Kudos