Skip to content

Instantly share code, notes, and snippets.

@geog4046instructor
Created April 25, 2017 05:31
Show Gist options
  • Select an option

  • Save geog4046instructor/43e898a56e4a26da2a6d6c001c1859da to your computer and use it in GitHub Desktop.

Select an option

Save geog4046instructor/43e898a56e4a26da2a6d6c001c1859da to your computer and use it in GitHub Desktop.

Revisions

  1. geog4046instructor created this gist Apr 25, 2017.
    12 changes: 12 additions & 0 deletions leaflet-arcgis-fly.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    /* 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