Skip to content

Commit cf794e8

Browse files
fix fgblayer sourceid 冲突导致报错
1 parent 78a33fd commit cf794e8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/mapboxgl/overlay/FGBLayer.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export class FGBLayer {
6363
constructor(options = {}) {
6464
this.id = options.layerID ? options.layerID : CommonUtil.createUniqueID('FGBLayer_');
6565
this.layerId = this.id + 'outer';
66-
this.sourceId = this.layerId;
66+
this._sourceId = this.layerId;
6767
this.options = options;
6868
this.strategy = options.strategy || 'bbox';
6969
this.url = options.url;
@@ -134,20 +134,20 @@ export class FGBLayer {
134134
async _handleFeatures(bounds) {
135135
let iter = await this.renderer._loadData(bounds);
136136
const features = await this.renderer.iterateFeatures(iter);
137-
if (!this.map.getSource(this.sourceId)) {
138-
this.map.addSource(this.sourceId, {
137+
if (!this.map.getSource(this._sourceId)) {
138+
this.map.addSource(this._sourceId, {
139139
type: 'geojson',
140140
data: features
141141
});
142142
} else {
143-
this.map.getSource(this.sourceId).setData(features);
143+
this.map.getSource(this._sourceId).setData(features);
144144
}
145145
if (!this.map.getLayer(this.layerId)) {
146146
this.layerType = this.renderer.layerType;
147147
const layer = Object.assign({
148148
id: this.layerId,
149149
type: this.layerType,
150-
source: this.sourceId,
150+
source: this._sourceId,
151151
paint: Object.assign(PAINT_MAP[this.layerType], this.options.paint) || {},
152152
layout: this.options.layout || {}
153153
});
@@ -164,7 +164,7 @@ export class FGBLayer {
164164
if (!alreadyLoaded) {
165165
let iter = await this.renderer._loadData(extentToLoad);
166166
const features = await this.renderer.iterateFeatures(iter);
167-
this.map.getSource(this.sourceId).setData(features);
167+
this.map.getSource(this._sourceId).setData(features);
168168
}
169169
}
170170
}

0 commit comments

Comments
 (0)