marvalo

Zooming to an area on a map

Discussion created by marvalo on Mar 23, 2012
Hi

I'm a completely new to this mapping API and I'm hoping that someone can point me in the right direction.

Basically I'm using OneMap and it's basemap which is Singapore. OneMap can be extended via ArcGis. I would like to be able to programmatically move to an area in the map and zoom
in so that the area fully fits the view.

So far I have tried to do it via Extents. To get the desired Extent I manually zoomed in and panned to the area and noted the Extent xmin, xmax etc from the innerHtml of a div where I was setting them to from the onExtentChange event handler. However when I call map.setExtent() no map is shown and the level is wrong.

This was just an experiment and it looked like this isn't a reliable way to do this as it seemed to depend on what width and height I set the map div to. Although it would be good to know why setting the Extent didn't work. I did ensure the wkid was the same.

The Set Map Extent example shows how you can set the extent of the map to the extent of one of its layers. Would this approach work for me? Presumably having a layer for each area on the map. I don't think these layers
exist on the OneMap server perhaps there is another source to get them from or I would have to create them myself.

Perhaps there are a number of ways to do this any help would be appreciated.

thanks

Outcomes