Insert or append overlay based on insertFirst option

This is to fix z-index issues with overlays that pass above ol3 default
controls.
This commit is contained in:
Bruno Binet
2013-10-11 11:36:37 +02:00
committed by Éric Lemoine
parent 69cee6a410
commit 71097d9cfc

View File

@@ -62,6 +62,13 @@ ol.Overlay = function(options) {
goog.base(this);
/**
* @private
* @type {boolean}
*/
this.insertFirst_ = goog.isDef(options.insertFirst) ?
options.insertFirst : false;
/**
* @private
* @type {boolean}
@@ -214,10 +221,14 @@ ol.Overlay.prototype.handleMapChanged = function() {
this.mapPostrenderListenerKey_ = goog.events.listen(map,
ol.MapEventType.POSTRENDER, this.handleMapPostrender, false, this);
this.updatePixelPosition_();
goog.dom.append(/** @type {!Node} */ (
this.stopEvent_ ? map.getOverlayContainerStopEvent() :
map.getOverlayContainer()),
this.element_);
var container = this.stopEvent_ ?
map.getOverlayContainerStopEvent() : map.getOverlayContainer();
if (this.insertFirst_) {
goog.dom.insertChildAt(/** @type {!Element} */ (
container), this.element_, 0);
} else {
goog.dom.append(/** @type {!Node} */ (container), this.element_);
}
}
};