Giving the map a getFeatureInfoForPixel method
This method is an entry point for getting feature information. Renderers can use a hit canvas or defer to a layer (source) to get matching features for a pixel. For now this is only implemented for vector layers, and it uses a bbox query because we cannot refine the result because of missing geometry intersection functions yet.
This commit is contained in:
@@ -147,6 +147,12 @@ ol.MapBrowserEventHandler = function(map) {
|
||||
*/
|
||||
this.downListenerKey_ = null;
|
||||
|
||||
/**
|
||||
* @type {?number}
|
||||
* @private
|
||||
*/
|
||||
this.moveListenerKey_ = null;
|
||||
|
||||
/**
|
||||
* @type {Array.<number>}
|
||||
* @private
|
||||
@@ -172,6 +178,9 @@ ol.MapBrowserEventHandler = function(map) {
|
||||
this.downListenerKey_ = goog.events.listen(element,
|
||||
goog.events.EventType.MOUSEDOWN,
|
||||
this.handleMouseDown_, false, this);
|
||||
this.moveListenerKey_ = goog.events.listen(element,
|
||||
goog.events.EventType.MOUSEMOVE,
|
||||
this.relayMouseMove_, false, this);
|
||||
// touch events
|
||||
this.touchListenerKeys_ = [
|
||||
goog.events.listen(element, [
|
||||
@@ -281,6 +290,19 @@ ol.MapBrowserEventHandler.prototype.handleMouseMove_ = function(browserEvent) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @private
|
||||
*/
|
||||
ol.MapBrowserEventHandler.prototype.relayMouseMove_ = function(browserEvent) {
|
||||
if (goog.events.hasListener(
|
||||
this.map_, ol.MapBrowserEvent.EventType.MOUSEMOVE)) {
|
||||
this.dispatchEvent(new ol.MapBrowserEvent(
|
||||
ol.MapBrowserEvent.EventType.MOUSEMOVE, this.map_, browserEvent));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {goog.events.BrowserEvent} browserEvent Browser event.
|
||||
* @private
|
||||
@@ -335,6 +357,7 @@ ol.MapBrowserEventHandler.prototype.handleTouchEnd_ = function(browserEvent) {
|
||||
ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
|
||||
goog.events.unlistenByKey(this.clickListenerKey_);
|
||||
goog.events.unlistenByKey(this.downListenerKey_);
|
||||
goog.events.unlistenByKey(this.moveListenerKey_);
|
||||
if (!goog.isNull(this.dragListenerKeys_)) {
|
||||
goog.array.forEach(this.dragListenerKeys_, goog.events.unlistenByKey);
|
||||
this.dragListenerKeys_ = null;
|
||||
@@ -360,5 +383,6 @@ ol.MapBrowserEvent.EventType = {
|
||||
DRAGEND: 'dragend',
|
||||
TOUCHSTART: goog.events.EventType.TOUCHSTART,
|
||||
TOUCHMOVE: goog.events.EventType.TOUCHMOVE,
|
||||
TOUCHEND: goog.events.EventType.TOUCHEND
|
||||
TOUCHEND: goog.events.EventType.TOUCHEND,
|
||||
MOUSEMOVE: goog.events.EventType.MOUSEMOVE
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user