From 71097d9cfce1e81104911ff50c404fec1e5bd7be Mon Sep 17 00:00:00 2001 From: Bruno Binet Date: Fri, 11 Oct 2013 11:36:37 +0200 Subject: [PATCH] Insert or append overlay based on insertFirst option This is to fix z-index issues with overlays that pass above ol3 default controls. --- src/ol/overlay.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ol/overlay.js b/src/ol/overlay.js index 00156e5079..d053f769be 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -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_); + } } };