Skip to content

Commit

Permalink
ignore layer without geometries listening certain events in Map's Geo…
Browse files Browse the repository at this point in the history
…metryEvents
  • Loading branch information
fuzhenn committed Nov 27, 2023
1 parent 34cf41d commit 6096981
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/layer/OverlayLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/map/Map.Topo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6096981

Please sign in to comment.