UNPKG

@c8y/ngx-components

Version:

Angular modules for Cumulocity IoT applications

182 lines 7.32 kB
import { ElementRef, EventEmitter, SimpleChange, SimpleChanges } from '@angular/core'; import { IEvent } from '@c8y/client'; import { DatePipe, GeoService, ManagedObjectRealtimeService, WidgetGlobalAutoRefreshService } from '@c8y/ngx-components'; import type { MapDefaultConfig, MapTileLayer } from '@c8y/options'; import { TranslateService } from '@ngx-translate/core'; import type * as L from 'leaflet'; import { BehaviorSubject, Observable, Subject, Subscription } from 'rxjs'; import { MapPopupDirective } from './map-popup.directive'; import { C8yMarker, C8yMarkerAttributes, MapConfig, PositionManagedObject } from './map.model'; import { MapService } from './map.service'; import * as i0 from "@angular/core"; export declare class MapComponent { protected moRealtimeService: ManagedObjectRealtimeService; protected mapService: MapService; protected layers$: Observable<MapTileLayer[]>; protected defaultConfig$: Observable<MapDefaultConfig>; protected translateService: TranslateService; protected geo: GeoService; protected datePipe: DatePipe; protected widgetGlobalAutoRefreshService: WidgetGlobalAutoRefreshService; /** * The leaflet map object instance. */ map: L.Map; /** * The markers currently placed on the map. */ markers: Array<C8yMarker | L.Marker>; /** * The leaflet library reference used for map operations. */ leaflet: typeof L; /** * Indicates if the map was already initialized. */ isInit: boolean; /** * Reference to the map DOM element. */ mapElement: ElementRef; /** * Reference to the custom popup directive for map markers. */ popup: MapPopupDirective; /** * Map configuration object (center, zoom, icon, color, etc). */ config: MapConfig; /** * Asset(s) to display as markers on the map. */ assets: PositionManagedObject | PositionManagedObject[]; /** * Observable for polyline coordinates to display on the map. */ polyline$: Observable<L.LatLngExpression[] | L.LatLngExpression[][]>; /** * Polyline display options for the map. */ polylineOptions: L.PolylineOptions; /** * Emits when a tracked asset is updated in real-time. */ onRealtimeUpdate: EventEmitter<PositionManagedObject>; /** * Emits observable of map drag/move events. */ onMove: Observable<L.LeafletEvent>; /** * Emits observable of map move end events. */ onMoveEnd: Observable<L.LeafletEvent>; /** * Emits observable of map zoom start events. */ onZoomStart: Observable<L.LeafletEvent>; /** * Emits observable of map zoom end events. */ onZoomEnd: Observable<L.LeafletEvent>; /** * Emits the Leaflet map instance when available. */ onMap: BehaviorSubject<L.Map>; /** * Emits when the map and Leaflet library are initialized. */ onInit: EventEmitter<typeof L>; protected realtimeSubscription: Subscription; protected unsubscribeTrigger$: Subject<void>; protected destroy$: Subject<void>; private markerTitle; constructor(moRealtimeService: ManagedObjectRealtimeService, mapService: MapService, layers$: Observable<MapTileLayer[]>, defaultConfig$: Observable<MapDefaultConfig>, translateService: TranslateService, geo: GeoService, datePipe: DatePipe, widgetGlobalAutoRefreshService: WidgetGlobalAutoRefreshService); /** * Starts real-time updates for a single asset on the map. * Updates marker position and icon as new data arrives. */ startRealtime(): void; /** * Moves the map view to the position of the given asset(s) if follow is enabled. * @param positions The asset or array of assets to center the map on. */ moveToPositionOfMo(positions: PositionManagedObject | PositionManagedObject[]): void; /** * Stops real-time updates for the asset. */ stopRealtime(): void; /** * Finds a marker on the map by asset, event, or ID. * @param moOrId Asset, event, or string ID to search for. * @returns The found marker or undefined. */ findMarker(moOrId: string | IEvent | PositionManagedObject): L.Marker<any> | C8yMarker; /** * Adds a marker to the map and internal marker list. * @param marker The marker to add. */ addMarkerToMap(marker: C8yMarker | L.Marker): void; /** * Creates and returns a marker for the given asset, including icon and popup. * @param asset The asset to create a marker for. * @returns The created marker. */ getAssetMarker(asset: PositionManagedObject): C8yMarker; /** * Creates and returns a marker for a tracking event, including icon and popup. * @param event The event to create a marker for. * @returns The created marker. */ getTrackingMarker(event: IEvent): C8yMarker; /** * Returns a Leaflet icon for the given asset, using config or asset icon and color. * @param asset The asset to get the icon for. * @returns The Leaflet icon. */ getAssetIcon(asset: PositionManagedObject): L.DivIcon; /** * Returns a Leaflet icon for a tracking event. * @returns The Leaflet icon. */ getTrackingIcon(): L.DivIcon; /** * Removes a marker from the map and internal marker list. * @param marker The marker to remove. */ removeMarker(marker: C8yMarker | L.Marker): void; /** * Removes all markers from the map, optionally filtered by marker attribute. * @param fragment Optional marker attribute to filter by. */ clearMarkers(fragment?: C8yMarkerAttributes): void; /** * Refreshes all markers on the map based on the current assets. */ refreshMarkers(): void; /** * Centers the map on the configured center coordinates. */ center(): void; /** * Refreshes the map and markers if the map is initialized. */ refresh(): void; protected ngAfterViewInit(): Promise<void>; protected ngOnChanges(changes: SimpleChanges): void; protected ngOnDestroy(): void; protected unsubscribeAllListeners(): void; protected initOutputs(): void; protected initMap(layers: MapTileLayer[], defaultConfig: MapConfig): void; protected handleMobile(): void; protected addLayers(layers: MapTileLayer[]): void; protected changeConfig(change: SimpleChange): void; protected hasChanged(change: SimpleChange, prop: keyof MapConfig): boolean; protected toggleControls(): void; private handleTouch; private zoomToBound; private fitBounds; private bindPopup; static ɵfac: i0.ɵɵFactoryDeclaration<MapComponent, never>; static ɵcmp: i0.ɵɵComponentDeclaration<MapComponent, "c8y-map", never, { "config": { "alias": "config"; "required": false; }; "assets": { "alias": "assets"; "required": false; }; "polyline$": { "alias": "polyline$"; "required": false; }; "polylineOptions": { "alias": "polylineOptions"; "required": false; }; }, { "onRealtimeUpdate": "onRealtimeUpdate"; "onMove": "onMove"; "onMoveEnd": "onMoveEnd"; "onZoomStart": "onZoomStart"; "onZoomEnd": "onZoomEnd"; "onMap": "onMap"; "onInit": "onInit"; }, ["popup"], ["*"], true, never>; } //# sourceMappingURL=map.component.d.ts.map