import { tileLayer , TileLayer } from 'leaflet' ; export class LeafletTileLayerDefinition { constructor ( public type , public url , public options ) { } param layerDef returns { TileLayer } static createTileLayer ( layerDef ) { let layer ; switch ( layerDef . type ) { case 'xyz' : layer = tileLayer ( layerDef . url , layerDef . options ) ; break ; case 'wms' : default : layer = tileLayer . wms ( layerDef . url , layerDef . options ) ; break ; } return layer ; } param layerDefs returns { { [ p : string ] : TileLayer } } static createTileLayers ( layerDefs ) { const layers = { } ; for ( const k in layerDefs ) { if ( layerDefs . hasOwnProperty ( k ) ) { layers [ k ] = ( LeafletTileLayerDefinition . createTileLayer ( layerDefs [ k ] ) ) ; } } return layers ; } returns { TileLayer } createTileLayer ( ) { return LeafletTileLayerDefinition . createTileLayer ( this ) ; } }