import { Widget } from "@hpcc-js/common" ; import { CRS , FeatureGroup , LatLngBounds , LeafletEvent , Map } from "@hpcc-js/leaflet-shim" ; export interface ILayer { init ( ) : Promise < void > ; hasBounds ( ) : boolean ; getBounds ( ) : LatLngBounds ; layerEnter ( map ) ; layerUpdate ( map ) ; layerExit ( map ) ; zoomEnd ( e ) ; moveEnd ( e ) ; viewReset ( e ) ; } export class TileLayer extends Widget implements ILayer { private _layer = new FeatureGroup ( ) ; protected _crs : any = CRS . EPSG3857 ; constructor ( cluster = false ) { super ( ) ; ( this . _layer as any ) . __hpcc_layer = this ; } crs ( ) { return this . _crs ; } attribution ( ) { return "" ; } clear ( ) { this . _layer . clearLayers ( ) ; } add ( layer ) { this . _layer . addLayer ( layer ) ; } protected _initPromise ; init ( ) { if ( ! this . _initPromise ) { this . _initPromise = Promise . resolve ( ) ; } return this . _initPromise ; } hasBounds ( ) { return false ; } getBounds ( ) { return this . _layer . getBounds ( ) ; } layerEnter ( map ) { map . addLayer ( this . _layer ) ; } layerUpdate ( map ) { } layerExit ( map ) { this . _layer . clearLayers ( ) ; map . removeLayer ( this . _layer ) ; } zoomEnd ( e ) { } moveEnd ( e ) { } viewReset ( e ) { } }