Skip to content

Commit 72aa607

Browse files
committed
fix mbgl客户端3D专题图高亮底色穿透问题
1 parent 44fe370 commit 72aa607

File tree

3 files changed

+13
-54
lines changed

3 files changed

+13
-54
lines changed

dist/iclient9-mapboxgl.js

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -51652,22 +51652,12 @@ var Theme3DLayer = exports.Theme3DLayer = function () {
5165251652
return;
5165351653
}
5165451654
var map = this.map;
51655-
if (map.getSource('highlight')) {
51656-
map.removeSource('highlight');
51657-
}
51658-
map.addSource('highlight', {
51659-
'type': 'geojson',
51660-
'data': {
51661-
"type": "FeatureCollection",
51662-
"features": []
51663-
}
51664-
});
5166551655
map.addLayer({
5166651656
'id': 'highlightLayer',
5166751657
'type': 'fill-extrusion',
51668-
'source': 'highlight',
51669-
'paint': this.getHighlightStyleOptions()
51670-
51658+
'source': this.sourceId,
51659+
'paint': this.getHighlightStyleOptions(),
51660+
"filter": ["in", "$id", ""]
5167151661
});
5167251662

5167351663
var me = this;
@@ -51677,6 +51667,7 @@ var Theme3DLayer = exports.Theme3DLayer = function () {
5167751667
canvas.style.cursor = 'auto';
5167851668

5167951669
var features = map.queryRenderedFeatures(e.point, { layers: [me.id] });
51670+
5168051671
if (me.highlight && me.highlight.callback) {
5168151672
me.highlight.callback(features, e);
5168251673
}
@@ -51685,31 +51676,19 @@ var Theme3DLayer = exports.Theme3DLayer = function () {
5168551676
me._clearHighlight.call(me);
5168651677
return;
5168751678
}
51688-
5168951679
var id = features[0].id;
5169051680
if (featureId === id) {
5169151681
return;
5169251682
}
5169351683
featureId = id;
51694-
me._clearHighlight.call(me);
51695-
var sourceFeatures = map.querySourceFeatures(me.sourceId, { filter: ['==', '$id', id] });
51696-
var i,
51697-
len = sourceFeatures.length;
51698-
var geoFeatures = { 'type': 'FeatureCollection', 'features': [] };
51699-
for (i = 0; i < len; i++) {
51700-
geoFeatures['features'].push(sourceFeatures[i].toJSON());
51701-
}
51702-
map.getSource('highlight').setData(geoFeatures);
51684+
map.setFilter("highlightLayer", ['==', '$id', featureId]);
5170351685
});
5170451686
}
5170551687
}, {
5170651688
key: '_clearHighlight',
5170751689
value: function _clearHighlight() {
5170851690
if (this.map) {
51709-
this.map.getSource('highlight').setData({
51710-
"type": "FeatureCollection",
51711-
"features": []
51712-
});
51691+
this.map.setFilter("highlightLayer", ["in", "$id", ""]);
5171351692
}
5171451693
}
5171551694
}, {

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: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,12 @@ export class Theme3DLayer {
342342
return;
343343
}
344344
var map = this.map;
345-
if (map.getSource('highlight')) {
346-
map.removeSource('highlight');
347-
}
348-
map.addSource('highlight', {
349-
'type': 'geojson',
350-
'data': {
351-
"type": "FeatureCollection",
352-
"features": []
353-
}
354-
});
355345
map.addLayer({
356346
'id': 'highlightLayer',
357347
'type': 'fill-extrusion',
358-
'source': 'highlight',
359-
'paint': this.getHighlightStyleOptions()
360-
348+
'source': this.sourceId,
349+
'paint': this.getHighlightStyleOptions(),
350+
"filter": ["in", "$id", ""]
361351
});
362352

363353
var me = this;
@@ -367,6 +357,7 @@ export class Theme3DLayer {
367357
canvas.style.cursor = 'auto';
368358

369359
var features = map.queryRenderedFeatures(e.point, {layers: [me.id]});
360+
370361
if (me.highlight && me.highlight.callback) {
371362
me.highlight.callback(features, e);
372363
}
@@ -375,29 +366,18 @@ export class Theme3DLayer {
375366
me._clearHighlight.call(me);
376367
return;
377368
}
378-
379369
var id = features[0].id;
380370
if (featureId === id) {
381371
return;
382372
}
383373
featureId = id;
384-
me._clearHighlight.call(me);
385-
var sourceFeatures = map.querySourceFeatures(me.sourceId, {filter: ['==', '$id', id]});
386-
var i, len = sourceFeatures.length;
387-
var geoFeatures = {'type': 'FeatureCollection', 'features': []};
388-
for (i = 0; i < len; i++) {
389-
geoFeatures['features'].push(sourceFeatures[i].toJSON());
390-
}
391-
map.getSource('highlight').setData(geoFeatures);
374+
map.setFilter("highlightLayer", ['==', '$id', featureId]);
392375
});
393376
}
394377

395378
_clearHighlight() {
396379
if (this.map) {
397-
this.map.getSource('highlight').setData({
398-
"type": "FeatureCollection",
399-
"features": []
400-
})
380+
this.map.setFilter("highlightLayer", ["in", "$id", ""]);
401381
}
402382
}
403383

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