diff --git a/src/layer/OverlayLayer.js b/src/layer/OverlayLayer.js index 45a70107ec..1c63b9ec9b 100644 --- a/src/layer/OverlayLayer.js +++ b/src/layer/OverlayLayer.js @@ -52,6 +52,27 @@ class OverlayLayer extends Layer { } } + isGeometryListening(types) { + if (!this._geoList) { + return false; + } + if (!Array.isArray(types)) { + types = [types]; + } + for (let i = 0, l = this._geoList.length; i < l; i++) { + const geometry = this._geoList[i]; + if (!geometry) { + continue; + } + for (let j = 0; j < types.length; j++) { + if (geometry.listens(types[j])) { + return true; + } + } + } + return false; + } + /** * Get a geometry by its id * @param {String|Number} id - id of the geometry diff --git a/src/map/Map.Topo.js b/src/map/Map.Topo.js index 9bb9aa45fe..08ff498724 100644 --- a/src/map/Map.Topo.js +++ b/src/map/Map.Topo.js @@ -106,6 +106,11 @@ Map.include(/** @lends Map.prototype */ { opts.tolerance = opts.tolerance || 0; opts.tolerance += layer.options.geometryEventTolerance; } + if (layer.isGeometryListening && isMapGeometryEvent && opts.eventTypes.indexOf('mousemove') >= 0) { + if (!layer.isGeometryListening(opts.eventTypes)) { + return []; + } + } if (layer.identifyAtPoint) { result = layer.identifyAtPoint(containerPoint, opts); } else if (coordinate && layer.identify) {