diff --git a/packages/base/src/mainview/mainview.tsx b/packages/base/src/mainview/mainview.tsx index 5e9a0734..39b40280 100644 --- a/packages/base/src/mainview/mainview.tsx +++ b/packages/base/src/mainview/mainview.tsx @@ -293,7 +293,7 @@ export class MainView extends React.Component { const currentLayerIds = this._Map.getStyle().layers.map(layer => layer.id); let beforeId: string | undefined = undefined; if (!(index === undefined) && index < currentLayerIds.length) { - beforeId = currentLayerIds[index + 1]; + beforeId = currentLayerIds[index]; } this._Map.moveLayer(id, beforeId); } @@ -373,7 +373,11 @@ export class MainView extends React.Component { if (!layer) { this.removeLayer(change.id); } else { - this.updateLayer(change.id, layer); + if ( + JupyterGISModel.getOrderedLayerIds(this._model).includes(change.id) + ) { + this.updateLayer(change.id, layer); + } } }); } diff --git a/packages/schema/src/model.ts b/packages/schema/src/model.ts index 01bd75ed..ba4d70ce 100644 --- a/packages/schema/src/model.ts +++ b/packages/schema/src/model.ts @@ -332,7 +332,7 @@ export class JupyterGISModel implements IJupyterGISModel { this._sharedModel.updateLayerTreeItem(mainGroupIndex, mainGroup); } else { this.sharedModel.addLayerTreeItem( - index ?? this.getLayerTree.length, + index ?? this.getLayerTree().length, item ); }