@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
931 lines (920 loc) • 37.8 kB
TypeScript
import * as i0 from '@angular/core';
import { TemplateRef, ElementRef, ViewContainerRef, InjectionToken, EventEmitter, SimpleChanges, SimpleChange, IterableDiffers } from '@angular/core';
import { IManagedObject, IEvent, QueriesUtil, InventoryService, IIdentified, IResultList } from '@c8y/client';
import * as i3 from '@c8y/ngx-components';
import { GlobalAutoRefreshWidgetConfig, OptionsService, ServiceRegistry, FeatureCacheService, ManagedObjectRealtimeService, GeoService, DatePipe, WidgetGlobalAutoRefreshService, DynamicComponent, CountdownIntervalComponent, DynamicComponentAlertAggregator, ColorService } from '@c8y/ngx-components';
import * as _c8y_options from '@c8y/options';
import { MapDefaultConfig, MapTileLayer } from '@c8y/options';
import { TranslateService } from '@ngx-translate/core';
import * as L from 'leaflet';
import * as rxjs from 'rxjs';
import { Observable, BehaviorSubject, Subscription, Subject } from 'rxjs';
import { GlobalContextDisplayMode } from '@c8y/ngx-components/global-context';
import * as i1 from '@angular/common';
import * as i2 from '@angular/forms';
import * as i4 from 'ngx-bootstrap/tooltip';
declare class MapPopupDirective {
template: TemplateRef<unknown>;
elementRef: ElementRef;
viewContainer: ViewContainerRef;
constructor(template: TemplateRef<unknown>, elementRef: ElementRef, viewContainer: ViewContainerRef);
static ɵfac: i0.ɵɵFactoryDeclaration<MapPopupDirective, never>;
static ɵdir: i0.ɵɵDirectiveDeclaration<MapPopupDirective, "[c8yMapPopup]", never, {}, {}, never, never, true, never>;
}
/**
* Utility function to assign asset and event information to a Leaflet marker.
* @param marker The Leaflet marker instance.
* @param asset The managed object representing the asset (optional).
* @param event The event associated with the marker (optional).
* @returns The marker with asset and/or event information attached.
*/
declare function getC8yMarker(marker: L.Marker, asset?: PositionManagedObject, event?: IEvent): C8yMarker;
/**
* Injection token for providing map tile layers as an observable.
*/
declare const MAP_TILE_LAYER: InjectionToken<Observable<MapTileLayer[]>>;
/**
* Utility type to require only one of the specified keys in a type.
* @ignore
*/
type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
[]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
}[Keys];
/**
* Attributes that can be attached to a Cumulocity marker.
*/
interface C8yMarkerAttr {
asset: PositionManagedObject;
event: IEvent;
}
/**
* Type representing the attribute keys for a Cumulocity marker.
*/
type C8yMarkerAttributes = keyof C8yMarkerAttr;
/**
* Leaflet marker extended with either asset or event information.
*/
type C8yMarker = L.Marker & RequireOnlyOne<C8yMarkerAttr, 'asset' | 'event'>;
/**
* Enum for supported cluster sizes on the map.
*/
declare enum ClusterSize {
/** No clustering. */
NONE = 0,
/** Cluster of 4. */
FOUR = 1,
/** Cluster of 16. */
SIXTEEN = 2
}
/**
* Enum for map tenant option keys used in configuration.
*/
declare enum MapTenantOptionKeys {
/** Map configuration key. */
CONFIG = "map-config",
/** Map layers key. */
LAYERS = "map-layers"
}
/**
* Managed object with position and optional alarm status and icon for map display.
*/
interface PositionManagedObject extends IManagedObject {
/**
* Position information (latitude, longitude, optional altitude).
*/
c8y_Position: {
lat: number;
lng: number;
alt?: number;
};
/**
* Optional active alarms status for the asset.
*/
c8y_ActiveAlarmsStatus?: {
minor: number;
major: number;
warning: number;
critical: number;
};
/**
* Optional icon information for the asset.
*/
icon?: {
name: string;
};
}
interface GroupedPositionManagedObject {
items: PositionManagedObject[];
}
/**
* Configuration for the cluster map, including center and refresh interval.
*/
type ClusterMapConfig = MapConfig & {
/**
* Center coordinates of the map [latitude, longitude].
*/
center: [number, number];
isRealtimeEnabled?: boolean;
isAutoRefreshEnabled?: boolean;
/**
* Optional refresh interval in milliseconds (null for no auto-refresh).
*/
refreshInterval?: number | null;
/** If set to true, the map will automatically fit to bounds on initialization. */
autoFitToBounds?: boolean;
};
/**
* General map configuration, including options for following, real-time, icon, color, zoom, pan, and bounds.
*/
type MapConfig = MapDefaultConfig & {
/** Whether the map should follow the selected asset. */
follow?: boolean;
/** Whether the map should update in real-time. */
realtime?: boolean;
/** Optional icon name for the map. */
icon?: string;
/** Optional color for the map or marker. */
color?: string;
/** Disable zoom controls. */
disableZoom?: boolean;
/** Disable pan controls. */
disablePan?: boolean;
/** Optional map bounds. */
bounds?: L.LatLngBounds;
/** Optional fit bounds options. */
fitBoundsOptions?: L.FitBoundsOptions;
refreshOption?: 'live' | 'history';
displayMode?: GlobalContextDisplayMode;
} & GlobalAutoRefreshWidgetConfig;
/**
* Injection token for providing the default map configuration as an observable.
*/
declare const MAP_DEFAULT_CONFIG: InjectionToken<Observable<MapDefaultConfig>>;
/**
* Default map tile layer configuration (OpenStreetMap).
*/
declare const defaultLayer: MapTileLayer;
/**
* Default map configuration (centered on Düsseldorf, zoom level 2).
*/
declare const defaultMapConfig: MapDefaultConfig;
/**
* Default options for fitting map bounds (padding).
*/
declare const defaultFitBoundsOptions: L.FitBoundsOptions;
/**
* Configuration for the status buttons shown on the map UI.
*/
type MapStatusButtonsConfig = {
autoRefresh: {
show: boolean;
disabled?: boolean;
};
refresh: {
show: boolean;
disabled?: boolean;
};
/** Real-time button configuration. */
realtime: {
show: boolean;
disabled?: boolean;
};
/** Fit to bounds button configuration. */
fitToBounds: {
show: boolean;
disabled?: boolean;
};
/** Center button configuration. */
center: {
show: boolean;
disabled?: boolean;
};
};
/**
* Extension of QueriesUtil to use decimal literals instead of float literals.
* Used for queries involving longitude and latitude to avoid precision issues.
*/
declare class QueriesUtilDecimalExtension extends QueriesUtil {
useAsFloat(operand: string | number): string;
}
declare class MapService {
private inventory;
private options;
private serviceRegistry;
private featureCacheService;
/**
* Returns asset icon status for highest alarm severity found in device object.
* @param device Device that contains alarms information.
* @returns Status string according to alarm severity
*/
static getStatus(device: PositionManagedObject): "text-muted" | "status critical" | "status major" | "status minor" | "status warning";
/**
* Returns the status of a group (highest severity among its devices).
* @param group The group of devices.
* @returns The status string representing the highest severity in the group.
*/
static getGroupStatus(group: GroupedPositionManagedObject): string;
/**
* Maps status strings to severity levels for comparison.
* @param status The status string.
* @returns Numeric severity level (higher = more severe).
*/
private static getStatusSeverity;
/**
* The devices that are maximal displayed in one cluster.
*/
MAX_DEVICE_PER_CLUSTER: number;
/**
* The count until the cluster is sized. There are a maximum of
* three clusters: 1, 4 or 16.
*/
CLUSTER_LEVEL_THRESHOLD: number;
private queriesUtil;
/**
* @ignore: Only DI.
*/
constructor(inventory: InventoryService, options: OptionsService, serviceRegistry: ServiceRegistry, featureCacheService: FeatureCacheService);
/**
* Returns the leaflet instance used by the cumulocity core.
*/
getLeaflet(): Promise<typeof L>;
/**
* Verifies if a given managed object is a device with a position fragment.
* @param mo The given managed object.
*/
isPositionedDevice(mo: IIdentified): boolean;
/**
* Verifies if a given managed object has a position fragment.
* @param mo The given managed object.
*/
hasPosition(mo: IIdentified): any;
getMapTileLayerProviders(): CumulocityServiceRegistry.MapTileLayerProvider[];
getMapTileLayersFromHookedProviders$(layerProviders: CumulocityServiceRegistry.MapTileLayerProvider[]): Observable<MapTileLayer[]>;
/**
* Returns the layers available in this application.
* Layers are taken from plugins installed to this application.
* In case none of the plugins override the default layers, the default layers are also considered.
* @returns The layers.
*/
getMapTileLayers$(): Observable<MapTileLayer[]>;
/**
* Returns the layers configured in the current platform via tenant options.
* @returns The layers. If not set in tenant options the default layers.
*/
getDefaultLayers(): Observable<MapTileLayer[]>;
/**
* Returns the map configuration configured on the tenant.
* @returns The configuration. If not set in tenant options the default configuration.
*/
getDefaultConfig(): Observable<MapDefaultConfig>;
/**
* Counts all managed objects in a given bound with a c8y_Position fragment.
* @param bound The lat lng bound to request the managed objects for.
* @param isInHierarchyOfMO The group managed object of which direct children should be searched for.
* @returns The number of all position managed objects in the given bound (and group).
*/
getPositionMOsFromBoundCount(bound: L.LatLngBounds, isInHierarchyOfMO?: IManagedObject): Promise<number>;
/**
* Returns all managed objects with a c8y_Position fragment in a certain boundary.
* @param bound The lat lng bound to request the managed objects for.
* @returns All position managed objects in the given bound.
*/
getPositionMOsFromBound(bound: L.LatLngBounds): Promise<PositionManagedObject[]>;
/**
* Returns all managed objects with a c8y_Position fragment in a certain boundary that belongs to a certain group.
* @param bound The lat lng bound to request the managed objects for.
* @param isInHierarchyOfMO The group managed object of which direct children should be searched for.
* @returns All position managed objects in the given bound that are children of the given group.
*/
getPositionMOsFromBound(bound: L.LatLngBounds, isInHierarchyOfMO: IManagedObject): Promise<PositionManagedObject[]>;
/**
* Counts the managed objects in a certain boundary belonging to a group.
* @param bound The lat lng bound to request the managed objects for.
* @param isInHierarchyOfMO The group managed object of which direct children should be searched for.
* @return The count of the managed objects.
*/
getPositionMOsFromBound(bound: L.LatLngBounds, isInHierarchyOfMO: IManagedObject, count: true): Promise<number>;
/**
* Returns all devices with c8y_Position.
*/
getPositionDevices(): Promise<PositionManagedObject[]>;
/**
* Returns all devices with c8y_Position.
* @param pageSize The page size to return.
*/
getPositionDevices(pageSize: number): Promise<PositionManagedObject[]>;
/**
* Returns all devices with c8y_Position.
* @param pageSize The page size to return.
* @param count Counting is disabled
*/
getPositionDevices(pageSize: number, count: false): Promise<PositionManagedObject[]>;
/**
* Returns the number of all devices with c8y_Position.
* @param pageSize The page size to return.
* @param count Counting is enabled
*/
getPositionDevices(pageSize: number, count: true): Promise<number>;
/**
* Returns all managed object with a c8y_Position fragment.
* @param isInHierarchyOfMO The group managed object of which direct children should be searched for.
* @param pageSize Defines how many results should be returned.
* @returns The managed objects with position.
*/
getAllPositionMOs(isInHierarchyOfMO?: IIdentified, pageSize?: number): Promise<IResultList<PositionManagedObject>>;
/**
* Gets the bounds of all assets, optionally within a group.
* @param isInHierarchyOfMO Is inhierachy of managed object to limit the assets to a group.
* @returns The bounds of all assets.
*/
getAllBounds(isInHierarchyOfMO?: IIdentified): Promise<L.LatLngBounds>;
/**
* Determines a rectangular geographical area based on the positions of all devices.
*
* @returns A [[LatLngBounds]] object fitting all devices' geo positions.
*/
getAllDevicesBounds(): Promise<L.LatLngBounds>;
/**
* Calculates the bounding box that contains all given assets.
* @param assets The assets to calculate the bounds for.
* @returns The calculated bounds or undefined if no valid positions are found.
*/
getAssetsBounds(assets: PositionManagedObject[]): Promise<L.LatLngBounds | undefined>;
/**
* Returns the cluster size for clustered maps. Counting the position MOs in a bounding
* and if it reach a threshold, returning a [[ClusterSize]].
* @param bound The bounding to check for cluster size.
* @returns The cluster size, can be NONE, FOUR or SIXTEEN.
*/
getClusterSize(bound: L.LatLngBounds): Promise<ClusterSize>;
private getMapOption;
/**
* Shifts longitudes received from Leaflet.js in the [-180 - k*360; 180 + k*360] rangewhen
* `noWrap` is enabled to the [-180; 180] range expected for values of the c8y_Position fragment.
*
* @param lng Longitude to shift.
* @returns Longitude value in the [-180; 180] range
*/
private normalizeLongitude;
/**
* Shifts longitudes in the [-180; 180] range expected for values of the c8y_Position fragment
* the the [-180 - k*360; 180 + k*360] range expected from Leaflet.js when `noWrap` is enabled.
*
* The method naively adds/subtracts 360 degrees to the original value until the position fits in the expected bounds.
*
* @param pmo A managed object with a `c8y_Position` fragment
* @param bounds The bounds where the position should fit
* @returns A managed object whose `c8y_Position`'s `lng` values has been shifted to fit in bounds
*/
private denormalizePMO;
private childrenOfGroupFilter;
/**
* Internal method to calculate bounds based on position coordinates.
* @param queryName The query parameter name to use ('q' or 'query'). Use q to limit to devices only.
* @param isInHierarchyOfMO Optional managed object to limit the assets to a group.
* @returns The calculated bounds
*/
private getBounds;
static ɵfac: i0.ɵɵFactoryDeclaration<MapService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<MapService>;
}
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;
private markerGroupTitle;
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. (only if it is a C8yMarker)
* @param moOrId Asset, event, or string ID to search for.
* @returns The found marker or undefined.
*/
findMarker(moOrId: string | IEvent | PositionManagedObject): C8yMarker | undefined;
/**
* 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: GroupedPositionManagedObject): C8yMarker;
/**
* Creates and returns a marker for a single asset, including icon and popup.
* @param asset The asset to create a marker for.
* @returns The created marker.
*/
getAssetMarkerSingle(asset: PositionManagedObject): C8yMarker;
/**
* Returns a marker with popup for a group of assets (clustered).
* @param group The asset group.
* @returns A marker for a group of assets (clustered).
*/
getGroupedMarker(group: GroupedPositionManagedObject): C8yMarker;
/**
* Creates spider markers for a group of assets at the same position.
* @param group The group of assets to create spider markers for.
* @param center The center position of the group.
* @param originalMarker The marker which was replaced by spider markers.
*/
createSpiderMarkers(group: GroupedPositionManagedObject, center: L.LatLng, originalMarker: C8yMarker): void;
/**
* The icon for a group of assets (clustered).
* It shows the count and is colored based on the highest severity status in the group.
* @param group The group of assets.
* @returns The marker icon for the group.
*/
getGroupAssetIcon(group: GroupedPositionManagedObject): L.DivIcon;
/**
* 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.
* @param anchor The icon anchor point.
* @returns The Leaflet icon.
*/
getAssetIcon(asset: PositionManagedObject, anchor?: [number, number]): 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>;
}
/**
* Smart map component for that clusters devices together when there are too many to display individually.
* Unlike the basic map, this component loads device data dynamically and manages cluster rendering and updates.
* Extends the base MapComponent with clustering, dynamic data loading, and advanced refresh logic.
*/
declare class ClusterMapComponent extends MapComponent implements DynamicComponent {
protected moRealtimeService: ManagedObjectRealtimeService;
protected mapService: MapService;
protected layers$: Observable<MapTileLayer[]>;
protected defaultConfig$: Observable<MapDefaultConfig>;
protected translateService: TranslateService;
protected widgetGlobalAutoRefreshService: WidgetGlobalAutoRefreshService;
private iterable;
private colorService;
/** Emits true while the map is loading or refreshing clusters. */
isLoading$: BehaviorSubject<boolean>;
/** @ignore */
countdownIntervalComp: CountdownIntervalComponent;
/**
* Cluster map configuration, including clustering thresholds and refresh intervals.
*/
config: ClusterMapConfig;
/**
* The root managed object (e.g., group or device) for which to load and cluster data.
*/
rootNode: IManagedObject;
/**
* Single asset to display (if not clustering). Used for following a specific device.
* If provided, clusters will not be used, and the asset will be displayed individually.
* If not provided, the component will cluster devices based on the root node.
*/
assets: PositionManagedObject;
/**
* Whether to show a color overlay for each cluster rectangle. This can be useful for debugging or visualizing clusters.
*/
showClusterColor: boolean;
/**
* Emits Leaflet map change events (move, moveend) for external listeners.
*/
mapChange: EventEmitter<L.LeafletEvent>;
/** Reference to the map element in the template. */
mapElement: ElementRef;
/** Aggregator for dynamic component alerts. */
alerts: DynamicComponentAlertAggregator;
/** @ignore */
errorNotifier: BehaviorSubject<any>;
/**
* Indicates if the map was manually changed by the user (e.g., panned or zoomed).
*/
isDirty: boolean;
private reloadTrigger$;
private clusters;
private readonly EVENT_THROTTLE_TIME;
/** Tracks the last followed position to prevent unnecessary map movements. */
private lastFollowedPosition;
/** Flag to skip first map movement after switching from realtime (prevents jump to stale cluster data). */
private skipNextFollowMove;
/**
* Constructs the ClusterMapComponent, injecting required services and initializing the base map.
*/
constructor(moRealtimeService: ManagedObjectRealtimeService, mapService: MapService, layers$: Observable<MapTileLayer[]>, defaultConfig$: Observable<MapDefaultConfig>, translateService: TranslateService, widgetGlobalAutoRefreshService: WidgetGlobalAutoRefreshService, iterable: IterableDiffers, colorService: ColorService, geo: GeoService, datePipe: DatePipe);
/**
* @ignore
*/
ngOnChanges(changes: SimpleChanges): Promise<void>;
/**
* Handles changes to the map configuration using a state machine approach.
* @param change The config change object.
*/
changeConfig(change: SimpleChange): void;
/**
* @ignore
*/
ngAfterViewInit(): Promise<void>;
/**
* Resets the map and clusters, re-initializing the component.
*/
reset(): Promise<void>;
/**
* Triggers a reload of cluster data.
*/
reload(): void;
/**
* Cancels an ongoing reload operation.
*/
cancelReload(): void;
/**
* Subscribes to cluster and interval changes, updating clusters as needed.
* Handles auto-refresh and global refresh loading.
*/
listenToClusterAndIntervalChanges(): void;
/**
* Subscribes to map change events for cluster updates.
*/
listenToClusterMapChanges(): void;
/**
* Refreshes markers or clusters, depending on whether a single asset or clusters are shown.
*/
refreshMarkers(): void;
/**
* Overrides base startRealtime to ensure assets and markers are set for single device realtime mode.
* Also switches from cluster subscription to marker-only mode.
*/
startRealtime(): void;
/**
* Determines the current map state based on config.
*/
private getMapState;
/**
* Handles state transitions using a clear state machine pattern.
*/
private handleStateTransition;
/** Realtime → Paused: Keep markers, stop subscriptions */
private transitionRealtimeToPaused;
/** Realtime → Auto-refresh: Switch to cluster mode */
private transitionRealtimeToAutoRefresh;
/** Paused → Realtime: Resume with existing markers */
private transitionPausedToRealtime;
/** Paused → Auto-refresh: Switch to cluster mode */
private transitionPausedToAutoRefresh;
/** Auto-refresh → Realtime: Use cluster position, switch to marker mode */
private transitionAutoRefreshToRealtime;
/** Auto-refresh → Paused: Keep clusters visible, stop listeners, preserve position */
private transitionAutoRefreshToPaused;
/** Helper to preserve marker position before transitions */
private preserveMarkerPosition;
/** Handle follow mode changes */
private handleFollowChanges;
/** Handle refresh interval changes */
private handleRefreshIntervalChanges;
private changeRootNode;
private getClusterRects;
private getRect;
private clearClusters;
private updateCluster;
/**
* Groups nearby assets based on pixel distance threshold.
* @param assets Array of assets to group.
* @param thresholdPixels Distance threshold in pixels.
* @returns Array of asset groups.
*/
private groupNearbyAssets;
/**
* Checks if two assets are within the specified pixel distance.
* @param asset1 First asset.
* @param asset2 Second asset.
* @param thresholdPixels Distance threshold in pixels.
* @returns True if assets are close, false otherwise.
*/
private areMarkersClose;
private createOrUpdateCluster;
private getMapChangeObservable;
private handleGlobalRefreshLoading;
static ɵfac: i0.ɵɵFactoryDeclaration<ClusterMapComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<ClusterMapComponent, "c8y-cluster-map", never, { "config": { "alias": "config"; "required": false; }; "rootNode": { "alias": "rootNode"; "required": false; }; "assets": { "alias": "asset"; "required": false; }; "showClusterColor": { "alias": "showClusterColor"; "required": false; }; }, { "mapChange": "mapChange"; }, never, ["*"], true, never>;
}
declare class ClusterMap {
private iterable;
private addAssetCallback;
private translateService;
markers: C8yMarker[];
positions: GroupedPositionManagedObject[];
set clusterMarker(item: L.Layer);
get clusterMarker(): L.Layer;
set rect(item: L.Rectangle);
get rect(): L.Rectangle;
private _clusterMarker;
private _rect;
private iterableDiffer;
constructor(iterable: IterableDiffers, addAssetCallback: (asset: GroupedPositionManagedObject) => C8yMarker, translateService: TranslateService);
render(map: L.Map): void;
clear(map: L.Map): void;
removeClusterToBigMarker(): void;
addMarkerToMap(device: GroupedPositionManagedObject, map: L.Map): void;
setClusterToBigMarker(map: L.Map, count: any, leaflet: typeof L): void;
private updateChanges;
private trackBy;
private removeMarkerFromMap;
}
/**
* Component to display controls and status information for a map rendered on an IoT Dashboard.
* Provides UI for centering, fitting bounds, toggling real-time updates, auto-refresh, and following assets.
*/
declare class MapStatusComponent {
/**
* Map configuration object, including center, refresh interval, and other map options.
*/
config: ClusterMapConfig;
/**
* List of managed objects with position information to be displayed on the map.
*/
assets: PositionManagedObject[];
/**
* Emits when the map configuration changes (e.g., toggling real-time, follow, etc.).
*/
configChange: EventEmitter<ClusterMapConfig>;
/**
* Emits when the user unfollows an asset on the map.
*/
onUnfollow: EventEmitter<ClusterMapConfig>;
/**
* Emits when the user requests to fit all assets within the map bounds.
*/
fitAssetsToBounds: EventEmitter<void>;
/**
* Reference to the ClusterMapComponent instance rendered in the view.
*/
clusterMap: ClusterMapComponent;
/**
* Configuration for which map status buttons are shown/enabled.
* By default the "center" button is shown and realtime is disabled.
* See {@link MapStatusButtonsConfig} for available options.
*/
buttonsConfig: Partial<MapStatusButtonsConfig>;
/**
* @ignore
*/
countdownIntervalComp: CountdownIntervalComponent;
/**
* @ignore
*/
initConfig: ClusterMapConfig;
/**
* @ignore
*/
refreshPaused: boolean;
/**
* @ignore
*/
autoRefreshPausedLabel: "Auto refresh paused";
/**
* @ignore
*/
autoRefreshEnabledLabel: "Auto refresh enabled";
private destroy$;
/**
* @ignore
*/
ngOnInit(): void;
/**
* @ignore
*/
ngAfterViewInit(): void;
/**
* @ignore
*/
ngOnChanges(changes: SimpleChanges): void;
/**
* Centers the map on the configured center coordinates.
*/
center(): void;
/**
* Emits an event to fit all assets within the map bounds and disables the button until the next change.
*/
fitToBounds(): void;
/**
* Reloads the map data.
*/
reload(): void;
/**
* Cancels the map reload operation.
*/
cancelReload(): void;
/**
* Toggles real-time updates for the map.
*/
toggleRealtime(): void;
/**
* Toggles the auto-refresh state for the map, pausing or resuming the countdown.
* @param $event Mouse event to prevent default and stop propagation.
*/
toggleAutoRefresh($event: MouseEvent): void;
/**
* Disables following an asset on the map and emits the change.
*/
unfollow(): void;
/**
* Enables following an asset on the map and emits the change.
*/
follow(): void;
/**
* @ignore
*/
ngOnDestroy(): void;
/**
* Subscribes to map changes and updates button states based on map bounds and center.
*/
private checkIfMapIsAlreadyCentered;
/**
* Checks if Center button should be disabled according to provided bounds.
* Provided bounds contain coordinates of current map rectangle corners.
* Center button should be disabled if distance between center coordinates (from config) and center of current bounds
* is less than 1/4 of bounds dimensions.
* To achieve it we just need to check if center coordinates (from config) are contained in the boundaries of
* current bounds shrunk by 25%.
* @param bounds Current map view boundaries.
* @returns True if distance between config center and current boundaries center is bigger than 1/4 of boundaries dimensions
*/
private shouldDisableCenterButton;
/**
* Checks if Fit to Bounds button should be disabled based on whether all assets are within the current bounds.
* @param bounds Current map view boundaries.
* @returns True if all assets are already within bounds, false otherwise.
*/
private shouldDisableFitToBoundsButton;
/**
* Returns the default configuration for map status buttons.
* @returns Default MapStatusButtonsConfig object.
*/
private defaultButtonsConfig;
static ɵfac: i0.ɵɵFactoryDeclaration<MapStatusComponent, never>;
static ɵcmp: i0.ɵɵComponentDeclaration<MapStatusComponent, "c8y-map-status", never, { "config": { "alias": "config"; "required": false; }; "assets": { "alias": "assets"; "required": false; }; "clusterMap": { "alias": "clusterMap"; "required": false; }; "buttonsConfig": { "alias": "buttonsConfig"; "required": false; }; }, { "configChange": "configChange"; "onUnfollow": "onUnfollow"; "fitAssetsToBounds": "fitAssetsToBounds"; }, never, ["*"], true, never>;
}
declare function provideMapConfig(): ({
provide: i0.InjectionToken<rxjs.Observable<_c8y_options.MapTileLayer[]>>;
useFactory: (mapService: MapService) => rxjs.Observable<_c8y_options.MapTileLayer[]>;
deps: (typeof MapService)[];
} | {
provide: i0.InjectionToken<rxjs.Observable<_c8y_options.MapDefaultConfig>>;
useFactory: (mapService: MapService) => rxjs.Observable<_c8y_options.MapDefaultConfig>;
deps: (typeof MapService)[];
})[];
declare class MapModule {
static ɵfac: i0.ɵɵFactoryDeclaration<MapModule, never>;
static ɵmod: i0.ɵɵNgModuleDeclaration<MapModule, never, [typeof i1.CommonModule, typeof i2.FormsModule, typeof i3.CommonModule, typeof i3.FormsModule, typeof i3.RealtimeModule, typeof i3.CoreModule, typeof i4.TooltipModule, typeof MapComponent, typeof MapStatusComponent, typeof ClusterMapComponent, typeof MapPopupDirective], [typeof MapComponent, typeof MapStatusComponent, typeof ClusterMapComponent, typeof MapPopupDirective]>;
static ɵinj: i0.ɵɵInjectorDeclaration<MapModule>;
}
declare global {
namespace CumulocityServiceRegistry {
interface SpecificExtensionKeys {
mapTileLayerHook: MapTileLayerProvider;
}
interface MapTileLayerProvider {
getMapTileLayers$(): Observable<MapTileLayer[]>;
overridesDefaultLayer?(): boolean;
}
}
}
//# sourceMappingURL=map-tile-layer-hook.d.ts.map
export { ClusterMap, ClusterMapComponent, ClusterSize, MAP_DEFAULT_CONFIG, MAP_TILE_LAYER, MapComponent, MapModule, MapPopupDirective, MapService, MapStatusComponent, MapTenantOptionKeys, QueriesUtilDecimalExtension, defaultFitBoundsOptions, defaultLayer, defaultMapConfig, getC8yMarker, provideMapConfig };
export type { C8yMarker, C8yMarkerAttributes, ClusterMapConfig, GroupedPositionManagedObject, MapConfig, MapStatusButtonsConfig, PositionManagedObject };
//# sourceMappingURL=index.d.ts.map