var contUnitedStatesExtent = new esri.geometry.Extent({"xmin":-14327455,"ymin":3000000,"xmax":-8199999,"ymax":6000000,"spatialReference":{"wkid":102100}}); map1 = new esri.Map("mapDiv", {extent:contUnitedStatesExtent, wrapAround180:true}); basemap1 = new esri.layers.ArcGISTiledMapServiceLayer ( "http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" ); map1.addLayer( basemap1 ); <!-- Change Extent --> function changeExtent () { alert("Inside changeExtent()"); map1.setExtent(contUnitedStatesExtent, true); //map1.setExtent(map1.extent.expand(0.5)); }
Solved! Go to Solution.
var map; var initExtent; function init() { initExtent = new esri.geometry.Extent({"xmin":-122.46,"ymin":37.73,"xmax":-122.36,"ymax":37.77,"spatialReference":{"wkid":4326}}); map = new esri.Map("map",{ extent:esri.geometry.geographicToWebMercator(initExtent) }); //Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); } function setExtent(){ map.setExtent(esri.geometry.geographicToWebMercator(initExtent)); } dojo.addOnLoad(init);
var map; var initExtent; function init() { initExtent = new esri.geometry.Extent({"xmin":-122.46,"ymin":37.73,"xmax":-122.36,"ymax":37.77,"spatialReference":{"wkid":4326}}); map = new esri.Map("map",{ extent:esri.geometry.geographicToWebMercator(initExtent) }); //Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"); map.addLayer(basemap); } function setExtent(){ map.setExtent(esri.geometry.geographicToWebMercator(initExtent)); } dojo.addOnLoad(init);