Created
January 8, 2013 20:02
-
-
Save mlevans/4487402 to your computer and use it in GitHub Desktop.
Leaflet zoom-by-about function
This file contains 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
// Stubbed out for now; this assumes that map is global and initialized. | |
// It also assumes that you're using jQuery or Zepto. | |
function zoomByAbout(e) { | |
var x = .5*$('#map').width(), | |
y = .5*$('#map').height(), | |
mouse_point = e.containerPoint, | |
new_center_point = new L.Point((x + mouse_point.x) / 2, (y + mouse_point.y) / 2), | |
new_center_location = map.containerPointToLatLng(new_center_point); | |
map.setView(new_center_location, map.getZoom() + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment