From 16b817b830a441c8ed979c47c6fbcf24c3eb30d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 30 Oct 2013 09:49:38 +0100 Subject: [PATCH] Overlay stopEvent and insertFirst default to true --- examples/geolocation.js | 3 ++- examples/icon.js | 3 ++- examples/overlay.js | 11 ++++------- examples/popup.js | 4 +--- src/objectliterals.jsdoc | 13 +++++++------ src/ol/overlay.js | 4 ++-- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/examples/geolocation.js b/examples/geolocation.js index fce765f696..7fb3fe83f2 100644 --- a/examples/geolocation.js +++ b/examples/geolocation.js @@ -39,7 +39,8 @@ geolocation.on('change', function() { var marker = new ol.Overlay({ element: /** @type {Element} */ ($('').addClass('icon-flag').get(0)), - positioning: ol.OverlayPositioning.BOTTOM_LEFT + positioning: ol.OverlayPositioning.BOTTOM_LEFT, + stopEvent: false }); map.addOverlay(marker); // bind the marker position to the device location. diff --git a/examples/icon.js b/examples/icon.js index 582bf2cca0..af0e158b30 100644 --- a/examples/icon.js +++ b/examples/icon.js @@ -65,7 +65,8 @@ var element = document.getElementById('popup'); var popup = new ol.Overlay({ element: element, - positioning: ol.OverlayPositioning.BOTTOM_CENTER + positioning: ol.OverlayPositioning.BOTTOM_CENTER, + stopEvent: false }); map.addOverlay(popup); diff --git a/examples/overlay.js b/examples/overlay.js index 03479fff9a..bc5d12915c 100644 --- a/examples/overlay.js +++ b/examples/overlay.js @@ -29,24 +29,21 @@ var pos = ol.proj.transform([16.3725, 48.208889], 'EPSG:4326', 'EPSG:3857'); var marker = new ol.Overlay({ position: pos, positioning: ol.OverlayPositioning.CENTER_CENTER, - element: document.getElementById('marker') + element: document.getElementById('marker'), + stopEvent: false }); map.addOverlay(marker); // Vienna label var vienna = new ol.Overlay({ position: pos, - element: document.getElementById('vienna'), - stopEvent: true, - insertFirst: true + element: document.getElementById('vienna') }); map.addOverlay(vienna); // Popup showing the position the user clicked var popup = new ol.Overlay({ - element: document.getElementById('popup'), - stopEvent: true, - insertFirst: true + element: document.getElementById('popup') }); map.addOverlay(popup); diff --git a/examples/popup.js b/examples/popup.js index 58b9d72085..944b5b8b8b 100644 --- a/examples/popup.js +++ b/examples/popup.js @@ -31,9 +31,7 @@ closer.onclick = function() { * Create an overlay to anchor the popup to the map. */ var overlay = new ol.Overlay({ - element: container, - stopEvent: true, - insertFirst: true + element: container }); diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 3cb335e2b9..c54b6bd31c 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -79,13 +79,14 @@ * projection. * @property {ol.OverlayPositioning|undefined} positioning Positioning. * @property {boolean|undefined} stopEvent Whether event propagation to the map - * should be stopped. Default is `false`. - * If `stopEvent` is `true`, the overlay is placed in the same container as - * that of the controls (`ol-overlaycontainer-stopevent`). + * viewport should be stopped. Default is `true`. If `true` the overlay is + * placed in the same container as that of the controls + * (`ol-overlaycontainer-stopevent`). * @property {boolean|undefined} insertFirst Whether the overlay is inserted - * first in the container div, or appended. Default is `false`. - * This is usually used in conjunction with `stopEvent: true` so the - * overlay is below controls. + * first in the overlay container, or appended. Default is `true`. If the + * overlay is placed in the same container as that of the controls (see + * the `stopEvent` option) you will probably set `insertFirst` to `true` + * so the overlay is displayed below the controls. * @todo stability experimental */ diff --git a/src/ol/overlay.js b/src/ol/overlay.js index d053f769be..b8c843fcdc 100644 --- a/src/ol/overlay.js +++ b/src/ol/overlay.js @@ -67,13 +67,13 @@ ol.Overlay = function(options) { * @type {boolean} */ this.insertFirst_ = goog.isDef(options.insertFirst) ? - options.insertFirst : false; + options.insertFirst : true; /** * @private * @type {boolean} */ - this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : false; + this.stopEvent_ = goog.isDef(options.stopEvent) ? options.stopEvent : true; /** * @private