Don't use clientWidth and clientHeight.

Instead, use map.getSize to make sure this works the same way in all browsers.
This commit is contained in:
ahocevar
2011-12-28 20:10:56 +01:00
parent 0b3f9c0ae9
commit 1ce59a207d

View File

@@ -479,12 +479,13 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
if (!dragging) {
this.renderer.root.style.visibility = 'hidden';
var viewPortWidth = this.map.viewPortDiv.clientWidth;
var viewPortHeight = this.map.viewPortDiv.clientHeight;
var offsetLeft = (viewPortWidth / 2 * this.ratio) - viewPortWidth / 2;
var viewSize = this.map.getSize(),
viewWidth = viewSize.w,
viewHeight = viewSize.h,
offsetLeft = (viewWidth / 2 * this.ratio) - viewWidth / 2,
offsetTop = (viewHeight / 2 * this.ratio) - viewHeight / 2;
offsetLeft += parseInt(this.map.layerContainerDiv.style.left, 10);
offsetLeft = -Math.round(offsetLeft);
var offsetTop = (viewPortHeight / 2 * this.ratio) - viewPortHeight / 2;
offsetTop += parseInt(this.map.layerContainerDiv.style.top, 10);
offsetTop = -Math.round(offsetTop);