Skip to content

Commit 505a317

Browse files
committed
fix mbgl 3d专题图移除操作遗留问题
1 parent 2ad7fc0 commit 505a317

File tree

4 files changed

+47
-42
lines changed

4 files changed

+47
-42
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@
137137
- 修复多个客户端专题图叠加偏移的问题
138138
- 修复 `mapboxgl.supermap.MapvLayer``clearData` 失败的问题
139139
- 修复客户端3D专题图高亮时底色穿透问题
140+
- 修复移除客户端3D专题图图层报错问题
140141

141142
### Classic
142143

dist/iclient9-mapboxgl.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -51532,11 +51532,13 @@ var Theme3DLayer = exports.Theme3DLayer = function () {
5153251532
//移除图层
5153351533
var layerId = this.id ? this.id : "theme3DLayer";
5153451534
if (this.map.getLayer(layerId)) {
51535+
this.map.off('mousemove', layerId, this._onMouseMove.bind(this));
5153551536
this.map.removeLayer(layerId);
5153651537
}
5153751538
//移除高亮图层
5153851539
var highlightLayerId = "highlightLayer";
5153951540
if (this.map.getLayer(highlightLayerId)) {
51541+
this._selectFeatureId = null;
5154051542
this.map.removeLayer(highlightLayerId);
5154151543
}
5154251544

@@ -51660,29 +51662,30 @@ var Theme3DLayer = exports.Theme3DLayer = function () {
5166051662
"filter": ["in", "$id", ""]
5166151663
});
5166251664

51663-
var me = this;
51664-
var canvas = document.querySelector('.mapboxgl-canvas-container.mapboxgl-interactive');
51665-
var featureId;
51666-
map.on('mousemove', function (e) {
51667-
canvas.style.cursor = 'auto';
51668-
51669-
var features = map.queryRenderedFeatures(e.point, { layers: [me.id] });
51665+
this._selectFeatureId = null;
51666+
map.on('mousemove', this.id, this._onMouseMove.bind(this));
51667+
}
51668+
}, {
51669+
key: '_onMouseMove',
51670+
value: function _onMouseMove(e) {
51671+
var me = this,
51672+
map = this.map;
51673+
var features = map.queryRenderedFeatures(e.point, { layers: [me.id] });
5167051674

51671-
if (me.highlight && me.highlight.callback) {
51672-
me.highlight.callback(features, e);
51673-
}
51675+
if (me.highlight && me.highlight.callback) {
51676+
me.highlight.callback(features, e);
51677+
}
5167451678

51675-
if (!features || features.length < 1) {
51676-
me._clearHighlight.call(me);
51677-
return;
51678-
}
51679-
var id = features[0].id;
51680-
if (featureId === id) {
51681-
return;
51682-
}
51683-
featureId = id;
51684-
map.setFilter("highlightLayer", ['==', '$id', featureId]);
51685-
});
51679+
if (!features || features.length < 1) {
51680+
me._clearHighlight.call(me);
51681+
return;
51682+
}
51683+
var id = features[0].id;
51684+
if (this._selectFeatureId === id) {
51685+
return;
51686+
}
51687+
this._selectFeatureId = id;
51688+
map.setFilter("highlightLayer", ['==', '$id', this._selectFeatureId]);
5168651689
}
5168751690
}, {
5168851691
key: '_clearHighlight',

dist/iclient9-mapboxgl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mapboxgl/overlay/theme/Theme3DLayer.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,13 @@ export class Theme3DLayer {
233233
//移除图层
234234
var layerId = this.id ? this.id : "theme3DLayer";
235235
if (this.map.getLayer(layerId)) {
236+
this.map.off('mousemove', layerId, this._onMouseMove.bind(this));
236237
this.map.removeLayer(layerId);
237238
}
238239
//移除高亮图层
239240
var highlightLayerId = "highlightLayer";
240241
if (this.map.getLayer(highlightLayerId)) {
242+
this._selectFeatureId = null;
241243
this.map.removeLayer(highlightLayerId);
242244
}
243245

@@ -350,29 +352,28 @@ export class Theme3DLayer {
350352
"filter": ["in", "$id", ""]
351353
});
352354

353-
var me = this;
354-
var canvas = document.querySelector('.mapboxgl-canvas-container.mapboxgl-interactive');
355-
var featureId;
356-
map.on('mousemove', function (e) {
357-
canvas.style.cursor = 'auto';
355+
this._selectFeatureId = null;
356+
map.on('mousemove', this.id, this._onMouseMove.bind(this));
357+
}
358358

359-
var features = map.queryRenderedFeatures(e.point, {layers: [me.id]});
359+
_onMouseMove(e) {
360+
var me = this, map = this.map;
361+
var features = map.queryRenderedFeatures(e.point, {layers: [me.id]});
360362

361-
if (me.highlight && me.highlight.callback) {
362-
me.highlight.callback(features, e);
363-
}
363+
if (me.highlight && me.highlight.callback) {
364+
me.highlight.callback(features, e);
365+
}
364366

365-
if (!features || features.length < 1) {
366-
me._clearHighlight.call(me);
367-
return;
368-
}
369-
var id = features[0].id;
370-
if (featureId === id) {
371-
return;
372-
}
373-
featureId = id;
374-
map.setFilter("highlightLayer", ['==', '$id', featureId]);
375-
});
367+
if (!features || features.length < 1) {
368+
me._clearHighlight.call(me);
369+
return;
370+
}
371+
var id = features[0].id;
372+
if (this._selectFeatureId === id) {
373+
return;
374+
}
375+
this._selectFeatureId = id;
376+
map.setFilter("highlightLayer", ['==', '$id', this._selectFeatureId]);
376377
}
377378

378379
_clearHighlight() {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy