import { HTMLWidget , select as d3Select , Utility } from "@hpcc-js/common" ; import { D3SvgOverlay , FeatureGroup , LatLngBounds , LeafletEvent , Map , MarkerClusterGroup } from "@hpcc-js/leaflet-shim" ; import { Leaflet } from "./Leaflet" ; import { ILayer } from "./TileLayer" ; export class FeatureLayer extends Leaflet implements ILayer { protected _layer : FeatureGroup | MarkerClusterGroup ; protected _selection : Utility . SimpleSelection ; constructor ( cluster = false ) { super ( ) ; this . _layer = cluster ? new MarkerClusterGroup ( ) : new FeatureGroup ( ) ; ( this . _layer as any ) . __hpcc_layer = this ; Utility . SimpleSelectionMixin . call ( this ) ; this . layers ( [ this ] ) ; } owner ( _ ) { this . _owner = _ ; } valid ( ) { return true ; } clear ( ) { this . _layer . clearLayers ( ) ; } add ( layer ) { this . _layer . addLayer ( layer ) ; } maxZoom ( ) { return ( this . _owner as any ) . _leafletMap . getMaxZoom ( ) || 24 ; } zoom ( ) { return ( this . _owner as any ) . _leafletMap . getZoom ( ) ; } visibleBounds ( ) { return ( this . _owner as any ) . _leafletMap . getBounds ( ) ; } protected _initPromise ; init ( ) { if ( ! this . _initPromise ) { this . _initPromise = Promise . resolve ( ) ; } return this . _initPromise ; } hasBounds ( ) { return false ; } getBounds ( ) { return this . _layer . getBounds ( ) ; } style ( id , _ ? ) { if ( _ === void 0 ) return d3Select ( this . _layer . getPane ( ) ) . style ( id ) ; d3Select ( this . _layer . getPane ( ) ) . style ( id , _ ) ; return this ; } protected propValue ( colIdx , row , defaultValue ) { return ( colIdx < 0 ? defaultValue : row [ colIdx ] ) || defaultValue ; } layerEnter ( map ) { map . addLayer ( this . _layer ) ; const elem = d3Select ( map . getContainer ( ) ) . select ( ".leaflet-pane.leaflet-marker-pane" ) ; this . _selection . widgetElement ( elem ) ; } layerUpdate ( map ) { } layerExit ( map ) { this . _layer . clearLayers ( ) ; map . removeLayer ( this . _layer ) ; } zoomEnd ( e ) { } moveEnd ( e ) { } viewReset ( e ) { } } FeatureLayer . prototype . _class += " map_FeatureLayer" ; FeatureLayer . prototype . mixin ( Utility . SimpleSelectionMixin ) ; FeatureLayer . prototype . publishReset ( [ "layers" ] ) ; export class ClusterLayer extends FeatureLayer { constructor ( cluster = true ) { super ( cluster ) ; } } ClusterLayer . prototype . _class += " map_ClusterLayer" ; export class D3SurfaceLayer extends FeatureLayer { protected _lfd3 = new D3SvgOverlay ( ) . drawCallback ( ( selection , projection ) => this . layerUpdate ( undefined , projection ) ) ; hasBounds ( ) { return true ; } getBounds ( ) { return this . _lfd3 . getBounds ( ) ; } layerEnter ( map ) { super . layerEnter ( map ) ; this . add ( this . _lfd3 ) ; } layerUpdate ( map , projection ? ) { super . layerUpdate ( map ) ; } clickHandler ( e , row ) { } }