Skip to content

Commit 65e400e

Browse files
Add a check on the type of the layer in onSelectedLayerChange to prevent calling editVectorLayer on irrelevant layers.
1 parent 673bfd6 commit 65e400e

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

packages/base/src/mainview/mainView.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,7 +2092,7 @@ export class MainView extends React.Component<IProps, IStates> {
20922092
private _getVectorSourceFromLayerID = (
20932093
layerID: string,
20942094
): VectorSource | undefined => {
2095-
/* get the OL vectorSource corresponding to the JGIS currentDrawLayerID */
2095+
/* get the OpenLayers VectorSource corresponding to the JGIS currentDrawLayerID */
20962096
this._currentVectorSource = this._Map
20972097
.getLayers()
20982098
.getArray()
@@ -2123,8 +2123,8 @@ export class MainView extends React.Component<IProps, IStates> {
21232123
}
21242124
const selectedLayerID = Object.keys(selectedLayers)[0];
21252125
this._currentDrawLayerID = selectedLayerID;
2126-
const jGISLayer = this._model.getLayer(selectedLayerID);
2127-
this._currentDrawSourceID = jGISLayer?.parameters?.source;
2126+
const JGISLayer = this._model.getLayer(selectedLayerID);
2127+
this._currentDrawSourceID = JGISLayer?.parameters?.source;
21282128
if (this._currentDrawSourceID) {
21292129
this._currentDrawSource = this._model.getSource(
21302130
this._currentDrawSourceID,
@@ -2247,9 +2247,14 @@ export class MainView extends React.Component<IProps, IStates> {
22472247
? Object.keys(selectedLayers)[0]
22482248
: undefined;
22492249
if (selectedLayerId && selectedLayerId !== this._previousDrawLayerID) {
2250-
this._previousDrawLayerID = selectedLayerId;
2251-
this._currentDrawLayerID = selectedLayerId;
2252-
this._editVectorLayer();
2250+
const selectedLayer = this._model.getLayer(selectedLayerId);
2251+
if (selectedLayer) {
2252+
if (this._model.checkIfIsADrawVectorLayer(selectedLayer)) {
2253+
this._previousDrawLayerID = selectedLayerId;
2254+
this._currentDrawLayerID = selectedLayerId;
2255+
this._editVectorLayer();
2256+
}
2257+
}
22532258
}
22542259
};
22552260

0 commit comments

Comments
 (0)