mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-18 15:54:22 +00:00
Check if map style is loaded before removing source or layer (#1123)
This commit is contained in:
parent
120f55efe3
commit
1d79ad61e2
@ -104,7 +104,7 @@ export default class Layer<Props: LayerProps> extends PureComponent<Props> {
|
||||
const map = this._map;
|
||||
if (map) {
|
||||
map.off('styledata', this._updateLayer);
|
||||
if (map.style) {
|
||||
if (map.style && map.style._loaded) {
|
||||
map.removeLayer(this.id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,9 +58,11 @@ export default class Source<Props: SourceProps> extends PureComponent<Props> {
|
||||
const map = this._map;
|
||||
if (map) {
|
||||
map.off('styledata', this._updateSource);
|
||||
if (map.style) {
|
||||
requestAnimationFrame(() => map.removeSource(this.id));
|
||||
}
|
||||
requestAnimationFrame(() => {
|
||||
if (map.style && map.style._loaded) {
|
||||
map.removeSource(this.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user