Skip to content

Commit

Permalink
Fix new layer in map (#26)
Browse files Browse the repository at this point in the history
* Fix the layer position in tree

* Do not update a layer not in the tree

* Fix the layer position in Map after layerTree update

* linter
  • Loading branch information
brichet authored Jul 2, 2024
1 parent 40ddf32 commit b9d1c78
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/base/src/mainview/mainview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export class MainView extends React.Component<IProps, IStates> {
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);
}
Expand Down Expand Up @@ -373,7 +373,11 @@ export class MainView extends React.Component<IProps, IStates> {
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);
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down

0 comments on commit b9d1c78

Please sign in to comment.