From 9266b7fdb26276c909d37eed11cdcff52cdbc1b0 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sat, 14 Jul 2012 17:47:18 +0200 Subject: [PATCH] Create new extent if no existing one --- src/ol/map.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index f060a2d8db..eda0d6fad6 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -216,11 +216,18 @@ ol.Map.prototype.handleCameraPropertyChanged = function() { return; } var size = this.size_; - var extent = this.extent_; - extent.left = position.x - resolution * size.width / 2; - extent.right = position.x + resolution * size.width / 2; - extent.bottom = position.y - resolution * size.height / 2; - extent.top = position.y + resolution * size.height / 2; + var left = position.x - resolution * size.width / 2; + var right = position.x + resolution * size.width / 2; + var bottom = position.y - resolution * size.height / 2; + var top = position.y + resolution * size.height / 2; + if (goog.isNull(this.extent_)) { + this.extent_ = new ol.Extent(top, right, bottom, left); + } else { + this.extent_.top = top; + this.extent_.right = right; + this.extent_.bottom = bottom; + this.extent_.left = left; + } };