Created
July 5, 2016 15:40
-
-
Save jeffreymorganio/359591dee3b08323d7f5609206ea4fcc to your computer and use it in GitHub Desktop.
Zoom and center a Leaflet map on a single marker.
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
function centerLeafletMapOnMarker(map, marker) { | |
var latLngs = [ marker.getLatLng() ]; | |
var markerBounds = L.latLngBounds(latLngs); | |
map.fitBounds(markerBounds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment