From d80bb6bd74e6e335e5923b4b5c45a440e2bf2e1b Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 2 Jan 2008 19:36:12 +0000 Subject: [PATCH] Oh please Google, give us some well named methods that solve this issue. We muddle around with obfuscated code trying in vein to solve your pesky setCenter flicker. This brings us a bit closer with even sized viewports but is still embarassingly wrong for users panning across the dateline with odd sized viewport. r=crschmidt (closes #1174) git-svn-id: http://svn.openlayers.org/trunk/openlayers@5627 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/EventPane.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Layer/EventPane.js b/lib/OpenLayers/Layer/EventPane.js index c461ee33ba..382c4f06f9 100644 --- a/lib/OpenLayers/Layer/EventPane.js +++ b/lib/OpenLayers/Layer/EventPane.js @@ -239,8 +239,6 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, { if ( !(newCenter.equals(oldCenter)) || !(newZoom == oldZoom) ) { - var center = this.getMapObjectLonLatFromOLLonLat(newCenter); - if (dragging && this.dragPanMapObject && this.smoothDragPan) { var resolution = this.map.getResolution(); @@ -248,6 +246,7 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, { var dY = (newCenter.lat - oldCenter.lat) / resolution; this.dragPanMapObject(dX, dY); } else { + var center = this.getMapObjectLonLatFromOLLonLat(newCenter); var zoom = this.getMapObjectZoomFromOLZoom(newZoom); this.setMapObjectCenter(center, zoom, dragging); } @@ -282,6 +281,18 @@ OpenLayers.Layer.EventPane = OpenLayers.Class(OpenLayers.Layer, { var moPixel = this.getMapObjectPixelFromOLPixel(viewPortPx); var moLonLat = this.getMapObjectLonLatFromMapObjectPixel(moPixel); lonlat = this.getOLLonLatFromMapObjectLonLat(moLonLat); + var xrem = this.map.size.w % 2; + var yrem = this.map.size.h % 2; + if(xrem != 0 || yrem != 0) { + // odd sized viewport + var olPx = viewPortPx.add(xrem, yrem); + var moPx = this.getMapObjectPixelFromOLPixel(olPx); + var moLoc = this.getMapObjectLonLatFromMapObjectPixel(moPx); + var olLoc = this.getOLLonLatFromMapObjectLonLat(moLoc); + // adjust by half a pixel in odd dimension(s) + lonlat.lon += (olLoc.lon - lonlat.lon) / 2; + lonlat.lat += (olLoc.lat - lonlat.lat) / 2; + } } return lonlat; },