Merge pull request #1609 from twpayne/stricter-map-defined

Stricter map defined
This commit is contained in:
Tom Payne
2014-02-04 02:56:56 -08:00
2 changed files with 18 additions and 2 deletions

View File

@@ -969,12 +969,27 @@ ol.Map.prototype.handleLayerGroupChanged_ = function() {
/**
* Returns `true` if the map is defined, `false` otherwise. The map is defined
* if it is contained in `document`, visible, has non-zero height and width, and
* has a defined view.
* @return {boolean} Is defined.
*/
ol.Map.prototype.isDef = function() {
if (!goog.dom.contains(document, this.viewport_)) {
return false;
}
if (!goog.style.isElementShown(this.viewport_)) {
return false;
}
var size = this.getSize();
if (!goog.isDefAndNotNull(size) || size[0] <= 0 || size[1] <= 0) {
return false;
}
var view = this.getView();
return goog.isDef(view) && view.isDef() &&
goog.isDefAndNotNull(this.getSize());
if (!goog.isDef(view) || !view.isDef()) {
return false;
}
return true;
};

View File

@@ -335,6 +335,7 @@ ol.Overlay.prototype.updatePixelPosition_ = function() {
}
var pixel = map.getPixelFromCoordinate(position);
goog.asserts.assert(!goog.isNull(pixel));
var mapSize = map.getSize();
goog.asserts.assert(goog.isDef(mapSize));
var style = this.element_.style;