@taichina/map-sdk 1.0.0 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,181 +0,0 @@
1
- import type { Map as MaplibreMap, GeoJSONFeature, LngLat, SourceSpecification } from 'maplibre-gl';
2
-
3
- /** 地图图层类型 */
4
- export type LayerType =
5
- | 'station'
6
- | 'track'
7
- | 'signal'
8
- | 'switch'
9
- | 'switch_loc'
10
- | 'insulation'
11
- | 'station_track'
12
- | 'platform'
13
- | 'crossing'
14
- | 'bridge'
15
- | 'tunnel'
16
- | 'culvert'
17
- | 'mileage'
18
- | string;
19
-
20
- /** 地图初始化参数 */
21
- export interface MapParams {
22
- id: string;
23
- source: SourceSpecification | SourceSpecification[];
24
- layers?: unknown[];
25
- subSourceId?: string;
26
- subSource?: SourceSpecification;
27
- }
28
-
29
- /** 画笔工具接口 */
30
- export interface DrawTool {
31
- changeMode(mode: string): void;
32
- setOnFinish(cb: (feature: unknown) => void): void;
33
- setOnChange(cb: (feature: unknown) => void): void;
34
- setOnDelete(cb: (feature: unknown) => void): void;
35
- setOnSelect(cb: (id: string | number) => void): void;
36
- }
37
-
38
- /**
39
- * TeeeMap 实例对外暴露的公共接口。
40
- */
41
- export interface TeeeMap {
42
- /** 底层 maplibre-gl Map 实例 */
43
- readonly map: MaplibreMap;
44
-
45
- /** 添加 GeoJSON 数据源 */
46
- addGeoJsonSource(id: string, data?: GeoJSON.GeoJSON | string): void;
47
- /** 移除指定数据源 */
48
- removeSource(id: string): void;
49
- /** 更新 GeoJSON 数据源内容 */
50
- updateGeoJsonSource(id: string, data: GeoJSON.GeoJSON | string): void;
51
- /** 添加矢量瓦片数据源 */
52
- addVectorTileSource(id: string, url: string): void;
53
- /** 添加栅格瓦片数据源 */
54
- addRasterTileSource(id: string, url: string): void;
55
- /** 添加 GeoJSON 图层 */
56
- addGeoJsonLayer(
57
- layerId: string,
58
- sourceId: string,
59
- type?: 'fill' | 'line' | 'circle' | 'symbol',
60
- paint?: Record<string, unknown>,
61
- layout?: Record<string, unknown>,
62
- ): void;
63
- /** 动态更新图层 paint 样式 */
64
- updateLayerStyle(id: string, paint: Record<string, unknown>): void;
65
- /** 移除指定图层 */
66
- removeLayer(id: string): void;
67
- /** 为指定图层绑定要素点击事件 */
68
- onFeatureClick(
69
- layerIds: string | string[],
70
- callback: (feature: GeoJSONFeature, lngLat: LngLat) => void,
71
- ): void;
72
-
73
- /** 销毁地图实例并释放资源 */
74
- destroy(): void;
75
- /** 初始化地图基础状态 */
76
- initState(): void;
77
- /** 为指定要素初始化 CTC 业务状态 */
78
- initCTCFeatureState(f: GeoJSONFeature): void;
79
- /** 为指定要素初始化 Graph 业务状态 */
80
- initGraphFeatureState(f: GeoJSONFeature): void;
81
- /** 为指定要素初始化 GeoJSON 图层业务状态 */
82
- initGeoJsonFeatureState(f: GeoJSONFeature, layerType: string): void;
83
- /** 初始化 GeoJSON 业务状态 */
84
- initGeoJsonState(): void;
85
-
86
- /** 更新要素业务状态 */
87
- updateFeatureState(code: string | number, state: Record<string, unknown>): void;
88
- /** 获取要素业务状态 */
89
- getFeatureState(code: string | number): Record<string, unknown> | undefined;
90
-
91
- /** 画笔工具实例(地图 load 后挂载) */
92
- readonly drawTool?: DrawTool;
93
-
94
- /** 创建 CTC 施工推演 / 站场平面图 */
95
- createCTCMap(stcode: string, url: string, layers: LayerType[]): void;
96
- /** 创建加密 CTC 施工推演 / 站场平面图 */
97
- createCTCEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
98
- /** 创建人员定位图(RSWP) */
99
- createRSWPMap(url: string): void;
100
- /** 创建普通站场平面图(Graph) */
101
- createGraphMap(stcode: string, url: string, layers: LayerType[]): void;
102
- /** 创建加密站场平面图(Graph) */
103
- createGraphEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
104
- /** 创建地理地图(Geom) */
105
- createGeomMap(stcode: string, url: string, layers: LayerType[]): void;
106
- /** 创建加密地理地图(Geom) */
107
- createGeomEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
108
- /** 创建 GeoJSON 站场图 */
109
- createGeoJsonStationMap(stcode: string, url: string, layers: LayerType[]): Promise<void>;
110
- /** 创建栅格影像地图 */
111
- createRasterMap(url: string): void;
112
- /** 创建加密栅格影像地图 */
113
- createEncryptedRasterMap(url: string): void;
114
- /** 创建 RAGE 地图 */
115
- createRAGEMap(url: string, subUrl: string, code: string): void;
116
- /** 获取 maplibre-gl Map 实例 */
117
- getMap(): MaplibreMap;
118
- }
119
-
120
- /**
121
- * 太昌业务地图 SDK 主类。
122
- * 基于 maplibre-gl 封装,提供一键式地图初始化、图层管理、要素状态控制、加密瓦片及离线包支持。
123
- *
124
- * @example
125
- * ```ts
126
- * import { TeeeMap } from '@teee/map-sdk';
127
- * import maplibregl from 'maplibre-gl';
128
- *
129
- * const teeeMap = new TeeeMap('map-container');
130
- * teeeMap.createCTCMap('1234', 'https://tiles.example.com/{z}/{x}/{y}', ['station', 'track', 'signal']);
131
- * ```
132
- */
133
- export declare class TeeeMap {
134
- constructor(container: string | HTMLElement);
135
-
136
- /** 底层 maplibre-gl Map 实例 */
137
- readonly map: MaplibreMap;
138
-
139
- addGeoJsonSource(id: string, data?: GeoJSON.GeoJSON | string): void;
140
- removeSource(id: string): void;
141
- updateGeoJsonSource(id: string, data: GeoJSON.GeoJSON | string): void;
142
- addVectorTileSource(id: string, url: string): void;
143
- addRasterTileSource(id: string, url: string): void;
144
- addGeoJsonLayer(
145
- layerId: string,
146
- sourceId: string,
147
- type?: 'fill' | 'line' | 'circle' | 'symbol',
148
- paint?: Record<string, unknown>,
149
- layout?: Record<string, unknown>,
150
- ): void;
151
- updateLayerStyle(id: string, paint: Record<string, unknown>): void;
152
- removeLayer(id: string): void;
153
- onFeatureClick(
154
- layerIds: string | string[],
155
- callback: (feature: GeoJSONFeature, lngLat: LngLat) => void,
156
- ): void;
157
-
158
- destroy(): void;
159
- initState(): void;
160
- initCTCFeatureState(f: GeoJSONFeature): void;
161
- initGraphFeatureState(f: GeoJSONFeature): void;
162
- initGeoJsonFeatureState(f: GeoJSONFeature, layerType: string): void;
163
- initGeoJsonState(): void;
164
- updateFeatureState(code: string | number, state: Record<string, unknown>): void;
165
- getFeatureState(code: string | number): Record<string, unknown> | undefined;
166
-
167
- readonly drawTool?: DrawTool;
168
-
169
- createCTCMap(stcode: string, url: string, layers: LayerType[]): void;
170
- createCTCEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
171
- createRSWPMap(url: string): void;
172
- createGraphMap(stcode: string, url: string, layers: LayerType[]): void;
173
- createGraphEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
174
- createGeomMap(stcode: string, url: string, layers: LayerType[]): void;
175
- createGeomEncryptedMap(stcode: string, url: string, layers: LayerType[]): void;
176
- createGeoJsonStationMap(stcode: string, url: string, layers: LayerType[]): Promise<void>;
177
- createRasterMap(url: string): void;
178
- createEncryptedRasterMap(url: string): void;
179
- createRAGEMap(url: string, subUrl: string, code: string): void;
180
- getMap(): MaplibreMap;
181
- }