Skip to content

Instantly share code, notes, and snippets.

@dirceu-jr
Created February 20, 2018 20:28
Show Gist options
  • Save dirceu-jr/b63f25749958fa2f253e08b7955670f5 to your computer and use it in GitHub Desktop.
Save dirceu-jr/b63f25749958fa2f253e08b7955670f5 to your computer and use it in GitHub Desktop.
var m2px = 1;
function newM2px() {
var centerLatLng = map.getCenter();
var pointC = map.latLngToContainerPoint(centerLatLng);
var pointX = [pointC.x + 100, pointC.y];
var latLngC = map.containerPointToLatLng(pointC);
var latLngX = map.containerPointToLatLng(pointX);
var distanceX = latLngC.distanceTo(latLngX)/100;
reciprocal = 1 / distanceX;
m2px = reciprocal;
}
function geoStyle(m) {
return Math.ceil(m * m2px);
}
map.on("zoomend", function(){
newM2px();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment