Skip to content

Commit

Permalink
[fix]ISVJ-6583大屏自定义地图切换 预览点选不生效 review by qiw
Browse files Browse the repository at this point in the history
  • Loading branch information
luoxiao-supermap committed Aug 21, 2023
1 parent 7ee40f0 commit a2f5aa6
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/mapboxgl/web-map/control/identify/Identify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,6 @@ export default {
}
}
return style;
},
layersOnMap() {
let layersOnMap = [];
if (this.map) {
for (let i = 0; i < this.layers.length; i++) {
if (this.map.getLayer(this.layers[i])) {
layersOnMap.push(this.layers[i]);
}
}
}
return layersOnMap;
}
},
watch: {
Expand Down Expand Up @@ -176,7 +165,7 @@ export default {
layerStyle: this.layerStyle
});
this.map && this.bindMapClick(this.map);
this.changeClickedLayersCursor(this.layersOnMap);
this.changeClickedLayersCursor(this.layers);
}
},
// 给图层绑定popup和高亮
Expand Down Expand Up @@ -206,14 +195,15 @@ export default {
}
},
// 给layer绑定queryRenderedFeatures
bindQueryRenderedFeatures(e, layers = this.layersOnMap) {
bindQueryRenderedFeatures(e, layers = this.layers) {
let map = e.target;
const layersOnMap = layers.filter(item => !!map.getLayer(item));
let bbox = [
[e.point.x - this.clickTolerance, e.point.y - this.clickTolerance],
[e.point.x + this.clickTolerance, e.point.y + this.clickTolerance]
];
let features = map.queryRenderedFeatures(bbox, {
layers
layers: layersOnMap
});
return features;
},
Expand Down Expand Up @@ -281,12 +271,13 @@ export default {
changeCursorPointer() {
this.changeCursor('pointer', this.map);
},
removeCursorEvent(layers = this.layersOnMap) {
removeCursorEvent(layers = this.layers) {
if (!this.map) {
return;
}
const layersOnMap = layers.filter(item => !!this.map.getLayer(item));
this.map.off('click', this.sourceMapClickFn);
layers.forEach(layer => {
layersOnMap.forEach(layer => {
this.map.off('mousemove', layer, this.changeCursorPointer);
this.map.off('mouseleave', layer, this.changeCursorGrab);
this.changeCursor('grab', this.map);
Expand Down

0 comments on commit a2f5aa6

Please sign in to comment.