@movk/maplibre 1.0.0

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.
Files changed (256) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +192 -0
  3. package/README.md +191 -0
  4. package/dist/module.d.mts +20 -0
  5. package/dist/module.d.ts +20 -0
  6. package/dist/module.json +12 -0
  7. package/dist/module.mjs +63 -0
  8. package/dist/runtime/components/CustomLayer.d.vue.ts +24 -0
  9. package/dist/runtime/components/CustomLayer.vue +23 -0
  10. package/dist/runtime/components/CustomLayer.vue.d.ts +24 -0
  11. package/dist/runtime/components/Layer.d.vue.ts +75 -0
  12. package/dist/runtime/components/Layer.vue +112 -0
  13. package/dist/runtime/components/Layer.vue.d.ts +75 -0
  14. package/dist/runtime/components/LayerGroup.d.vue.ts +25 -0
  15. package/dist/runtime/components/LayerGroup.vue +16 -0
  16. package/dist/runtime/components/LayerGroup.vue.d.ts +25 -0
  17. package/dist/runtime/components/LottieMarker.d.vue.ts +50 -0
  18. package/dist/runtime/components/LottieMarker.vue +31 -0
  19. package/dist/runtime/components/LottieMarker.vue.d.ts +50 -0
  20. package/dist/runtime/components/Map.d.vue.ts +84 -0
  21. package/dist/runtime/components/Map.vue +134 -0
  22. package/dist/runtime/components/Map.vue.d.ts +84 -0
  23. package/dist/runtime/components/Marker.d.vue.ts +54 -0
  24. package/dist/runtime/components/Marker.vue +86 -0
  25. package/dist/runtime/components/Marker.vue.d.ts +54 -0
  26. package/dist/runtime/components/Popup.d.vue.ts +30 -0
  27. package/dist/runtime/components/Popup.vue +33 -0
  28. package/dist/runtime/components/Popup.vue.d.ts +30 -0
  29. package/dist/runtime/components/Source.d.vue.ts +23 -0
  30. package/dist/runtime/components/Source.vue +44 -0
  31. package/dist/runtime/components/Source.vue.d.ts +23 -0
  32. package/dist/runtime/components/Tooltip.d.vue.ts +45 -0
  33. package/dist/runtime/components/Tooltip.vue +106 -0
  34. package/dist/runtime/components/Tooltip.vue.d.ts +45 -0
  35. package/dist/runtime/components/buffers/BufferCircle.d.vue.ts +27 -0
  36. package/dist/runtime/components/buffers/BufferCircle.vue +30 -0
  37. package/dist/runtime/components/buffers/BufferCircle.vue.d.ts +27 -0
  38. package/dist/runtime/components/buffers/BufferEllipse.d.vue.ts +35 -0
  39. package/dist/runtime/components/buffers/BufferEllipse.vue +36 -0
  40. package/dist/runtime/components/buffers/BufferEllipse.vue.d.ts +35 -0
  41. package/dist/runtime/components/buffers/BufferLine.d.vue.ts +21 -0
  42. package/dist/runtime/components/buffers/BufferLine.vue +40 -0
  43. package/dist/runtime/components/buffers/BufferLine.vue.d.ts +21 -0
  44. package/dist/runtime/components/buffers/BufferPolygon.d.vue.ts +21 -0
  45. package/dist/runtime/components/buffers/BufferPolygon.vue +40 -0
  46. package/dist/runtime/components/buffers/BufferPolygon.vue.d.ts +21 -0
  47. package/dist/runtime/components/buffers/BufferSector.d.vue.ts +31 -0
  48. package/dist/runtime/components/buffers/BufferSector.vue +35 -0
  49. package/dist/runtime/components/buffers/BufferSector.vue.d.ts +31 -0
  50. package/dist/runtime/components/controls/AttributionControl.d.vue.ts +24 -0
  51. package/dist/runtime/components/controls/AttributionControl.vue +18 -0
  52. package/dist/runtime/components/controls/AttributionControl.vue.d.ts +24 -0
  53. package/dist/runtime/components/controls/FullscreenControl.d.vue.ts +24 -0
  54. package/dist/runtime/components/controls/FullscreenControl.vue +18 -0
  55. package/dist/runtime/components/controls/FullscreenControl.vue.d.ts +24 -0
  56. package/dist/runtime/components/controls/GeolocateControl.d.vue.ts +24 -0
  57. package/dist/runtime/components/controls/GeolocateControl.vue +18 -0
  58. package/dist/runtime/components/controls/GeolocateControl.vue.d.ts +24 -0
  59. package/dist/runtime/components/controls/NavigationControl.d.vue.ts +24 -0
  60. package/dist/runtime/components/controls/NavigationControl.vue +18 -0
  61. package/dist/runtime/components/controls/NavigationControl.vue.d.ts +24 -0
  62. package/dist/runtime/components/controls/ScaleControl.d.vue.ts +24 -0
  63. package/dist/runtime/components/controls/ScaleControl.vue +18 -0
  64. package/dist/runtime/components/controls/ScaleControl.vue.d.ts +24 -0
  65. package/dist/runtime/components/effects/AnimatedImage.d.vue.ts +28 -0
  66. package/dist/runtime/components/effects/AnimatedImage.vue +50 -0
  67. package/dist/runtime/components/effects/AnimatedImage.vue.d.ts +28 -0
  68. package/dist/runtime/components/effects/DiffusionCircle.d.vue.ts +44 -0
  69. package/dist/runtime/components/effects/DiffusionCircle.vue +47 -0
  70. package/dist/runtime/components/effects/DiffusionCircle.vue.d.ts +44 -0
  71. package/dist/runtime/components/effects/FlowBuilding.d.vue.ts +53 -0
  72. package/dist/runtime/components/effects/FlowBuilding.vue +64 -0
  73. package/dist/runtime/components/effects/FlowBuilding.vue.d.ts +53 -0
  74. package/dist/runtime/components/effects/GlowCircle.d.vue.ts +44 -0
  75. package/dist/runtime/components/effects/GlowCircle.vue +42 -0
  76. package/dist/runtime/components/effects/GlowCircle.vue.d.ts +44 -0
  77. package/dist/runtime/components/effects/GradientBuilding.d.vue.ts +25 -0
  78. package/dist/runtime/components/effects/GradientBuilding.vue +37 -0
  79. package/dist/runtime/components/effects/GradientBuilding.vue.d.ts +25 -0
  80. package/dist/runtime/components/effects/Migration.d.vue.ts +50 -0
  81. package/dist/runtime/components/effects/Migration.vue +90 -0
  82. package/dist/runtime/components/effects/Migration.vue.d.ts +50 -0
  83. package/dist/runtime/components/effects/Radar.d.vue.ts +32 -0
  84. package/dist/runtime/components/effects/Radar.vue +49 -0
  85. package/dist/runtime/components/effects/Radar.vue.d.ts +32 -0
  86. package/dist/runtime/components/effects/SpriteImage.d.vue.ts +41 -0
  87. package/dist/runtime/components/effects/SpriteImage.vue +67 -0
  88. package/dist/runtime/components/effects/SpriteImage.vue.d.ts +41 -0
  89. package/dist/runtime/components/effects/TextureBuilding.d.vue.ts +25 -0
  90. package/dist/runtime/components/effects/TextureBuilding.vue +39 -0
  91. package/dist/runtime/components/effects/TextureBuilding.vue.d.ts +25 -0
  92. package/dist/runtime/components/effects/Trail.d.vue.ts +44 -0
  93. package/dist/runtime/components/effects/Trail.vue +61 -0
  94. package/dist/runtime/components/effects/Trail.vue.d.ts +44 -0
  95. package/dist/runtime/components/effects/WaveCircle.d.vue.ts +44 -0
  96. package/dist/runtime/components/effects/WaveCircle.vue +55 -0
  97. package/dist/runtime/components/effects/WaveCircle.vue.d.ts +44 -0
  98. package/dist/runtime/components/effects/WindowBuilding.d.vue.ts +53 -0
  99. package/dist/runtime/components/effects/WindowBuilding.vue +61 -0
  100. package/dist/runtime/components/effects/WindowBuilding.vue.d.ts +53 -0
  101. package/dist/runtime/components/environment/Sky.d.vue.ts +21 -0
  102. package/dist/runtime/components/environment/Sky.vue +15 -0
  103. package/dist/runtime/components/environment/Sky.vue.d.ts +21 -0
  104. package/dist/runtime/components/environment/Temperature.d.vue.ts +47 -0
  105. package/dist/runtime/components/environment/Temperature.vue +41 -0
  106. package/dist/runtime/components/environment/Temperature.vue.d.ts +47 -0
  107. package/dist/runtime/components/environment/Terrain.d.vue.ts +34 -0
  108. package/dist/runtime/components/environment/Terrain.vue +47 -0
  109. package/dist/runtime/components/environment/Terrain.vue.d.ts +34 -0
  110. package/dist/runtime/components/extensions/DrawControl.d.vue.ts +0 -0
  111. package/dist/runtime/components/extensions/DrawControl.vue +168 -0
  112. package/dist/runtime/components/extensions/DrawControl.vue.d.ts +0 -0
  113. package/dist/runtime/components/extensions/TiandituLayer.d.vue.ts +20 -0
  114. package/dist/runtime/components/extensions/TiandituLayer.vue +26 -0
  115. package/dist/runtime/components/extensions/TiandituLayer.vue.d.ts +20 -0
  116. package/dist/runtime/components/extensions/WmsLayer.d.vue.ts +50 -0
  117. package/dist/runtime/components/extensions/WmsLayer.vue +39 -0
  118. package/dist/runtime/components/extensions/WmsLayer.vue.d.ts +50 -0
  119. package/dist/runtime/components/extensions/WmtsLayer.d.vue.ts +42 -0
  120. package/dist/runtime/components/extensions/WmtsLayer.vue +37 -0
  121. package/dist/runtime/components/extensions/WmtsLayer.vue.d.ts +42 -0
  122. package/dist/runtime/components/layers/BuildingLayer.d.vue.ts +28 -0
  123. package/dist/runtime/components/layers/BuildingLayer.vue +41 -0
  124. package/dist/runtime/components/layers/BuildingLayer.vue.d.ts +28 -0
  125. package/dist/runtime/components/layers/ClusterLayer.d.vue.ts +55 -0
  126. package/dist/runtime/components/layers/ClusterLayer.vue +86 -0
  127. package/dist/runtime/components/layers/ClusterLayer.vue.d.ts +55 -0
  128. package/dist/runtime/components/layers/ImageLayer.d.vue.ts +21 -0
  129. package/dist/runtime/components/layers/ImageLayer.vue +25 -0
  130. package/dist/runtime/components/layers/ImageLayer.vue.d.ts +21 -0
  131. package/dist/runtime/components/layers/RasterLayer.d.vue.ts +35 -0
  132. package/dist/runtime/components/layers/RasterLayer.vue +34 -0
  133. package/dist/runtime/components/layers/RasterLayer.vue.d.ts +35 -0
  134. package/dist/runtime/components/layers/VideoLayer.d.vue.ts +28 -0
  135. package/dist/runtime/components/layers/VideoLayer.vue +38 -0
  136. package/dist/runtime/components/layers/VideoLayer.vue.d.ts +28 -0
  137. package/dist/runtime/composables/defineMaplibreControl.d.ts +3 -0
  138. package/dist/runtime/composables/defineMaplibreControl.js +6 -0
  139. package/dist/runtime/composables/useFeatureState.d.ts +35 -0
  140. package/dist/runtime/composables/useFeatureState.js +76 -0
  141. package/dist/runtime/composables/useFrameIcon.d.ts +17 -0
  142. package/dist/runtime/composables/useFrameIcon.js +36 -0
  143. package/dist/runtime/composables/useMap.d.ts +3 -0
  144. package/dist/runtime/composables/useMap.js +9 -0
  145. package/dist/runtime/composables/useMapAnimation.d.ts +21 -0
  146. package/dist/runtime/composables/useMapAnimation.js +13 -0
  147. package/dist/runtime/composables/useMapExport.d.ts +34 -0
  148. package/dist/runtime/composables/useMapExport.js +35 -0
  149. package/dist/runtime/composables/useMaplibre.d.ts +6 -0
  150. package/dist/runtime/composables/useMaplibre.js +4 -0
  151. package/dist/runtime/composables/useMaplibreCamera.d.ts +15 -0
  152. package/dist/runtime/composables/useMaplibreCamera.js +32 -0
  153. package/dist/runtime/composables/useMaplibreDraw.d.ts +10 -0
  154. package/dist/runtime/composables/useMaplibreDraw.js +34 -0
  155. package/dist/runtime/composables/useMaplibreImage.d.ts +19 -0
  156. package/dist/runtime/composables/useMaplibreImage.js +33 -0
  157. package/dist/runtime/composables/useMeasure.d.ts +25 -0
  158. package/dist/runtime/composables/useMeasure.js +173 -0
  159. package/dist/runtime/domains/map/config.d.ts +7 -0
  160. package/dist/runtime/domains/map/config.js +13 -0
  161. package/dist/runtime/domains/map/context.d.ts +13 -0
  162. package/dist/runtime/domains/map/context.js +51 -0
  163. package/dist/runtime/domains/map/control.d.ts +4 -0
  164. package/dist/runtime/domains/map/control.js +28 -0
  165. package/dist/runtime/domains/map/create-map.d.ts +3 -0
  166. package/dist/runtime/domains/map/create-map.js +21 -0
  167. package/dist/runtime/domains/map/draw-context.d.ts +26 -0
  168. package/dist/runtime/domains/map/draw-context.js +73 -0
  169. package/dist/runtime/domains/map/draw-registry.d.ts +5 -0
  170. package/dist/runtime/domains/map/draw-registry.js +15 -0
  171. package/dist/runtime/domains/map/draw-toolbar.d.ts +15 -0
  172. package/dist/runtime/domains/map/draw-toolbar.js +52 -0
  173. package/dist/runtime/domains/map/draw.d.ts +4 -0
  174. package/dist/runtime/domains/map/draw.js +1 -0
  175. package/dist/runtime/domains/map/layer-group.d.ts +9 -0
  176. package/dist/runtime/domains/map/layer-group.js +1 -0
  177. package/dist/runtime/domains/map/registry.d.ts +4 -0
  178. package/dist/runtime/domains/map/registry.js +10 -0
  179. package/dist/runtime/domains/map/resolve.d.ts +7 -0
  180. package/dist/runtime/domains/map/resolve.js +7 -0
  181. package/dist/runtime/domains/map/style-effect.d.ts +6 -0
  182. package/dist/runtime/domains/map/style-effect.js +21 -0
  183. package/dist/runtime/draw-modes/index.d.ts +16 -0
  184. package/dist/runtime/draw-modes/index.js +32 -0
  185. package/dist/runtime/index.css +1 -0
  186. package/dist/runtime/plugins/config.d.ts +2 -0
  187. package/dist/runtime/plugins/config.js +6 -0
  188. package/dist/runtime/types/draw.d.ts +30 -0
  189. package/dist/runtime/types/draw.js +0 -0
  190. package/dist/runtime/types/index.d.ts +3 -0
  191. package/dist/runtime/types/index.js +0 -0
  192. package/dist/runtime/types/map.d.ts +45 -0
  193. package/dist/runtime/types/map.js +0 -0
  194. package/dist/runtime/types/tianditu.d.ts +247 -0
  195. package/dist/runtime/types/tianditu.js +0 -0
  196. package/dist/runtime/utils/animated-image.d.ts +13 -0
  197. package/dist/runtime/utils/animated-image.js +47 -0
  198. package/dist/runtime/utils/buffer.d.ts +24 -0
  199. package/dist/runtime/utils/buffer.js +13 -0
  200. package/dist/runtime/utils/building-effects.d.ts +73 -0
  201. package/dist/runtime/utils/building-effects.js +50 -0
  202. package/dist/runtime/utils/building.d.ts +53 -0
  203. package/dist/runtime/utils/building.js +26 -0
  204. package/dist/runtime/utils/cluster.d.ts +24 -0
  205. package/dist/runtime/utils/cluster.js +42 -0
  206. package/dist/runtime/utils/coordinate.d.ts +12 -0
  207. package/dist/runtime/utils/coordinate.js +44 -0
  208. package/dist/runtime/utils/draw-theme.d.ts +47 -0
  209. package/dist/runtime/utils/draw-theme.js +39 -0
  210. package/dist/runtime/utils/effects.d.ts +34 -0
  211. package/dist/runtime/utils/effects.js +78 -0
  212. package/dist/runtime/utils/events.d.ts +6 -0
  213. package/dist/runtime/utils/events.js +20 -0
  214. package/dist/runtime/utils/frame-icon.d.ts +27 -0
  215. package/dist/runtime/utils/frame-icon.js +45 -0
  216. package/dist/runtime/utils/geometry.d.ts +5 -0
  217. package/dist/runtime/utils/geometry.js +41 -0
  218. package/dist/runtime/utils/heatmap.d.ts +36 -0
  219. package/dist/runtime/utils/heatmap.js +30 -0
  220. package/dist/runtime/utils/layer.d.ts +13 -0
  221. package/dist/runtime/utils/layer.js +17 -0
  222. package/dist/runtime/utils/logger.d.ts +2 -0
  223. package/dist/runtime/utils/logger.js +2 -0
  224. package/dist/runtime/utils/measure.d.ts +4 -0
  225. package/dist/runtime/utils/measure.js +8 -0
  226. package/dist/runtime/utils/sprite.d.ts +31 -0
  227. package/dist/runtime/utils/sprite.js +23 -0
  228. package/dist/runtime/utils/tianditu-administrative.d.ts +3 -0
  229. package/dist/runtime/utils/tianditu-administrative.js +48 -0
  230. package/dist/runtime/utils/tianditu-client.d.ts +30 -0
  231. package/dist/runtime/utils/tianditu-client.js +17 -0
  232. package/dist/runtime/utils/tianditu-geocoder.d.ts +5 -0
  233. package/dist/runtime/utils/tianditu-geocoder.js +37 -0
  234. package/dist/runtime/utils/tianditu-request.d.ts +20 -0
  235. package/dist/runtime/utils/tianditu-request.js +42 -0
  236. package/dist/runtime/utils/tianditu-route.d.ts +3 -0
  237. package/dist/runtime/utils/tianditu-route.js +40 -0
  238. package/dist/runtime/utils/tianditu-search.d.ts +15 -0
  239. package/dist/runtime/utils/tianditu-search.js +183 -0
  240. package/dist/runtime/utils/tianditu.d.ts +21 -0
  241. package/dist/runtime/utils/tianditu.js +26 -0
  242. package/dist/runtime/utils/wms.d.ts +43 -0
  243. package/dist/runtime/utils/wms.js +30 -0
  244. package/dist/runtime/utils/wmts.d.ts +35 -0
  245. package/dist/runtime/utils/wmts.js +29 -0
  246. package/dist/types.d.mts +5 -0
  247. package/dist/unplugin.d.mts +30 -0
  248. package/dist/unplugin.d.ts +30 -0
  249. package/dist/unplugin.mjs +53 -0
  250. package/dist/vite.d.mts +7 -0
  251. package/dist/vite.d.ts +7 -0
  252. package/dist/vite.mjs +11 -0
  253. package/dist/vue-plugin.d.mts +9 -0
  254. package/dist/vue-plugin.d.ts +9 -0
  255. package/dist/vue-plugin.mjs +9 -0
  256. package/package.json +174 -0
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { defineNuxtPlugin, useRuntimeConfig } from "#app";
2
+ import { setMaplibreConfig } from "../domains/map/config.js";
3
+ export default defineNuxtPlugin(() => {
4
+ const config = useRuntimeConfig().public.maplibre;
5
+ if (config) setMaplibreConfig(config);
6
+ });
@@ -0,0 +1,30 @@
1
+ import type { Ref } from 'vue';
2
+ import type { TerraDraw, TerraDrawExtend } from 'terra-draw';
3
+ import type { Feature, FeatureCollection, Geometry } from 'geojson';
4
+ type FeatureId = TerraDrawExtend.FeatureId;
5
+ /**
6
+ * 由 MaplibreDrawControl 下发的绘制上下文。
7
+ * 子树内经 useMaplibreDraw() 注入,子树外经 useMaplibreDraw({ mapId }) 查注册表。
8
+ * 写操作等待实例就绪后执行,并同步控件的 v-model:features / v-model:mode。
9
+ */
10
+ export interface MaplibreDrawContext {
11
+ /** 所属地图 id */
12
+ mapId: string;
13
+ /** terra-draw 实例引用;控件挂载且地图 load 后才有值 */
14
+ draw: Readonly<Ref<TerraDraw | undefined>>;
15
+ /** 实例就绪时 resolve;跨树调用且该 mapId 未注册控件时 reject */
16
+ whenReady: () => Promise<TerraDraw>;
17
+ /** 切换绘制模式(如 'select'、'polygon') */
18
+ changeMode: (mode: string) => Promise<void>;
19
+ /** 添加要素;缺失 id 时自动生成,缺失 properties.mode 时按几何类型推断。返回成功添加的要素 id */
20
+ add: (geojson: Feature | FeatureCollection | Geometry) => Promise<FeatureId[]>;
21
+ /** 清空全部要素 */
22
+ deleteAll: () => Promise<void>;
23
+ /** 设置要素属性(如 color 覆盖主题色) */
24
+ setFeatureProperty: (featureId: FeatureId, property: string, value: unknown) => Promise<void>;
25
+ /** 已完成的要素集合(不含绘制中的要素与辅助点);未就绪时为 undefined */
26
+ getAll: () => FeatureCollection | undefined;
27
+ /** 当前绘制模式;未就绪时为 undefined */
28
+ getMode: () => string | undefined;
29
+ }
30
+ export {};
File without changes
@@ -0,0 +1,3 @@
1
+ export type * from './draw';
2
+ export type * from './map';
3
+ export type * from './tianditu';
File without changes
@@ -0,0 +1,45 @@
1
+ import type { Ref, ShallowRef } from 'vue';
2
+ import type { Map as MaplibreMap, MapOptions } from 'maplibre-gl';
3
+ /** 运行时全局配置;Nuxt 模式由插件注入,Vue 模式由 vue-plugin 注入 */
4
+ export interface MaplibreRuntimeConfig {
5
+ /** 天地图服务 token(tk),用于天地图底图与地理编码 */
6
+ tk?: string;
7
+ /** 字体 pbf 地址模板(含 {fontstack} 与 {range}),用于 MaplibreMap 缺省的空白样式;未配置时空白样式不支持文字标注 */
8
+ glyphs?: string;
9
+ /** 库内置文字图层(聚合计数、量算标签)使用的字体栈,需存在于当前样式的 glyphs 服务;未配置时使用 MapLibre 默认字体 */
10
+ textFont?: string[];
11
+ /** maplibre-gl worker 脚本地址;经打包工具(Vite 等)使用时必需,Nuxt 模块已自动注入 */
12
+ workerUrl?: string;
13
+ /** Web Worker 数量 */
14
+ workerCount?: number;
15
+ /** 是否预热 GL 资源 */
16
+ prewarm?: boolean;
17
+ /** RTL 文本插件;true 使用默认 CDN,或自定义地址与懒加载 */
18
+ RTLTextPlugin?: boolean | {
19
+ pluginURL?: string;
20
+ lazy?: boolean;
21
+ };
22
+ }
23
+ /** MaplibreMap 组件 options:剔除 container(由组件内部接管) */
24
+ export type MaplibreMapOptions = Omit<MapOptions, 'container'>;
25
+ /** 弹窗触发时机;'none' 表示不绑定自动触发,由外部受控 */
26
+ export type PopupTrigger = 'click' | 'hover' | 'none';
27
+ /**
28
+ * 由 MaplibreMap 向子组件下发的地图上下文。
29
+ * 子组件经 useMap() 注入,直接访问实例与就绪状态,无需 id 查表。
30
+ */
31
+ export interface MaplibreContext {
32
+ /** 地图 id(未显式指定时为内部生成的唯一值) */
33
+ id: string;
34
+ /** 地图实例引用;SSR 与挂载前为 undefined */
35
+ map: ShallowRef<MaplibreMap | undefined>;
36
+ /** 样式是否已加载完成 */
37
+ isLoaded: Ref<boolean>;
38
+ /** 样式首次加载完成时 resolve */
39
+ whenLoaded: () => Promise<MaplibreMap>;
40
+ /**
41
+ * 样式就绪即执行回调,且每次 setStyle 重新加载后重跑(用于重建 source/layer)。
42
+ * 返回取消订阅函数。
43
+ */
44
+ onReady: (callback: (map: MaplibreMap) => void) => () => void;
45
+ }
File without changes
@@ -0,0 +1,247 @@
1
+ import type { LineString, MultiPolygon } from 'geojson';
2
+ /** 经纬度包围盒 [minx, miny, maxx, maxy],WGS84。 */
3
+ export type Bounds = [number, number, number, number];
4
+ /** 地名搜索返回的 POI 点;天地图坐标系 CGCS2000 与 WGS84 兼容,坐标原样透传。 */
5
+ export interface Poi {
6
+ name: string;
7
+ address?: string;
8
+ phone?: string;
9
+ /** WGS84 经纬度 [lng, lat] */
10
+ location: [number, number];
11
+ /** POI 类型:101 POI 数据、102 公交站点 */
12
+ poiType?: number;
13
+ hotPointID?: string;
14
+ province?: string;
15
+ city?: string;
16
+ county?: string;
17
+ typeCode?: string;
18
+ typeName?: string;
19
+ source?: string;
20
+ /** 距中心点距离(仅周边搜索返回,原样字符串,1km 以下为米、以上为千米) */
21
+ distance?: string;
22
+ }
23
+ /** 统计搜索结果(resultType=2)。 */
24
+ export interface Statistics {
25
+ /** 命中 POI 总数 */
26
+ count: number;
27
+ /** 涉及行政区数量 */
28
+ adminCount: number;
29
+ /** 推荐行政区,坐标为 WGS84(天地图 CGCS2000 兼容坐标原样透传) */
30
+ priorityCities: {
31
+ name: string;
32
+ count: number;
33
+ adminCode: string;
34
+ location: [number, number];
35
+ }[];
36
+ }
37
+ /** 行政区搜索结果(resultType=3)。 */
38
+ export interface Area {
39
+ name: string;
40
+ adminCode: string;
41
+ /** 显示级别 1-18 */
42
+ level: number;
43
+ /** 中心点 WGS84 [lng, lat] */
44
+ location: [number, number];
45
+ /** 定位范围 [minx, miny, maxx, maxy],WGS84 */
46
+ bound?: Bounds;
47
+ }
48
+ /** 建议词结果(resultType=4)。 */
49
+ export interface Suggestion {
50
+ /** 提示类型:1 是否在 X 搜 Y、2 在 X 无结果、3 多个可跳转行政区、4 城市 */
51
+ type: number;
52
+ keyword: string;
53
+ admins: {
54
+ adminName: string;
55
+ adminCode: string;
56
+ }[];
57
+ }
58
+ /** 线路结果(resultType=5)。 */
59
+ export interface LineResult {
60
+ name: string;
61
+ uuid: string;
62
+ stationNum?: string;
63
+ }
64
+ /** 单个查询分类的检索结果(category 传多个 dataTypes 时按分类名分组)。 */
65
+ export interface CategoryResult {
66
+ /** 查询分类名(来自 dataTypes 中的某一项,天地图按此分组返回) */
67
+ name: string;
68
+ /** 该分类命中 POI 总数 */
69
+ count: number;
70
+ pois: Poi[];
71
+ }
72
+ /**
73
+ * 地名搜索归一化结果,按 kind 判别对应 resultType;无数据为 empty。
74
+ * category 传多个 dataTypes 时天地图按分类名分组返回,对应 kind: 'categories'。
75
+ */
76
+ export type SearchResult = {
77
+ kind: 'poi';
78
+ count: number;
79
+ pois: Poi[];
80
+ suggestedDistrict?: SuggestedDistrict;
81
+ } | {
82
+ kind: 'categories';
83
+ categories: CategoryResult[];
84
+ } | {
85
+ kind: 'statistics';
86
+ statistics: Statistics;
87
+ } | {
88
+ kind: 'area';
89
+ area: Area;
90
+ } | {
91
+ kind: 'suggestion';
92
+ suggestion: Suggestion;
93
+ } | {
94
+ kind: 'line';
95
+ lines: LineResult[];
96
+ } | {
97
+ kind: 'empty';
98
+ };
99
+ /** 天地图从关键词里识别出的行政区建议(伴随 POI 结果返回,可用于收窄二次检索范围)。 */
100
+ export interface SuggestedDistrict {
101
+ name: string;
102
+ code: string;
103
+ }
104
+ /** 地名搜索公共分页/过滤参数。 */
105
+ interface SearchCommon {
106
+ /**
107
+ * 返回结果起始位(分页)
108
+ * @defaultValue 0
109
+ */
110
+ start?: number;
111
+ /**
112
+ * 返回条数 1-300
113
+ * @defaultValue 10
114
+ */
115
+ count?: number;
116
+ /** POI 分类(分类名或编码,多个用英文逗号分隔) */
117
+ dataTypes?: string;
118
+ /** 返回信息类别:1 基本、2 详细 */
119
+ show?: 1 | 2;
120
+ }
121
+ /**
122
+ * 地名搜索参数,按 type 判别对应天地图 queryType:
123
+ * normal(1) / inView(2) / nearby(3) / polygon(10) / district(12) / category(13) / statistics(14)。
124
+ * 所有坐标入参均为 WGS84。
125
+ */
126
+ export type SearchParams = ({
127
+ type: 'normal';
128
+ keyword: string;
129
+ bounds: Bounds;
130
+ level: number;
131
+ specify?: string;
132
+ } & SearchCommon) | ({
133
+ type: 'inView';
134
+ keyword: string;
135
+ bounds: Bounds;
136
+ level: number;
137
+ } & SearchCommon) | ({
138
+ type: 'nearby';
139
+ keyword: string;
140
+ center: [number, number];
141
+ radius: number;
142
+ } & SearchCommon) | ({
143
+ type: 'polygon';
144
+ keyword: string;
145
+ polygon: [number, number][];
146
+ } & SearchCommon) | ({
147
+ type: 'district';
148
+ specify: string;
149
+ keyword?: string;
150
+ } & SearchCommon) | ({
151
+ type: 'category';
152
+ specify: string;
153
+ bounds: Bounds;
154
+ dataTypes: string;
155
+ } & SearchCommon) | ({
156
+ type: 'statistics';
157
+ specify: string;
158
+ keyword?: string;
159
+ } & SearchCommon);
160
+ /** 正地理编码(地址→坐标)结果;天地图坐标系 CGCS2000 与 WGS84 兼容,坐标原样透传。 */
161
+ export interface GeocodePoint {
162
+ /** WGS84 经纬度 [lng, lat] */
163
+ location: [number, number];
164
+ /** 匹配级别,如「门址」 */
165
+ level?: string;
166
+ /** 匹配得分 0-100 */
167
+ score?: number;
168
+ }
169
+ /** 逆地理编码(坐标→地址)结果。 */
170
+ export interface ReverseGeocodeResult {
171
+ formattedAddress: string;
172
+ province?: string;
173
+ city?: string;
174
+ county?: string;
175
+ road?: string;
176
+ poi?: string;
177
+ }
178
+ /** 地名精确定位(locate)选项。 */
179
+ export interface LocateOptions {
180
+ /**
181
+ * 自定义检索范围(WGS84 [minx, miny, maxx, maxy]);已知大致范围时传入可提升排序精度
182
+ * @defaultValue 全国范围
183
+ */
184
+ bounds?: Bounds;
185
+ /**
186
+ * 查询级别 1-18
187
+ * @defaultValue 10
188
+ */
189
+ level?: number;
190
+ count?: number;
191
+ }
192
+ /** 下级行政区(无边界轮廓)。 */
193
+ export interface AdministrativeChild {
194
+ name: string;
195
+ code: string;
196
+ /** 行政区划级别:国家 5、省 4、市 3、区县 2 */
197
+ level: number;
198
+ /** 中心点 WGS84 [lng, lat] */
199
+ center: [number, number];
200
+ }
201
+ /** 行政区划查询结果。 */
202
+ export interface AdministrativeDivision extends AdministrativeChild {
203
+ /** 行政区边界;仅在 boundary 且天地图返回轮廓时存在,坐标为 WGS84(原样透传) */
204
+ boundary?: MultiPolygon;
205
+ children?: AdministrativeChild[];
206
+ }
207
+ /** 行政区划查询选项。 */
208
+ export interface AdministrativeOptions {
209
+ /**
210
+ * 下级行政区级数:0 不返回、1 下一级、2 下两级、3 下三级
211
+ * @defaultValue 0
212
+ */
213
+ childLevel?: 0 | 1 | 2 | 3;
214
+ /**
215
+ * 是否返回边界轮廓
216
+ * @defaultValue true
217
+ */
218
+ boundary?: boolean;
219
+ }
220
+ /** 驾车/步行路线模式,映射天地图 style:最快 0、最短 1、避开高速 2、步行 3。 */
221
+ export type RouteMode = 'fastest' | 'shortest' | 'avoid-highway' | 'walking';
222
+ /** 路线规划选项。 */
223
+ export interface RouteOptions {
224
+ /**
225
+ * 路线模式
226
+ * @defaultValue 'fastest'
227
+ */
228
+ mode?: RouteMode;
229
+ /** 途经点(WGS84),按顺序途经 */
230
+ waypoints?: [number, number][];
231
+ }
232
+ /** 路线规划结果。 */
233
+ export interface RouteResult {
234
+ /** 总距离(公里) */
235
+ distanceKm: number;
236
+ /** 总时长(分钟) */
237
+ durationMinutes: number;
238
+ /** 整条路线折线(WGS84) */
239
+ path: LineString;
240
+ /** 逐段转向文字摘要 */
241
+ summary?: string;
242
+ /** 适宜展示整条路线的中心点(WGS84) */
243
+ center?: [number, number];
244
+ /** 适宜缩放级别 */
245
+ scale?: number;
246
+ }
247
+ export {};
File without changes
@@ -0,0 +1,13 @@
1
+ export interface DecodedAnimation {
2
+ /** 逐帧 ImageData(均缩放到 size×size) */
3
+ frames: ImageData[];
4
+ /** 每帧时长 ms,与 frames 一一对应 */
5
+ durations: number[];
6
+ /** 纹理边长 */
7
+ size: number;
8
+ }
9
+ /**
10
+ * 用浏览器原生 ImageDecoder(WebCodecs)逐帧解码动图(GIF/APNG/WebP/AVIF)为 ImageData。
11
+ * 帧统一缩放到 size×size。无 ImageDecoder/canvas 环境(旧浏览器/SSR/测试)返回空,由组件降级。
12
+ */
13
+ export declare function decodeAnimatedImage(url: string, size: number): Promise<DecodedAnimation>;
@@ -0,0 +1,47 @@
1
+ const EMPTY = { frames: [], durations: [], size: 0 };
2
+ function inferType(url) {
3
+ const ext = url.split("?")[0].split(".").pop()?.toLowerCase();
4
+ switch (ext) {
5
+ case "gif":
6
+ return "image/gif";
7
+ case "apng":
8
+ case "png":
9
+ return "image/png";
10
+ case "webp":
11
+ return "image/webp";
12
+ case "avif":
13
+ return "image/avif";
14
+ default:
15
+ return "image/png";
16
+ }
17
+ }
18
+ export async function decodeAnimatedImage(url, size) {
19
+ if (typeof ImageDecoder === "undefined" || typeof document === "undefined") return EMPTY;
20
+ try {
21
+ const res = await fetch(url);
22
+ const data = await res.arrayBuffer();
23
+ const type = res.headers.get("content-type") || inferType(url);
24
+ const decoder = new ImageDecoder({ data, type });
25
+ await decoder.tracks.ready;
26
+ const frameCount = decoder.tracks.selectedTrack?.frameCount ?? 1;
27
+ const canvas = document.createElement("canvas");
28
+ canvas.width = size;
29
+ canvas.height = size;
30
+ const context = canvas.getContext("2d", { willReadFrequently: true });
31
+ if (!context) return EMPTY;
32
+ const frames = [];
33
+ const durations = [];
34
+ for (let i = 0; i < frameCount; i++) {
35
+ const { image } = await decoder.decode({ frameIndex: i });
36
+ context.clearRect(0, 0, size, size);
37
+ context.drawImage(image, 0, 0, size, size);
38
+ frames.push(context.getImageData(0, 0, size, size));
39
+ durations.push((image.duration ?? 0) / 1e3);
40
+ image.close();
41
+ }
42
+ decoder.close();
43
+ return { frames, durations, size };
44
+ } catch {
45
+ return EMPTY;
46
+ }
47
+ }
@@ -0,0 +1,24 @@
1
+ type PropBag = Record<string, unknown>;
2
+ export interface BufferPaintOptions {
3
+ /**
4
+ * 主色
5
+ * @defaultValue '#3b82f6'
6
+ */
7
+ color?: string;
8
+ /**
9
+ * 填充不透明度
10
+ * @defaultValue 0.25
11
+ */
12
+ fillOpacity?: number;
13
+ /**
14
+ * 描边宽度
15
+ * @defaultValue 2
16
+ */
17
+ lineWidth?: number;
18
+ }
19
+ /** 缓冲区默认 fill/line paint;组件可经 fillPaint/linePaint 整体覆盖。 */
20
+ export declare function bufferPaints(options?: BufferPaintOptions): {
21
+ fill: PropBag;
22
+ line: PropBag;
23
+ };
24
+ export {};
@@ -0,0 +1,13 @@
1
+ export function bufferPaints(options = {}) {
2
+ const color = options.color ?? "#3b82f6";
3
+ return {
4
+ fill: {
5
+ "fill-color": color,
6
+ "fill-opacity": options.fillOpacity ?? 0.25
7
+ },
8
+ line: {
9
+ "line-color": color,
10
+ "line-width": options.lineWidth ?? 2
11
+ }
12
+ };
13
+ }
@@ -0,0 +1,73 @@
1
+ type PropBag = Record<string, unknown>;
2
+ export interface BuildingGradientOptions {
3
+ /** 高度-颜色断点;缺省为低矮到高耸的蓝紫渐变 */
4
+ stops?: [number, string][];
5
+ /**
6
+ * 整体透明度
7
+ * @defaultValue 0.85
8
+ */
9
+ opacity?: number;
10
+ /**
11
+ * 显示建筑的最小缩放级别
12
+ * @defaultValue 15
13
+ */
14
+ minzoom?: number;
15
+ /**
16
+ * 建筑高度属性名
17
+ * @defaultValue 'render_height'
18
+ */
19
+ heightProperty?: string;
20
+ /**
21
+ * 建筑底面高度属性名
22
+ * @defaultValue 'render_min_height'
23
+ */
24
+ baseProperty?: string;
25
+ }
26
+ /**
27
+ * 按建筑高度插值着色的 fill-extrusion paint。
28
+ * 复用 building.ts 的 minzoom 高度起伏约定,避免建筑瞬间弹出。
29
+ */
30
+ export declare function buildingGradientPaint(options?: BuildingGradientOptions): PropBag;
31
+ export interface WindowTextureOptions {
32
+ /**
33
+ * 贴图边长(像素)
34
+ * @defaultValue 128
35
+ */
36
+ size?: number;
37
+ /**
38
+ * 窗户行数
39
+ * @defaultValue 8
40
+ */
41
+ rows?: number;
42
+ /**
43
+ * 窗户列数
44
+ * @defaultValue 6
45
+ */
46
+ cols?: number;
47
+ /**
48
+ * 亮窗颜色
49
+ * @defaultValue '#fde68a'
50
+ */
51
+ litColor?: string;
52
+ /**
53
+ * 暗窗/墙体颜色
54
+ * @defaultValue '#1f2937'
55
+ */
56
+ darkColor?: string;
57
+ /**
58
+ * 亮窗比例 0-1
59
+ * @defaultValue 0.45
60
+ */
61
+ litRatio?: number;
62
+ /**
63
+ * 随机种子(决定亮窗分布,保证可复现)
64
+ * @defaultValue 1
65
+ */
66
+ seed?: number;
67
+ }
68
+ /**
69
+ * 程序生成窗户点阵贴图,用于 fill-extrusion-pattern。
70
+ * LCG 伪随机由 seed 决定亮窗分布,保证可测;无 canvas 环境返回 undefined。
71
+ */
72
+ export declare function windowTextureImage(options?: WindowTextureOptions): ImageData | undefined;
73
+ export {};
@@ -0,0 +1,50 @@
1
+ import { buildingExtrusionPaint, DEFAULT_HEIGHT_PROPERTY } from "./building.js";
2
+ const DEFAULT_STOPS = [
3
+ [0, "#1e3a8a"],
4
+ [50, "#3b82f6"],
5
+ [150, "#22d3ee"],
6
+ [300, "#a78bfa"]
7
+ ];
8
+ export function buildingGradientPaint(options = {}) {
9
+ const stops = options.stops ?? DEFAULT_STOPS;
10
+ const heightProperty = options.heightProperty ?? DEFAULT_HEIGHT_PROPERTY;
11
+ const colorExpr = ["interpolate", ["linear"], ["get", heightProperty]];
12
+ for (const [height, color] of stops) colorExpr.push(height, color);
13
+ return {
14
+ "fill-extrusion-color": colorExpr,
15
+ ...buildingExtrusionPaint({ minzoom: options.minzoom, heightProperty, baseProperty: options.baseProperty }),
16
+ "fill-extrusion-opacity": options.opacity ?? 0.85
17
+ };
18
+ }
19
+ export function windowTextureImage(options = {}) {
20
+ if (typeof document === "undefined") return void 0;
21
+ const size = options.size ?? 128;
22
+ const rows = options.rows ?? 8;
23
+ const cols = options.cols ?? 6;
24
+ const litColor = options.litColor ?? "#fde68a";
25
+ const darkColor = options.darkColor ?? "#1f2937";
26
+ const litRatio = options.litRatio ?? 0.45;
27
+ const canvas = document.createElement("canvas");
28
+ canvas.width = size;
29
+ canvas.height = size;
30
+ const context = canvas.getContext("2d", { willReadFrequently: true });
31
+ if (!context) return void 0;
32
+ context.fillStyle = darkColor;
33
+ context.fillRect(0, 0, size, size);
34
+ let seed = (options.seed ?? 1) >>> 0;
35
+ const rand = () => {
36
+ seed = seed * 1664525 + 1013904223 >>> 0;
37
+ return seed / 4294967295;
38
+ };
39
+ const cellW = size / cols;
40
+ const cellH = size / rows;
41
+ const padX = cellW * 0.2;
42
+ const padY = cellH * 0.2;
43
+ for (let r = 0; r < rows; r++) {
44
+ for (let c = 0; c < cols; c++) {
45
+ context.fillStyle = rand() < litRatio ? litColor : darkColor;
46
+ context.fillRect(c * cellW + padX, r * cellH + padY, cellW - padX * 2, cellH - padY * 2);
47
+ }
48
+ }
49
+ return context.getImageData(0, 0, size, size);
50
+ }
@@ -0,0 +1,53 @@
1
+ import type { FillExtrusionLayerSpecification } from '@maplibre/maplibre-gl-style-spec';
2
+ type PropBag = Record<string, unknown>;
3
+ /** 建筑数据来源:矢量瓦片或 GeoJSON 中带高度属性的面要素 */
4
+ export interface BuildingSourceOptions {
5
+ /** 数据源 id(需已由 MaplibreSource 或样式声明) */
6
+ source: string;
7
+ /** 矢量瓦片中的图层名(如 OpenMapTiles 的 'building');GeoJSON 源省略 */
8
+ sourceLayer?: string;
9
+ /**
10
+ * 建筑高度属性名
11
+ * @defaultValue 'render_height'
12
+ */
13
+ heightProperty?: string;
14
+ /**
15
+ * 建筑底面高度属性名
16
+ * @defaultValue 'render_min_height'
17
+ */
18
+ baseProperty?: string;
19
+ }
20
+ export interface BuildingLayerOptions extends BuildingSourceOptions {
21
+ /** 图层 id */
22
+ id: string;
23
+ /**
24
+ * 建筑颜色
25
+ * @defaultValue '#aaa'
26
+ */
27
+ color?: string;
28
+ /**
29
+ * 整体透明度
30
+ * @defaultValue 0.8
31
+ */
32
+ opacity?: number;
33
+ /**
34
+ * 显示建筑的最小缩放级别
35
+ * @defaultValue 15
36
+ */
37
+ minzoom?: number;
38
+ /** 整体覆盖 paint(提供时忽略 color/opacity 预设) */
39
+ paint?: PropBag;
40
+ }
41
+ export declare const DEFAULT_HEIGHT_PROPERTY = "render_height";
42
+ export declare const DEFAULT_BASE_PROPERTY = "render_min_height";
43
+ /**
44
+ * 建筑拉伸的高度与底面 paint:进入 minzoom 后 0.05 级内由 0 插值到真实高度,避免建筑瞬间弹出。
45
+ */
46
+ export declare function buildingExtrusionPaint(options?: {
47
+ minzoom?: number;
48
+ heightProperty?: string;
49
+ baseProperty?: string;
50
+ }): PropBag;
51
+ /** 生成 3D 建筑 fill-extrusion 图层规格。 */
52
+ export declare function buildingLayerSpec(options: BuildingLayerOptions): FillExtrusionLayerSpecification;
53
+ export {};
@@ -0,0 +1,26 @@
1
+ export const DEFAULT_HEIGHT_PROPERTY = "render_height";
2
+ export const DEFAULT_BASE_PROPERTY = "render_min_height";
3
+ export function buildingExtrusionPaint(options = {}) {
4
+ const minzoom = options.minzoom ?? 15;
5
+ const rise = (property) => ["interpolate", ["linear"], ["zoom"], minzoom, 0, minzoom + 0.05, ["get", property]];
6
+ return {
7
+ "fill-extrusion-height": rise(options.heightProperty ?? DEFAULT_HEIGHT_PROPERTY),
8
+ "fill-extrusion-base": rise(options.baseProperty ?? DEFAULT_BASE_PROPERTY)
9
+ };
10
+ }
11
+ export function buildingLayerSpec(options) {
12
+ const minzoom = options.minzoom ?? 15;
13
+ const defaultPaint = {
14
+ "fill-extrusion-color": options.color ?? "#aaa",
15
+ ...buildingExtrusionPaint({ minzoom, heightProperty: options.heightProperty, baseProperty: options.baseProperty }),
16
+ "fill-extrusion-opacity": options.opacity ?? 0.8
17
+ };
18
+ return {
19
+ id: options.id,
20
+ type: "fill-extrusion",
21
+ source: options.source,
22
+ ...options.sourceLayer ? { "source-layer": options.sourceLayer } : {},
23
+ minzoom,
24
+ paint: options.paint ?? defaultPaint
25
+ };
26
+ }
@@ -0,0 +1,24 @@
1
+ import type { CircleLayerSpecification, SymbolLayerSpecification } from '@maplibre/maplibre-gl-style-spec';
2
+ type PropBag = Record<string, unknown>;
3
+ export interface ClusterLayersOptions {
4
+ /** 图层 id 前缀,生成 {id}-clusters / {id}-count / {id}-points */
5
+ id: string;
6
+ /** 聚合 geojson 数据源 id */
7
+ sourceId: string;
8
+ /** 覆盖聚合圆 paint */
9
+ clusterPaint?: PropBag;
10
+ /** 覆盖计数文字 layout */
11
+ countLayout?: PropBag;
12
+ /** 覆盖计数文字 paint */
13
+ countPaint?: PropBag;
14
+ /** 覆盖散点 paint */
15
+ pointPaint?: PropBag;
16
+ }
17
+ export interface ClusterLayerSpecs {
18
+ clusters: CircleLayerSpecification;
19
+ count: SymbolLayerSpecification;
20
+ points: CircleLayerSpecification;
21
+ }
22
+ /** 生成聚合三层(分级聚合圆 / 数量标注 / 未聚合散点)图层规格。 */
23
+ export declare function clusterLayerSpecs(options: ClusterLayersOptions): ClusterLayerSpecs;
24
+ export {};