@@ -117,7 +117,7 @@ interface IStates {
117117 loadingErrors : Array < { id : string ; error : any ; index : number } > ;
118118 displayTemporalController : boolean ;
119119 filterStates : IDict < IJGISFilterItem | undefined > ;
120- isDrawVectorLayerEnabled : boolean ;
120+ editingVectorLayer : boolean ;
121121 drawGeometryLabel : string | undefined ;
122122}
123123
@@ -170,8 +170,8 @@ export class MainView extends React.Component<IProps, IStates> {
170170 this . _handleGeolocationChanged ,
171171 this ,
172172 ) ;
173- this . _model . drawVectorLayerChanged . connect (
174- this . _updateIsDrawVectorLayerEnabled ,
173+ this . _model . editingVectorLayerChanged . connect (
174+ this . _updateEditingVectorLayer ,
175175 this ,
176176 ) ;
177177
@@ -201,7 +201,7 @@ export class MainView extends React.Component<IProps, IStates> {
201201 loadingErrors : [ ] ,
202202 displayTemporalController : false ,
203203 filterStates : { } ,
204- isDrawVectorLayerEnabled : false ,
204+ editingVectorLayer : false ,
205205 drawGeometryLabel : '' ,
206206 } ;
207207
@@ -250,7 +250,7 @@ export class MainView extends React.Component<IProps, IStates> {
250250
251251 this . _model . sharedModel . awareness . off (
252252 'change' ,
253- this . _onSelectedLayerChangeHandler ,
253+ this . _onSelectedLayerChange ,
254254 ) ;
255255 this . _mainViewModel . dispose ( ) ;
256256 }
@@ -408,24 +408,12 @@ export class MainView extends React.Component<IProps, IStates> {
408408 } ,
409409 } ) ) ;
410410
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-
423411 /* Track changes of selected layers
424412 Get the vector source of the selected layer
425413 Edit the vector layer*/
426414 this . _model . sharedModel . awareness . on (
427415 'change' ,
428- this . _onSelectedLayerChangeHandler ,
416+ this . _onSelectedLayerChange ,
429417 ) ;
430418 }
431419 }
@@ -1515,8 +1503,8 @@ export class MainView extends React.Component<IProps, IStates> {
15151503 const JGISLayer = this . _model . getLayer ( selectedLayerID ) ;
15161504 if ( JGISLayer ) {
15171505 if ( this . _model . checkIfIsADrawVectorLayer ( JGISLayer ) === false ) {
1518- this . _model . isDrawVectorLayerEnabled = false ;
1519- this . _updateIsDrawVectorLayerEnabled ( ) ;
1506+ this . _model . editingVectorLayer = false ;
1507+ this . _updateEditingVectorLayer ( ) ;
15201508 }
15211509 }
15221510
@@ -1767,8 +1755,8 @@ export class MainView extends React.Component<IProps, IStates> {
17671755 if (
17681756 this . _model . checkIfIsADrawVectorLayer ( oldLayer as IJGISLayer ) === true
17691757 ) {
1770- this . _model . isDrawVectorLayerEnabled = false ;
1771- this . _updateIsDrawVectorLayerEnabled ( ) ;
1758+ this . _model . editingVectorLayer = false ;
1759+ this . _updateEditingVectorLayer ( ) ;
17721760 this . _mainViewModel . commands . notifyCommandChanged (
17731761 CommandIDs . toggleDrawFeatures ,
17741762 ) ;
@@ -2093,11 +2081,10 @@ export class MainView extends React.Component<IProps, IStates> {
20932081 // TODO SOMETHING
20942082 } ;
20952083
2096- private _updateIsDrawVectorLayerEnabled ( ) {
2097- const isDrawVectorLayerEnabled : boolean =
2098- this . _model . isDrawVectorLayerEnabled ;
2099- this . setState ( old => ( { ...old , isDrawVectorLayerEnabled } ) ) ;
2100- if ( isDrawVectorLayerEnabled === false && this . _draw ) {
2084+ private _updateEditingVectorLayer ( ) {
2085+ const editingVectorLayer : boolean = this . _model . editingVectorLayer ;
2086+ this . setState ( old => ( { ...old , editingVectorLayer } ) ) ;
2087+ if ( editingVectorLayer === false && this . _draw ) {
21012088 this . _removeDrawInteraction ( ) ;
21022089 }
21032090 }
@@ -2181,7 +2168,7 @@ export class MainView extends React.Component<IProps, IStates> {
21812168
21822169 _updateDrawSource = ( ) => {
21832170 if ( this . _currentVectorSource ) {
2184- this . _currentVectorSource . on ( 'change' , this . _onVectorSourceChangeHandler ) ;
2171+ this . _currentVectorSource . on ( 'change' , this . _onVectorSourceChange ) ;
21852172 }
21862173 } ;
21872174
@@ -2253,11 +2240,7 @@ export class MainView extends React.Component<IProps, IStates> {
22532240 this . _Map . removeInteraction ( this . _modify ) ;
22542241 } ;
22552242
2256- private _onVectorSourceChangeHandler = ( ) => {
2257- this . _onVectorSourceChange ( ) ;
2258- } ;
2259-
2260- private _onSelectedLayerChangeHandler = ( ) => {
2243+ private _onSelectedLayerChange = ( ) => {
22612244 const selectedLayers =
22622245 this . _model . sharedModel . awareness . getLocalState ( ) ?. selected ?. value ;
22632246 const selectedLayerId = selectedLayers
@@ -2298,7 +2281,7 @@ export class MainView extends React.Component<IProps, IStates> {
22982281 ) ;
22992282 } ) }
23002283
2301- { this . state . isDrawVectorLayerEnabled && (
2284+ { this . state . editingVectorLayer && (
23022285 < div
23032286 style = { {
23042287 position : 'absolute' ,
@@ -2325,7 +2308,7 @@ export class MainView extends React.Component<IProps, IStates> {
23252308 < option value = "Select Geometry" selected hidden >
23262309 Geometry type
23272310 </ option >
2328- { drawGeometries . map ( geometryType => (
2311+ { DRAW_GEOMETRIES . map ( geometryType => (
23292312 < option key = { geometryType } value = { geometryType } >
23302313 { geometryType }
23312314 </ option >
0 commit comments