Skip to content

Commit b1d978b

Browse files
author
farfromrefuge
committed
fix: catch errors on addLayer
1 parent edcf001 commit b1d978b

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/ui-carto/ui/index.android.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,15 @@ export class CartoMap<T = DefaultLatLonKeys> extends CartoViewBase {
300300
if (this.mapView) {
301301
const native: com.carto.layers.TileLayer = layer.getNative();
302302
if (!!native) {
303-
const layers = this.mapView.getLayers();
304-
if (index !== undefined && index < layers.count()) {
305-
layers.insert(index, native);
306-
} else {
307-
layers.add(native);
303+
try {
304+
const layers = this.mapView.getLayers();
305+
if (index !== undefined && index < layers.count()) {
306+
layers.insert(index, native);
307+
} else {
308+
layers.add(native);
309+
}
310+
} catch (error) {
311+
console.error(error)
308312
}
309313
}
310314
}

0 commit comments

Comments
 (0)