@@ -16,6 +16,7 @@ import type {FeatureType} from './TrackData';
16
16
import { Point } from 'ol/geom' ;
17
17
import { containsCoordinate } from 'ol/extent.js' ;
18
18
import { Extent } from "ol/extent" ;
19
+ import { Coordinate } from "ol/coordinate.js" ;
19
20
20
21
export interface Options {
21
22
map : Map ;
@@ -86,16 +87,15 @@ export default class TrackInteraction extends Interaction {
86
87
} ) ;
87
88
}
88
89
89
- pixelAtDrawingExtent ( pixel : Pixel ) : boolean {
90
+ pixelAtDrawingExtent ( coordinate : Coordinate ) : boolean {
90
91
if ( ! this . drawExtent_ ?. length ) return true ;
91
- const coordinate = this . getMap ( ) . getCoordinateFromPixel ( pixel ) ;
92
92
return containsCoordinate ( this . drawExtent_ , coordinate ) ;
93
93
}
94
94
95
95
createDrawInteraction ( source : VectorSource ) : DrawPoint {
96
96
const draw = new DrawPoint ( {
97
97
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 )
99
99
} ) ;
100
100
// @ts -ignore too complicate to declare proper events
101
101
draw . on ( 'drawend' , ( evt ) => this . dispatchEvent ( evt ) ) ;
@@ -107,9 +107,9 @@ export default class TrackInteraction extends Interaction {
107
107
trackData : trackData ,
108
108
source : source ,
109
109
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 ) ,
113
113
hitTolerance : hitTolerance ,
114
114
} ) ;
115
115
// @ts -ignore too complicate to declare proper events
0 commit comments