-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathdraw-point-mode.ts
35 lines (30 loc) · 1.05 KB
/
draw-point-mode.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { ClickEvent, PointerMoveEvent, ModeProps, TentativeFeature } from '../types';
import { FeatureCollection, Point } from '../geojson-types';
import { GeoJsonEditMode } from './geojson-edit-mode';
export class DrawPointMode extends GeoJsonEditMode {
createTentativeFeature(props: ModeProps<FeatureCollection>): TentativeFeature {
const { lastPointerMoveEvent } = props;
const lastCoords = lastPointerMoveEvent ? [lastPointerMoveEvent.mapCoords] : [];
return {
type: 'Feature',
properties: {
guideType: 'tentative',
},
geometry: {
type: 'Point',
coordinates: lastCoords[0],
},
};
}
handleClick({ mapCoords }: ClickEvent, props: ModeProps<FeatureCollection>): void {
const geometry: Point = {
type: 'Point',
coordinates: mapCoords,
};
props.onEdit(this.getAddFeatureAction(geometry, props.data));
}
handlePointerMove(event: PointerMoveEvent, props: ModeProps<FeatureCollection>) {
props.onUpdateCursor('cell');
super.handlePointerMove(event, props);
}
}