Skip to content

Commit 8f826a4

Browse files
authored
Merge pull request #9 from ericdong79/dev/fix-possible-source-undefined
fix: error if source is undefined
2 parents ebd0813 + 55597f8 commit 8f826a4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,13 @@ export default class FeatureService {
302302
}
303303

304304
_updateFcOnMap(fc) {
305-
this._map.getSource(this.sourceId).setData(fc)
305+
const source = this._map.getSource(this.sourceId);
306+
if(source){
307+
source.setData(fc)
308+
}
309+
else{
310+
console.warn(`Cannot find source with id: ${this.sourceId}`)
311+
}
306312
}
307313

308314
_doesTileOverlapBbox(tile, bbox) {

0 commit comments

Comments
 (0)