Skip to content

Commit 9190977

Browse files
committed
refinement
1 parent 0538bcb commit 9190977

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/interaction/TrackInteraction.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import type {FeatureType} from './TrackData';
1616
import {Point} from 'ol/geom';
1717
import {containsCoordinate} from 'ol/extent.js';
1818
import {Extent} from "ol/extent";
19+
import {Coordinate} from "ol/coordinate.js";
1920

2021
export interface Options {
2122
map: Map;
@@ -86,16 +87,15 @@ export default class TrackInteraction extends Interaction {
8687
});
8788
}
8889

89-
pixelAtDrawingExtent(pixel: Pixel): boolean {
90+
pixelAtDrawingExtent(coordinate: Coordinate): boolean {
9091
if (!this.drawExtent_?.length) return true;
91-
const coordinate = this.getMap().getCoordinateFromPixel(pixel);
9292
return containsCoordinate(this.drawExtent_, coordinate);
9393
}
9494

9595
createDrawInteraction(source: VectorSource): DrawPoint {
9696
const draw = new DrawPoint({
9797
source: source,
98-
condition: (event) => this.pixelAtDrawingExtent(event.pixel) && this.userAddLastPointCondition_(event) && !this.controlPointOrPOIAtPixel(event.pixel)
98+
condition: (event) => this.pixelAtDrawingExtent(event.coordinate) && this.userAddLastPointCondition_(event) && !this.controlPointOrPOIAtPixel(event.pixel)
9999
});
100100
// @ts-ignore too complicate to declare proper events
101101
draw.on('drawend', (evt) => this.dispatchEvent(evt));
@@ -107,9 +107,9 @@ export default class TrackInteraction extends Interaction {
107107
trackData: trackData,
108108
source: source,
109109
style: style,
110-
condition: (event) => this.pixelAtDrawingExtent(event.pixel) && !this.deleteCondition_(event),
111-
addControlPointCondition: (event) => this.pixelAtDrawingExtent(event.pixel) && this.userAddControlPointCondition_(event),
112-
sketchPointCondition: (event) => this.pixelAtDrawingExtent(event.pixel),
110+
condition: (event) => this.pixelAtDrawingExtent(event.coordinate) && !this.deleteCondition_(event),
111+
addControlPointCondition: (event) => this.pixelAtDrawingExtent(event.coordinate) && this.userAddControlPointCondition_(event),
112+
sketchPointCondition: (event) => this.pixelAtDrawingExtent(event.coordinate),
113113
hitTolerance: hitTolerance,
114114
});
115115
// @ts-ignore too complicate to declare proper events

0 commit comments

Comments
 (0)