@@ -7,7 +7,11 @@ import Fill from 'ol/style/Fill.js';
77import Stroke from 'ol/style/Stroke.js' ;
88import VectorLayer from "ol/layer/Vector" ;
99
10+ // Box selection
11+ import { platformModifierKeyOnly } from 'ol/events/condition.js' ;
12+
1013import { featureToGeoJSON } from "./utils" ;
14+ import DragBox from 'ol/interaction/DragBox.js' ;
1115
1216// TODO: Should be a parameter
1317const highlightStyle = new Style ( {
@@ -58,4 +62,21 @@ function addSelectFeaturesToMap(map: Map, model?: AnyModel): void {
5862 } ) ;
5963}
6064
61- export { addSelectFeaturesToMap } ;
65+ function addBoxSelectionToMap ( map : Map , model ?: AnyModel ) : void {
66+ console . warn ( "Box selection not implemented yet" ) ;
67+
68+ const dragBox = new DragBox ( {
69+ condition : platformModifierKeyOnly ,
70+ } ) ;
71+ map . addInteraction ( dragBox ) ;
72+ dragBox . on ( 'boxend' , function ( ) {
73+ const extent = dragBox . getGeometry ( ) . getExtent ( ) ;
74+ console . log ( "box extent" , extent ) ;
75+ } ) ;
76+
77+ dragBox . on ( 'boxstart' , function ( ) {
78+ // select.clearSelection();
79+ } ) ;
80+ }
81+
82+ export { addSelectFeaturesToMap , addBoxSelectionToMap } ;
0 commit comments