add utility functions to clamp latitude to +-90.0, and longitude to +-180.0
This commit is contained in:
parent
a3b957c967
commit
339c7ec21e
@ -407,3 +407,30 @@ window.addLayerGroup = function(name, layerGroup, defaultDisplay) {
|
||||
if(isLayerGroupDisplayed(name, defaultDisplay)) map.addLayer(layerGroup);
|
||||
layerChooser.addOverlay(layerGroup, name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
window.clampLat = function(lat) {
|
||||
if (lat > 90.0)
|
||||
lat = 90.0;
|
||||
else if (lat < -90.0)
|
||||
lat = -90.0;
|
||||
return lat;
|
||||
}
|
||||
|
||||
window.clampLng = function(lng) {
|
||||
if (lng > 180.0)
|
||||
lng = 180.0
|
||||
else if (lng < -180.0)
|
||||
lng = -180.0;
|
||||
return lng;
|
||||
}
|
||||
|
||||
|
||||
window.clampLatLng = function(latlng) {
|
||||
return new L.LatLng ( clampLat(latlng.lat), clampLng(latlng.lng) );
|
||||
}
|
||||
|
||||
window.clampLatLngBounds = function(bounds) {
|
||||
return new L.LatLngBounds ( clampLatLng(bounds.getSouthWest()), clampLatLng(bounds.getNorthEast()) );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user