Skip to content

Commit 0ff5043

Browse files
committed
[fix] 修复使用了MapExtendSymbol时,getLayer接口返回值有误的问题
edit by yangtt ; review by qiul
1 parent db85cdf commit 0ff5043

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/mapboxgl/overlay/symbol/MapExtendSymbol.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function MapExtendSymbol(){
2020
if (!mapboxgl.Map.prototype.symbolHandler) {
2121
mapboxgl.Map.prototype.symbolHandler = new SymbolHandler(map);
2222
}
23-
return mapboxgl.Map.prototype.symbolHandler;
23+
return mapboxgl.Map.prototype.symbolHandler._update(map);
2424
}
2525

2626
if (mapboxgl.Map.prototype.addLayerBySymbolBak === undefined) {

src/mapboxgl/overlay/symbol/SymbolHandler.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class SymbolHandler {
2323
this.#layerSymbols = {};
2424
}
2525

26+
_update(map) {
27+
this.map = map;
28+
return this;
29+
}
30+
2631
/**
2732
* 添加符号图层
2833
* @param {Object} layer
@@ -339,7 +344,7 @@ class SymbolHandler {
339344
*/
340345
moveLayer(layerId, beforeId) {
341346
const layerIds = this.getLayerIds(layerId);
342-
const realBeforeId = beforeId && (this.map.style.getLayer(beforeId)?.id ?? this.getFirstLayerId(beforeId));
347+
const realBeforeId = beforeId && (this.map.style.getLayer(beforeId)?.id ?? this.getFirstLayerId(beforeId));
343348
if (layerIds?.length > 0) {
344349
layerIds.forEach(id => this.map.style.moveLayer(id, realBeforeId));
345350
} else {

0 commit comments

Comments
 (0)