Created
February 20, 2018 20:28
-
-
Save dirceu-jr/b63f25749958fa2f253e08b7955670f5 to your computer and use it in GitHub Desktop.
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
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