File

libs/map/src/lib/selector/map-selector.component.ts

Extends

CachedMapComponent

Implements

OnChanges AfterViewInit

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(mapCache: MapCache, kvDiffers: KeyValueDiffers, cd: ChangeDetectorRef)
Parameters :
Name Type Optional
mapCache MapCache No
kvDiffers KeyValueDiffers No
cd ChangeDetectorRef No

Properties

Private _baseMaps
Type : LayerMap
Inherited from CachedMapComponent
Private _differBaseMaps
Type : KeyValueDiffer<string | LayerOptions>
Inherited from CachedMapComponent
Private _differOverlayMaps
Type : KeyValueDiffer<string | LayerOptions>
Inherited from CachedMapComponent
Private _overlayMaps
Type : LayerMap
Inherited from CachedMapComponent
Protected layerControl
Type : L.Control.Layers
Inherited from CachedMapComponent
Protected map
Type : L.Map
Inherited from CachedMapComponent

The map object.

Protected oldBaseLayer
Type : L.Control.LayersObject
Default value : {}
Inherited from CachedMapComponent
Protected oldOverlayLayer
Type : L.Control.LayersObject
Default value : {}
Inherited from CachedMapComponent
Protected zoomControl
Type : L.Control.Zoom
Inherited from CachedMapComponent

Methods

Protected Abstract drawGeometries
drawGeometries()

Draws the geometries

Returns : void
Public ngAfterViewInit
ngAfterViewInit()
Returns : void
Public ngOnChanges
ngOnChanges(changes: SimpleChanges)
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
Protected zoomToMarkerBounds
zoomToMarkerBounds(bounds: L.LatLngBoundsExpression)

Zooms to the given bounds

Parameters :
Name Type Optional Description
bounds L.LatLngBoundsExpression No

where to zoom

Returns : void
Private addBaseMap
addBaseMap(layerOptions?: LayerOptions)
Inherited from CachedMapComponent
Parameters :
Name Type Optional
layerOptions LayerOptions Yes
Returns : void
Private addOverlayMap
addOverlayMap(layerOptions: LayerOptions)
Inherited from CachedMapComponent
Parameters :
Name Type Optional
layerOptions LayerOptions No
Returns : void
Protected createMap
createMap()
Inherited from CachedMapComponent
Returns : void
Private generateUUID
generateUUID()
Inherited from CachedMapComponent
Returns : string
Public ngDoCheck
ngDoCheck()
Inherited from CachedMapComponent
Returns : void
Public ngOnChanges
ngOnChanges(changes: SimpleChanges)
Inherited from CachedMapComponent
Parameters :
Name Type Optional
changes SimpleChanges No
Returns : void
Public ngOnDestroy
ngOnDestroy()
Inherited from CachedMapComponent
Returns : void
Public ngOnInit
ngOnInit()
Inherited from CachedMapComponent
Returns : void
Private removeBaseMap
removeBaseMap(layerOptions: LayerOptions)
Inherited from CachedMapComponent
Parameters :
Name Type Optional
layerOptions LayerOptions No
Returns : void
Private removeOverlayMap
removeOverlayMap(layerOptions: LayerOptions)
Inherited from CachedMapComponent
Parameters :
Name Type Optional
layerOptions LayerOptions No
Returns : void
Private updateLayerControl
updateLayerControl()
Inherited from CachedMapComponent
Returns : void
Private updateZoomControl
updateZoomControl()
Inherited from CachedMapComponent
Returns : void

Inputs

avoidZoomToSelection
Type : boolean
filter
Type : HelgolandParameterFilter
fitBoundsMarkerOptions
Type : L.FitBoundsOptions
markerSelectorGenerator
Type : MarkerSelectorGenerator
serviceUrl
Type : string

Outputs

onContentLoading
Type : EventEmitter<boolean>
onNoResultsFound
Type : EventEmitter<boolean>
onSelected
Type : EventEmitter<T>
import {
    AfterViewInit,
    ChangeDetectorRef,
    EventEmitter,
    Input,
    KeyValueDiffers,
    OnChanges,
    Output,
    SimpleChanges,
} from '@angular/core';
import { HelgolandParameterFilter } from '@helgoland/core';
import * as L from 'leaflet';

import { CachedMapComponent } from '../base/cached-map-component';
import { MapCache } from '../base/map-cache.service';
import { MarkerSelectorGenerator } from './model/marker-selector-generator';

export abstract class MapSelectorComponent<T>
    extends CachedMapComponent
    implements OnChanges, AfterViewInit {

    /**
     * @input The serviceUrl, where the selection should be loaded.
     */
    @Input()
    public serviceUrl: string;

    /**
     * @input The filter which should be used, while fetching the selection.
     */
    @Input()
    public filter: HelgolandParameterFilter;

    @Input()
    public avoidZoomToSelection: boolean;

    @Input()
    public markerSelectorGenerator: MarkerSelectorGenerator;

    @Output()
    public onSelected: EventEmitter<T> = new EventEmitter<T>();

    @Output()
    public onContentLoading: EventEmitter<boolean> = new EventEmitter();

    /**
     * @input Additional configuration for the marker zooming (https://leafletjs.com/reference-1.3.4.html#fitbounds-options)
     */
    @Input()
    public fitBoundsMarkerOptions: L.FitBoundsOptions;

    @Output()
    public onNoResultsFound: EventEmitter<boolean> = new EventEmitter();

    constructor(
        protected mapCache: MapCache,
        protected kvDiffers: KeyValueDiffers,
        protected cd: ChangeDetectorRef
    ) {
        super(mapCache, kvDiffers);
    }

    public ngAfterViewInit() {
        this.createMap();
        setTimeout(() => {
            this.drawGeometries();
            this.cd.detectChanges();
        }, 10);
    }

    public ngOnChanges(changes: SimpleChanges) {
        super.ngOnChanges(changes);
        if (this.map) {
            if (changes.serviceUrl || changes.filter || changes.cluster) {
                this.drawGeometries();
            }
        }
    }

    /**
     * Draws the geometries
     *
     * @protected
     * @abstract
     */
    protected abstract drawGeometries(): void;

    /**
     * Zooms to the given bounds
     *
     * @protected
     * @param bounds where to zoom
     */
    protected zoomToMarkerBounds(bounds: L.LatLngBoundsExpression) {
        if (!this.avoidZoomToSelection) {
            this.map.fitBounds(bounds, this.fitBoundsMarkerOptions || {});
        }
    }

}

result-matching ""

    No results matching ""