2022-09-20 18:05:05 +03:00
|
|
|
///
|
2025-02-25 09:39:16 +02:00
|
|
|
/// Copyright © 2016-2025 The Thingsboard Authors
|
2022-09-20 18:05:05 +03:00
|
|
|
///
|
|
|
|
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
/// you may not use this file except in compliance with the License.
|
|
|
|
|
/// You may obtain a copy of the License at
|
|
|
|
|
///
|
|
|
|
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
///
|
|
|
|
|
/// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
/// See the License for the specific language governing permissions and
|
|
|
|
|
/// limitations under the License.
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
import { FormattedData } from '@shared/models/widget.models';
|
2025-03-05 18:42:25 +02:00
|
|
|
import L from 'leaflet';
|
2025-03-12 18:51:02 +02:00
|
|
|
import { Map as MapLibreGLMap, MapOptions as MapLibreGLMapOptions } from 'maplibre-gl';
|
2025-03-05 18:42:25 +02:00
|
|
|
import { TbMapDatasource } from '@shared/models/widget/maps/map.models';
|
2025-02-25 17:52:19 +02:00
|
|
|
import { MatIconRegistry } from '@angular/material/icon';
|
2022-09-20 18:05:05 +03:00
|
|
|
|
|
|
|
|
// redeclare module, maintains compatibility with @types/leaflet
|
|
|
|
|
declare module 'leaflet' {
|
|
|
|
|
interface MarkerOptions {
|
2025-01-21 19:42:21 +02:00
|
|
|
tbMarkerData?: FormattedData<TbMapDatasource>;
|
2022-09-20 18:05:05 +03:00
|
|
|
}
|
2025-01-03 19:37:04 +02:00
|
|
|
|
|
|
|
|
interface TileLayer {
|
|
|
|
|
_url: string;
|
|
|
|
|
_getSubdomain(tilePoint: L.Coords): string;
|
|
|
|
|
_globalTileRange: L.Bounds;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-27 15:26:19 +02:00
|
|
|
namespace TB {
|
2024-12-30 19:29:15 +02:00
|
|
|
|
|
|
|
|
interface SidebarControlOptions extends ControlOptions {
|
|
|
|
|
container: JQuery<HTMLElement>;
|
|
|
|
|
paneWidth?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SidebarControl extends Control<SidebarControlOptions> {
|
|
|
|
|
constructor(options: SidebarControlOptions);
|
2025-01-10 18:03:40 +02:00
|
|
|
addPane(pane: JQuery<HTMLElement>, button: JQuery<HTMLElement>): this;
|
2024-12-30 19:29:15 +02:00
|
|
|
togglePane(pane: JQuery<HTMLElement>, button: JQuery<HTMLElement>): void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface SidebarPaneControlOptions extends ControlOptions {
|
|
|
|
|
sidebar: SidebarControl;
|
|
|
|
|
uiClass: string;
|
|
|
|
|
buttonTitle?: string;
|
|
|
|
|
paneTitle: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SidebarPaneControl<O extends SidebarPaneControlOptions> extends Control<O> {
|
|
|
|
|
constructor(options: O);
|
|
|
|
|
onAddPane(map: Map, button: JQuery<HTMLElement>, $ui: JQuery<HTMLElement>, toggle: (e: JQuery.MouseEventBase) => void);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface LayerData {
|
|
|
|
|
title: string;
|
2025-01-03 19:37:04 +02:00
|
|
|
attributionPrefix?: string;
|
2024-12-30 19:29:15 +02:00
|
|
|
layer: Layer;
|
|
|
|
|
mini: Layer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface LayersControlOptions extends SidebarPaneControlOptions {
|
|
|
|
|
layers: LayerData[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class LayersControl extends SidebarPaneControl<LayersControlOptions> {
|
|
|
|
|
constructor(options: LayersControlOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-10 18:03:40 +02:00
|
|
|
interface DataLayer {
|
|
|
|
|
toggleGroup(group: string): boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GroupData {
|
|
|
|
|
title: string;
|
|
|
|
|
group: string;
|
|
|
|
|
enabled: boolean;
|
|
|
|
|
dataLayers: DataLayer[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface GroupsControlOptions extends SidebarPaneControlOptions {
|
|
|
|
|
groups: GroupData[];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class GroupsControl extends SidebarPaneControl<GroupsControlOptions> {
|
|
|
|
|
constructor(options: GroupsControlOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 19:32:18 +02:00
|
|
|
interface TopToolbarButtonOptions {
|
|
|
|
|
icon: string;
|
2025-02-25 17:52:19 +02:00
|
|
|
color?: string;
|
2025-01-31 19:32:18 +02:00
|
|
|
title: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TopToolbarButton {
|
2025-02-25 17:52:19 +02:00
|
|
|
constructor(options: TopToolbarButtonOptions, iconRegistry: MatIconRegistry);
|
|
|
|
|
onClick(onClick: (e: MouseEvent, button: TopToolbarButton) => void): void;
|
|
|
|
|
setActive(active: boolean): void;
|
|
|
|
|
isActive(): boolean;
|
|
|
|
|
setDisabled(disabled: boolean): void;
|
|
|
|
|
isDisabled(): boolean;
|
2025-01-31 19:32:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface TopToolbarControlOptions {
|
|
|
|
|
mapElement: JQuery<HTMLElement>;
|
2025-02-25 17:52:19 +02:00
|
|
|
iconRegistry: MatIconRegistry;
|
2025-01-31 19:32:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TopToolbarControl {
|
|
|
|
|
constructor(options: TopToolbarControlOptions);
|
|
|
|
|
toolbarButton(options: TopToolbarButtonOptions): TopToolbarButton;
|
2025-02-25 17:52:19 +02:00
|
|
|
setDisabled(disabled: boolean): void;
|
2025-01-31 19:32:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ToolbarButtonOptions {
|
2025-01-28 15:51:44 +02:00
|
|
|
id: string;
|
2025-01-27 17:56:33 +02:00
|
|
|
title: string;
|
|
|
|
|
click: (e: MouseEvent, button: ToolbarButton) => void;
|
|
|
|
|
iconClass: string;
|
2025-01-29 21:06:11 +02:00
|
|
|
showText?: boolean;
|
2025-01-27 17:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
2025-01-31 19:32:18 +02:00
|
|
|
class ToolbarButton {
|
2025-01-27 17:56:33 +02:00
|
|
|
constructor(options: ToolbarButtonOptions);
|
2025-01-28 15:51:44 +02:00
|
|
|
setActive(active: boolean): void;
|
|
|
|
|
isActive(): boolean;
|
|
|
|
|
setDisabled(disabled: boolean): void;
|
|
|
|
|
isDisabled(): boolean;
|
2025-01-27 17:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
2025-01-28 20:11:46 +02:00
|
|
|
class ToolbarControl extends Control<ControlOptions> {
|
|
|
|
|
constructor(options: ControlOptions);
|
|
|
|
|
toolbarButton(options: ToolbarButtonOptions): ToolbarButton;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-31 19:32:18 +02:00
|
|
|
interface BottomToolbarControlOptions {
|
2025-01-27 17:56:33 +02:00
|
|
|
mapElement: JQuery<HTMLElement>;
|
|
|
|
|
closeTitle: string;
|
2025-01-28 15:51:44 +02:00
|
|
|
onClose: () => boolean;
|
2025-01-27 17:56:33 +02:00
|
|
|
}
|
|
|
|
|
|
2025-01-31 19:32:18 +02:00
|
|
|
class BottomToolbarControl {
|
2025-01-27 17:56:33 +02:00
|
|
|
constructor(options: BottomToolbarControlOptions);
|
2025-01-28 15:51:44 +02:00
|
|
|
getButton(id: string): ToolbarButton | undefined;
|
2025-01-29 21:06:11 +02:00
|
|
|
open(buttons: ToolbarButtonOptions[], showCloseButton?: boolean): void;
|
2025-01-27 17:56:33 +02:00
|
|
|
close(): void;
|
|
|
|
|
container: HTMLElement;
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-30 19:29:15 +02:00
|
|
|
function sidebar(options: SidebarControlOptions): SidebarControl;
|
|
|
|
|
|
|
|
|
|
function sidebarPane<O extends SidebarPaneControlOptions>(options: O): SidebarPaneControl<O>;
|
|
|
|
|
|
|
|
|
|
function layers(options: LayersControlOptions): LayersControl;
|
2025-01-03 19:37:04 +02:00
|
|
|
|
2025-01-10 18:03:40 +02:00
|
|
|
function groups(options: GroupsControlOptions): GroupsControl;
|
|
|
|
|
|
2025-01-31 19:32:18 +02:00
|
|
|
function topToolbar(options: TopToolbarControlOptions): TopToolbarControl;
|
|
|
|
|
|
2025-01-28 20:11:46 +02:00
|
|
|
function toolbar(options: ControlOptions): ToolbarControl;
|
|
|
|
|
|
2025-01-27 17:56:33 +02:00
|
|
|
function bottomToolbar(options: BottomToolbarControlOptions): BottomToolbarControl;
|
|
|
|
|
|
2025-01-03 19:37:04 +02:00
|
|
|
namespace TileLayer {
|
|
|
|
|
|
|
|
|
|
interface ChinaProvidersData {
|
|
|
|
|
[provider: string]: {
|
|
|
|
|
[type: string]: string;
|
|
|
|
|
Subdomains: string;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ChinaProvider extends L.TileLayer {
|
|
|
|
|
constructor(type: string, options?: TileLayerOptions);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace tileLayer {
|
|
|
|
|
function chinaProvider(type: string, options?: TileLayerOptions): TileLayer.ChinaProvider;
|
|
|
|
|
}
|
2025-03-12 18:51:02 +02:00
|
|
|
|
|
|
|
|
namespace MapLibreGL {
|
|
|
|
|
|
|
|
|
|
interface LeafletMapLibreGLMapOptions extends L.InteractiveLayerOptions, Omit<MapLibreGLMapOptions, "container"> {
|
|
|
|
|
updateInterval?: number;
|
|
|
|
|
padding?: number;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class MapLibreGLLayer extends L.Layer {
|
|
|
|
|
constructor(options: LeafletMapLibreGLMapOptions);
|
|
|
|
|
getMapLibreGLMap(): MapLibreGLMap
|
|
|
|
|
getCanvas(): HTMLCanvasElement
|
|
|
|
|
getSize(): L.Point
|
|
|
|
|
getBounds(): L.LatLngBounds
|
|
|
|
|
getContainer(): HTMLDivElement
|
|
|
|
|
getPaneName(): string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function mapLibreGLLayer(options: LeafletMapLibreGLMapOptions): MapLibreGLLayer;
|
|
|
|
|
}
|
2024-12-27 15:26:19 +02:00
|
|
|
}
|
2022-09-20 18:05:05 +03:00
|
|
|
}
|