@@ -87,6 +87,8 @@ import { MainViewModel } from './mainviewmodel';
87
87
import { Spinner } from './spinner' ;
88
88
import { Geometry , Point } from 'ol/geom' ;
89
89
import Draw from 'ol/interaction/Draw.js' ;
90
+ import Modify from 'ol/interaction/Modify.js' ;
91
+ import Snap from 'ol/interaction/Snap.js' ;
90
92
import { Type } from 'ol/geom/Geometry' ;
91
93
92
94
const drawGeometries = [ 'Point' , 'LineString' , 'Polygon' , 'Circle' ] ;
@@ -2028,11 +2030,27 @@ export class MainView extends React.Component<IProps, IStates> {
2028
2030
this . _removeCurrentDrawInteraction ( ) ;
2029
2031
}
2030
2032
const source = new VectorSource ( ) ;
2033
+ const vectorLayer = new VectorLayer ( {
2034
+ source : source ,
2035
+ style : {
2036
+ 'fill-color' : 'rgba(255, 255, 255, 0.2)' ,
2037
+ 'stroke-color' : '#ffcc33' ,
2038
+ 'stroke-width' : 2 ,
2039
+ 'circle-radius' : 7 ,
2040
+ 'circle-fill-color' : '#ffcc33'
2041
+ }
2042
+ } ) ;
2043
+ this . _Map . addLayer ( vectorLayer ) ;
2044
+ const modify = new Modify ( { source : source } ) ;
2045
+ this . _Map . addInteraction ( modify ) ;
2031
2046
const draw = new Draw ( {
2032
2047
source : source ,
2033
2048
type : drawGeometryType as Type // Type being a geometry type here
2034
2049
} ) ;
2050
+ const snap = new Snap ( { source : source } ) ;
2051
+
2035
2052
this . _Map . addInteraction ( draw ) ;
2053
+ this . _Map . addInteraction ( snap ) ;
2036
2054
this . _currentDrawInteraction = draw ;
2037
2055
this . setState ( old => ( {
2038
2056
...old ,
0 commit comments