Introducing ol.overlay.Overlay and an overlayContainer
ol.overlay.Overlay can be used to bind DOM elements to a coordinate on the map. It has positioning options to support e.g. popups or image markers that have an anchor at the bottom and an unknown size. The overlayContainer stops propagation on mousedown and touchstart events, so clicks and gestures on overlays don't trigger any MapBrowserEvent. To make this work reliably, we now only fire dblclick in mapbrowserevent.js when there was a previous mousedown or touchstart. The default container for controls is now the overlayContainer.
This commit is contained in:
@@ -24,6 +24,7 @@ goog.require('goog.functions');
|
||||
goog.require('goog.fx.anim');
|
||||
goog.require('goog.fx.anim.Animated');
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.BrowserFeature');
|
||||
goog.require('ol.Collection');
|
||||
goog.require('ol.Color');
|
||||
goog.require('ol.Constraints');
|
||||
@@ -63,14 +64,6 @@ ol.MapProperty = {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @enum {number}
|
||||
*/
|
||||
ol.MapPaneZIndex = {
|
||||
VIEWPORT: 1000
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
@@ -145,15 +138,25 @@ ol.Map = function(container, mapOptionsLiteral) {
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
this.viewport_ = goog.dom.createElement(goog.dom.TagName.DIV);
|
||||
this.viewport_.className = 'ol-viewport';
|
||||
this.viewport_ = goog.dom.createDom(goog.dom.TagName.DIV, 'ol-viewport');
|
||||
this.viewport_.style.position = 'relative';
|
||||
this.viewport_.style.overflow = 'hidden';
|
||||
this.viewport_.style.width = '100%';
|
||||
this.viewport_.style.height = '100%';
|
||||
this.viewport_.style.zIndex = ol.MapPaneZIndex.VIEWPORT;
|
||||
goog.dom.appendChild(container, this.viewport_);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Element}
|
||||
*/
|
||||
this.overlayContainer_ = goog.dom.createDom(goog.dom.TagName.DIV,
|
||||
'ol-overlaycontainer');
|
||||
goog.events.listen(this.overlayContainer_,
|
||||
ol.BrowserFeature.HAS_TOUCH ?
|
||||
goog.events.EventType.TOUCHSTART : goog.events.EventType.MOUSEDOWN,
|
||||
goog.events.Event.stopPropagation);
|
||||
goog.dom.appendChild(this.viewport_, this.overlayContainer_);
|
||||
|
||||
var mapBrowserEventHandler = new ol.MapBrowserEventHandler(this);
|
||||
goog.events.listen(mapBrowserEventHandler, [
|
||||
ol.MapBrowserEvent.EventType.CLICK,
|
||||
@@ -504,6 +507,16 @@ ol.Map.prototype.getViewport = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {Element} The map's overlay container. Elements added to this
|
||||
* container won't let mousedown and touchstart events through to the map, so
|
||||
* clicks and gestures on an overlay don't trigger any MapBrowserEvent.
|
||||
*/
|
||||
ol.Map.prototype.getOverlayContainer = function() {
|
||||
return this.overlayContainer_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @param {string=} opt_type Type.
|
||||
|
||||
Reference in New Issue
Block a user