Overlay stopEvent and insertFirst default to true

This commit is contained in:
Éric Lemoine
2013-10-30 09:49:38 +01:00
parent d7c696fc76
commit 16b817b830
6 changed files with 18 additions and 20 deletions

View File

@@ -39,7 +39,8 @@ geolocation.on('change', function() {
var marker = new ol.Overlay({ var marker = new ol.Overlay({
element: /** @type {Element} */ ($('<i/>').addClass('icon-flag').get(0)), element: /** @type {Element} */ ($('<i/>').addClass('icon-flag').get(0)),
positioning: ol.OverlayPositioning.BOTTOM_LEFT positioning: ol.OverlayPositioning.BOTTOM_LEFT,
stopEvent: false
}); });
map.addOverlay(marker); map.addOverlay(marker);
// bind the marker position to the device location. // bind the marker position to the device location.

View File

@@ -65,7 +65,8 @@ var element = document.getElementById('popup');
var popup = new ol.Overlay({ var popup = new ol.Overlay({
element: element, element: element,
positioning: ol.OverlayPositioning.BOTTOM_CENTER positioning: ol.OverlayPositioning.BOTTOM_CENTER,
stopEvent: false
}); });
map.addOverlay(popup); map.addOverlay(popup);

View File

@@ -29,24 +29,21 @@ var pos = ol.proj.transform([16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857');
var marker = new ol.Overlay({ var marker = new ol.Overlay({
position: pos, position: pos,
positioning: ol.OverlayPositioning.CENTER_CENTER, positioning: ol.OverlayPositioning.CENTER_CENTER,
element: document.getElementById('marker') element: document.getElementById('marker'),
stopEvent: false
}); });
map.addOverlay(marker); map.addOverlay(marker);
// Vienna label // Vienna label
var vienna = new ol.Overlay({ var vienna = new ol.Overlay({
position: pos, position: pos,
element: document.getElementById('vienna'), element: document.getElementById('vienna')
stopEvent: true,
insertFirst: true
}); });
map.addOverlay(vienna); map.addOverlay(vienna);
// Popup showing the position the user clicked // Popup showing the position the user clicked
var popup = new ol.Overlay({ var popup = new ol.Overlay({
element: document.getElementById('popup'), element: document.getElementById('popup')
stopEvent: true,
insertFirst: true
}); });
map.addOverlay(popup); map.addOverlay(popup);

View File

@@ -31,9 +31,7 @@ closer.onclick = function() {
* Create an overlay to anchor the popup to the map. * Create an overlay to anchor the popup to the map.
*/ */
var overlay = new ol.Overlay({ var overlay = new ol.Overlay({
element: container, element: container
stopEvent: true,
insertFirst: true
}); });

View File

@@ -79,13 +79,14 @@
* projection. * projection.
* @property {ol.OverlayPositioning|undefined} positioning Positioning. * @property {ol.OverlayPositioning|undefined} positioning Positioning.
* @property {boolean|undefined} stopEvent Whether event propagation to the map * @property {boolean|undefined} stopEvent Whether event propagation to the map
* should be stopped. Default is `false`. * viewport should be stopped. Default is `true`. If `true` the overlay is
* If `stopEvent` is `true`, the overlay is placed in the same container as * placed in the same container as that of the controls
* that of the controls (`ol-overlaycontainer-stopevent`). * (`ol-overlaycontainer-stopevent`).
* @property {boolean|undefined} insertFirst Whether the overlay is inserted * @property {boolean|undefined} insertFirst Whether the overlay is inserted
* first in the container div, or appended. Default is `false`. * first in the overlay container, or appended. Default is `true`. If the
* This is usually used in conjunction with `stopEvent: true` so the * overlay is placed in the same container as that of the controls (see
* overlay is below controls. * the `stopEvent` option) you will probably set `insertFirst` to `true`
* so the overlay is displayed below the controls.
* @todo stability experimental * @todo stability experimental
*/ */

View File

@@ -67,13 +67,13 @@ ol.Overlay = function(options) {
* @type {boolean} * @type {boolean}
*/ */
this.insertFirst_ = goog.isDef(options.insertFirst) ? this.insertFirst_ = goog.isDef(options.insertFirst) ?
options.insertFirst : false; options.insertFirst : true;
/** /**
* @private * @private
* @type {boolean} * @type {boolean}
*/ */
this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : false; this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : true;
/** /**
* @private * @private