From 7659cf4b840ef04f1fef3518e7e60f9b8cf53212 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Thu, 5 Sep 2013 23:12:18 +0100 Subject: [PATCH] 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 --- code/boot.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/boot.js b/code/boot.js index 1553b303..9dad98cb 100644 --- a/code/boot.js +++ b/code/boot.js @@ -181,8 +181,16 @@ window.setupMap = function() { map.attributionControl.setPrefix(''); // listen for changes and store them in cookies 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 // ensures order of calls