Well to start with, if you want to return to your original default extent, create a global variable called spatialExtent and initialize it with the starting extent of your map. For instance, add the following statement in your init function. startExtent = new esri.geometry.Extent(-27471128,-11652400,4072293,15507815, new esri.SpatialReference({wkid:3857}));Now create a button called Reset which when you click on it, calls the function resetMap. All you have to have in the function resetMap is the following: map.setExtent(startExtent);That will reload your map to its original location. As far as getting back the original layers you had drawn on your map, as long as you declare them globally and define them in your init function, you can recall them in the resetMap function. For instance, if there is a particular basemap you originally had displayed, you would have to do the following statement in your init function: basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer");Then in the resetMap function you need to add the following: map.removeAllLayers(); map.addLayer(basemap); The map.removeAllLayers() clears the map of whatever you have displayed on it. The map.addLayer(basemap) adds the basemap back. You can do the same with any additional layers as long as you define them globally so they can be seen by the function. Hope this makes sense. I'm assuming you know a little bit of javascript.
Hi Bill , What are you trying to 'refresh,' the application..the map? You could add a refresh button that refreshes the map and sets it to its default extent and removes any additional operational layers that were added. Is this the kind of functionality you are referring to?
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.