Cope with map being null

This commit is contained in:
Tom Payne
2012-09-28 12:51:10 +02:00
parent 74f87995c8
commit e7eccb302d

View File

@@ -85,14 +85,18 @@ goog.inherits(ol.control.MousePosition, ol.control.Control);
*/ */
ol.control.MousePosition.prototype.handleMapProjectionChanged = function() { ol.control.MousePosition.prototype.handleMapProjectionChanged = function() {
var map = this.getMap(); var map = this.getMap();
var mapProjection = map.getProjection(); if (goog.isNull(map)) {
if (!goog.isDef(mapProjection) || !goog.isDef(this.projection_)) {
this.transform_ = ol.Projection.identityTransform; this.transform_ = ol.Projection.identityTransform;
} else { } else {
this.transform_ = var mapProjection = map.getProjection();
ol.Projection.getTransform(mapProjection, this.projection_); 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_; this.element.innerHTML = this.undefinedHtml_;
}; };