Skip to content

Commit da4628c

Browse files
Add logics to create the vector layer and to add it to the map.
1 parent 9b3e464 commit da4628c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/base/src/mainview/mainView.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ import { MainViewModel } from './mainviewmodel';
8787
import { Spinner } from './spinner';
8888
import { Geometry, Point } from 'ol/geom';
8989
import Draw from 'ol/interaction/Draw.js';
90+
import Modify from 'ol/interaction/Modify.js';
91+
import Snap from 'ol/interaction/Snap.js';
9092
import { Type } from 'ol/geom/Geometry';
9193

9294
const drawGeometries = ['Point', 'LineString', 'Polygon', 'Circle'];
@@ -2028,11 +2030,27 @@ export class MainView extends React.Component<IProps, IStates> {
20282030
this._removeCurrentDrawInteraction();
20292031
}
20302032
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);
20312046
const draw = new Draw({
20322047
source: source,
20332048
type: drawGeometryType as Type // Type being a geometry type here
20342049
});
2050+
const snap = new Snap({ source: source });
2051+
20352052
this._Map.addInteraction(draw);
2053+
this._Map.addInteraction(snap);
20362054
this._currentDrawInteraction = draw;
20372055
this.setState(old => ({
20382056
...old,

0 commit comments

Comments
 (0)