@@ -117,7 +117,7 @@ interface IStates {
117
117
loadingErrors : Array < { id : string ; error : any ; index : number } > ;
118
118
displayTemporalController : boolean ;
119
119
filterStates : IDict < IJGISFilterItem | undefined > ;
120
- isDrawVectorLayerEnabled : boolean ;
120
+ editingVectorLayer : boolean ;
121
121
drawGeometryLabel : string | undefined ;
122
122
}
123
123
@@ -170,8 +170,8 @@ export class MainView extends React.Component<IProps, IStates> {
170
170
this . _handleGeolocationChanged ,
171
171
this ,
172
172
) ;
173
- this . _model . drawVectorLayerChanged . connect (
174
- this . _updateIsDrawVectorLayerEnabled ,
173
+ this . _model . editingVectorLayerChanged . connect (
174
+ this . _updateEditingVectorLayer ,
175
175
this ,
176
176
) ;
177
177
@@ -201,7 +201,7 @@ export class MainView extends React.Component<IProps, IStates> {
201
201
loadingErrors : [ ] ,
202
202
displayTemporalController : false ,
203
203
filterStates : { } ,
204
- isDrawVectorLayerEnabled : false ,
204
+ editingVectorLayer : false ,
205
205
drawGeometryLabel : '' ,
206
206
} ;
207
207
@@ -250,7 +250,7 @@ export class MainView extends React.Component<IProps, IStates> {
250
250
251
251
this . _model . sharedModel . awareness . off (
252
252
'change' ,
253
- this . _onSelectedLayerChangeHandler ,
253
+ this . _onSelectedLayerChange ,
254
254
) ;
255
255
this . _mainViewModel . dispose ( ) ;
256
256
}
@@ -408,24 +408,13 @@ export class MainView extends React.Component<IProps, IStates> {
408
408
} ,
409
409
} ) ) ;
410
410
411
- /* generate select, modify and snap interactions for features of layers already added to the Map */
412
- this . _select = new Select ( ) ;
413
- this . _modify = new Modify ( {
414
- features : this . _select . getFeatures ( ) ,
415
- } ) ;
416
-
417
- this . _Map . addInteraction ( this . _select ) ;
418
- this . _Map . addInteraction ( this . _modify ) ;
419
-
420
- this . _select . setActive ( true ) ;
421
- this . _modify . setActive ( true ) ;
422
-
411
+
423
412
/* Track changes of selected layers
424
413
Get the vector source of the selected layer
425
414
Edit the vector layer*/
426
415
this . _model . sharedModel . awareness . on (
427
416
'change' ,
428
- this . _onSelectedLayerChangeHandler ,
417
+ this . _onSelectedLayerChange ,
429
418
) ;
430
419
}
431
420
}
@@ -1379,8 +1368,8 @@ export class MainView extends React.Component<IProps, IStates> {
1379
1368
const parsedGeometry = isOlGeometry
1380
1369
? geometry
1381
1370
: new GeoJSON ( ) . readGeometry ( geometry , {
1382
- featureProjection : this . _Map . getView ( ) . getProjection ( ) ,
1383
- } ) ;
1371
+ featureProjection : this . _Map . getView ( ) . getProjection ( ) ,
1372
+ } ) ;
1384
1373
1385
1374
const olFeature = new Feature ( {
1386
1375
geometry : parsedGeometry ,
@@ -1515,8 +1504,8 @@ export class MainView extends React.Component<IProps, IStates> {
1515
1504
const JGISLayer = this . _model . getLayer ( selectedLayerID ) ;
1516
1505
if ( JGISLayer ) {
1517
1506
if ( this . _model . checkIfIsADrawVectorLayer ( JGISLayer ) === false ) {
1518
- this . _model . isDrawVectorLayerEnabled = false ;
1519
- this . _updateIsDrawVectorLayerEnabled ( ) ;
1507
+ this . _model . editingVectorLayer = false ;
1508
+ this . _updateEditingVectorLayer ( ) ;
1520
1509
}
1521
1510
}
1522
1511
@@ -1767,8 +1756,8 @@ export class MainView extends React.Component<IProps, IStates> {
1767
1756
if (
1768
1757
this . _model . checkIfIsADrawVectorLayer ( oldLayer as IJGISLayer ) === true
1769
1758
) {
1770
- this . _model . isDrawVectorLayerEnabled = false ;
1771
- this . _updateIsDrawVectorLayerEnabled ( ) ;
1759
+ this . _model . editingVectorLayer = false ;
1760
+ this . _updateEditingVectorLayer ( ) ;
1772
1761
this . _mainViewModel . commands . notifyCommandChanged (
1773
1762
CommandIDs . toggleDrawFeatures ,
1774
1763
) ;
@@ -2093,11 +2082,11 @@ export class MainView extends React.Component<IProps, IStates> {
2093
2082
// TODO SOMETHING
2094
2083
} ;
2095
2084
2096
- private _updateIsDrawVectorLayerEnabled ( ) {
2097
- const isDrawVectorLayerEnabled : boolean =
2098
- this . _model . isDrawVectorLayerEnabled ;
2099
- this . setState ( old => ( { ...old , isDrawVectorLayerEnabled } ) ) ;
2100
- if ( isDrawVectorLayerEnabled === false && this . _draw ) {
2085
+ private _updateEditingVectorLayer ( ) {
2086
+ const editingVectorLayer : boolean =
2087
+ this . _model . editingVectorLayer ;
2088
+ this . setState ( old => ( { ...old , editingVectorLayer } ) ) ;
2089
+ if ( editingVectorLayer === false && this . _draw ) {
2101
2090
this . _removeDrawInteraction ( ) ;
2102
2091
}
2103
2092
}
@@ -2181,7 +2170,7 @@ export class MainView extends React.Component<IProps, IStates> {
2181
2170
2182
2171
_updateDrawSource = ( ) => {
2183
2172
if ( this . _currentVectorSource ) {
2184
- this . _currentVectorSource . on ( 'change' , this . _onVectorSourceChangeHandler ) ;
2173
+ this . _currentVectorSource . on ( 'change' , this . _onVectorSourceChange ) ;
2185
2174
}
2186
2175
} ;
2187
2176
@@ -2253,11 +2242,7 @@ export class MainView extends React.Component<IProps, IStates> {
2253
2242
this . _Map . removeInteraction ( this . _modify ) ;
2254
2243
} ;
2255
2244
2256
- private _onVectorSourceChangeHandler = ( ) => {
2257
- this . _onVectorSourceChange ( ) ;
2258
- } ;
2259
-
2260
- private _onSelectedLayerChangeHandler = ( ) => {
2245
+ private _onSelectedLayerChange = ( ) => {
2261
2246
const selectedLayers =
2262
2247
this . _model . sharedModel . awareness . getLocalState ( ) ?. selected ?. value ;
2263
2248
const selectedLayerId = selectedLayers
@@ -2298,7 +2283,7 @@ export class MainView extends React.Component<IProps, IStates> {
2298
2283
) ;
2299
2284
} ) }
2300
2285
2301
- { this . state . isDrawVectorLayerEnabled && (
2286
+ { this . state . editingVectorLayer && (
2302
2287
< div
2303
2288
style = { {
2304
2289
position : 'absolute' ,
@@ -2325,7 +2310,7 @@ export class MainView extends React.Component<IProps, IStates> {
2325
2310
< option value = "Select Geometry" selected hidden >
2326
2311
Geometry type
2327
2312
</ option >
2328
- { drawGeometries . map ( geometryType => (
2313
+ { DRAW_GEOMETRIES . map ( geometryType => (
2329
2314
< option key = { geometryType } value = { geometryType } >
2330
2315
{ geometryType }
2331
2316
</ option >
0 commit comments