Skip to content

Instantly share code, notes, and snippets.

@mlevans
Created January 8, 2013 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlevans/4487402 to your computer and use it in GitHub Desktop.
Save mlevans/4487402 to your computer and use it in GitHub Desktop.
Leaflet zoom-by-about function
// 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