Skip to content

Instantly share code, notes, and snippets.

@chriswhong
Last active August 29, 2015 14:21
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save chriswhong/bb1e72b87bc640b8739c to your computer and use it in GitHub Desktop.
Leaflet initial view helper
//Logs current map center and zoom level for use in map init options
//Use it to find that perfect intial view without having to use trial and error
map.on('dragend',getInit).on('zoomend',getInit);
function getInit() {
var c = map.getCenter();
console.log('center: [' + c.lat + ',' + c.lng + '],\nzoom: ' + map.getZoom());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment