Created
April 25, 2017 05:31
-
-
Save geog4046instructor/43e898a56e4a26da2a6d6c001c1859da to your computer and use it in GitHub Desktop.
Leaflet and ArcGIS - Change the view by flying to a location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Change the map or scene view by making the camera "fly" to a new latitude and longitude. Note the lat/lng are reversed. | |
* | |
*/ | |
map.flyTo( [34.69, -117.76], 8, { animate:true, duration:1 } ) // for Leaflet maps | |
scene.goTo({ center: [-117.76, 34.69], zoom: 8 }) // for ArcGIS web scenes | |
/* To change the camera location but keep the current zoom level, you could provide flyTo and goTo with a zoom value equal | |
* to the map or scene's current zoom obtained with the map.getZoom() method in Leaflet and the scene.zoom property in ArcGIS. | |
*/ | |
map.flyTo( [lat, lng], map.getZoom(), { animate:true, duration:1 } ) // for leaflet | |
scene.goTo({ center: [lng, lat], zoom: scene.zoom }) // for ArcGIS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment