From e7eccb302d1ead727344e0c5cff92e6d5f2e79c4 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 28 Sep 2012 12:51:10 +0200 Subject: [PATCH] Cope with map being null --- src/ol/control/mouseposition.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ol/control/mouseposition.js b/src/ol/control/mouseposition.js index 31dc2492d0..7da2f4bf5d 100644 --- a/src/ol/control/mouseposition.js +++ b/src/ol/control/mouseposition.js @@ -85,14 +85,18 @@ goog.inherits(ol.control.MousePosition, ol.control.Control); */ ol.control.MousePosition.prototype.handleMapProjectionChanged = function() { var map = this.getMap(); - var mapProjection = map.getProjection(); - if (!goog.isDef(mapProjection) || !goog.isDef(this.projection_)) { + if (goog.isNull(map)) { this.transform_ = ol.Projection.identityTransform; } else { - this.transform_ = - ol.Projection.getTransform(mapProjection, this.projection_); + var mapProjection = map.getProjection(); + if (!goog.isDef(mapProjection) || !goog.isDef(this.projection_)) { + this.transform_ = ol.Projection.identityTransform; + } else { + this.transform_ = + ol.Projection.getTransform(mapProjection, this.projection_); + } + // FIXME should we instead re-calculate using the last known mouse position? } - // FIXME should we instead re-calculate using the last known mouse position? this.element.innerHTML = this.undefinedHtml_; };