slight improvement around the antimeridian - wrap the map centre so it's always between +-180 degrees

also limit north/south to 85 degrees, to avoid leaving the active map area
This commit is contained in:
Jon Atkins 2013-09-05 23:12:18 +01:00
parent 2f96b9d07c
commit 7659cf4b84

View File

@ -181,8 +181,16 @@ window.setupMap = function() {
map.attributionControl.setPrefix(''); map.attributionControl.setPrefix('');
// listen for changes and store them in cookies // listen for changes and store them in cookies
map.on('moveend', window.storeMapPosition); map.on('moveend', window.storeMapPosition);
map.on('zoomend', window.storeMapPosition);
map.on('moveend', function(e) {
// two limits on map position
// we wrap longitude (the L.LatLng 'wrap' method) - so we don't find outselves looking beyond +-180 degrees
// then latitude is clamped with the clampLatLng function (to the 85 deg north/south limits)
var newPos = clampLatLng(map.getCenter().wrap());
if (!map.getCenter().equals(newPos)) {
map.panTo(newPos,{animate:false})
}
});
// map update status handling & update map hooks // map update status handling & update map hooks
// ensures order of calls // ensures order of calls