diff --git a/lib/OpenLayers/Control/PinchZoom.js b/lib/OpenLayers/Control/PinchZoom.js index 0a57d89726..9985bd42cd 100644 --- a/lib/OpenLayers/Control/PinchZoom.js +++ b/lib/OpenLayers/Control/PinchZoom.js @@ -184,6 +184,20 @@ OpenLayers.Control.PinchZoom = OpenLayers.Class(OpenLayers.Control, { location.lon += resolution * ((size.w / 2) - zoomPixel.x); location.lat -= resolution * ((size.h / 2) - zoomPixel.y); + // Force a reflow before calling setCenter. This is to work + // around an issue occuring in iOS. + // + // See https://github.com/openlayers/openlayers/pull/351. + // + // Without a reflow setting the layer container div's top left + // style properties to "0px" - as done in Map.moveTo when zoom + // is changed - won't actually correctly reposition the layer + // container div. + // + // Also, we need to use a statement that the Google Closure + // compiler won't optimize away. + this.map.div.clientWidth = this.map.div.clientWidth; + this.map.setCenter(location, zoom); } },