Add sanity check before adding layer (#1735)

This commit is contained in:
Xiaoji Chen 2022-02-08 10:59:37 -08:00 committed by Xiaoji Chen
parent dd35d0eecc
commit 33cd502536

View File

@ -61,7 +61,7 @@ function updateLayer(map: MapboxMap, id: string, props: LayerProps, prevProps: L
function createLayer(map: MapboxMap, id: string, props: LayerProps) {
// @ts-ignore
if (map.style && map.style._loaded) {
if (map.style && map.style._loaded && map.getSource(props.source)) {
const options: LayerProps = {...props, id};
delete options.beforeId;