How to keep the map in the map extent?

482
1
11-15-2012 04:09 AM
JoseSanchez
Occasional Contributor III
Hi all

How can I show the map in the map extent of the map service, assigned in the reference layer - in my case it shwos only the County limits- and ignore the map extent from the base map that covers the whole world.

Thanks
0 Kudos
1 Reply
ShreyasVakil
Occasional Contributor II
I don't know if I completely understand your questions, but let me try to help 🙂

You can set the map extent in reference to the basemap added to your application. The map takes the spatial reference of the first layer added to the map.

So make sure the extent you are passing is in the spatial reference of the first layer added.

Even if you have added your county limits as the dynamic map or feature layer, you need to specify the map extent in reference to the basemap.

This is how you should specify the map extent:

var initExtent = new esri.geometry.Extent({"xmin":-13814922,"ymin":332653,"xmax":6222585,"ymax":10351408,"spatialReference":{"wkid":102100}});
        var map = new esri.Map("map",{extent:initExtent});   
0 Kudos