From 957f6a8dcebd2e2f88dfb6a2ba509353f405e8d7 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 6 Nov 2011 11:03:45 +0800 Subject: [PATCH] Preserve map center when changing between worlds --- web/js/map.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/web/js/map.js b/web/js/map.js index 8d24028e..c74d7f1a 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -396,6 +396,12 @@ DynMap.prototype = { var prevzoom = me.map.getZoom(); + var prevworld = me.world; + + if(worldChanged && me.world) { + me.world.lastcenter = me.maptype.getProjection().fromLatLngToLocation(me.map.getCenter(), 64); + } + if (me.maptype) { me.map.removeLayer(me.maptype); } @@ -416,7 +422,11 @@ DynMap.prototype = { centerPoint = me.getProjection().fromLocationToLatLng(location); } else if(worldChanged) { - var centerLocation = $.extend({ x: 0, y: 64, z: 0 }, mapWorld.center); + var centerLocation; + if(mapWorld.lastcenter) + centerLocation = mapWorld.lastcenter; + else + centerLocation = $.extend({ x: 0, y: 64, z: 0 }, mapWorld.center); centerPoint = me.getProjection().fromLocationToLatLng(centerLocation); } else {