import { Evented , LatLngBounds , Map } from "leaflet" ; import { throttle } from "lodash" ; export default class BoxSelection extends Map . BoxZoom { _ctrlKey = false ; constructor ( map ) { super ( Object . assign ( Object . create ( map ) , { fire : ( type ) => { if ( type == "boxzoomstart" ) this . fire ( "selectstart" , { ctrlKey : this . _ctrlKey } ) ; else if ( type == "boxzoomend" ) this . fire ( "selectend" ) ; return this . _map ; } , fitBounds : ( ) => { return this . _map ; } } ) ) ; } _onMouseDown ( e ) { this . _ctrlKey = e . ctrlKey ; super . _onMouseDown ( e ) ; } _onMouseMove ( e ) { super . _onMouseMove ( e ) ; this . fireSelect ( new LatLngBounds ( this . _map . containerPointToLatLng ( this . _startPoint ) , this . _map . containerPointToLatLng ( this . _point ) ) ) ; } fireSelect = throttle ( ( bounds ) => { this . fire ( "select" , { bounds } ) ; } , 300 ) ; } export default interface BoxSelection extends Evented { } Object . assign ( BoxSelection . prototype , Evented . prototype ) ;