@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,42 @@
1
+ import { textFontLayout } from "../domains/map/config.js";
2
+ export function clusterLayerSpecs(options) {
3
+ const { id, sourceId } = options;
4
+ const clusters = {
5
+ id: `${id}-clusters`,
6
+ type: "circle",
7
+ source: sourceId,
8
+ filter: ["has", "point_count"],
9
+ paint: options.clusterPaint ?? {
10
+ // 按聚合数量分级配色与半径:<100 / <750 / >=750
11
+ "circle-color": ["step", ["get", "point_count"], "#51bbd6", 100, "#f1f075", 750, "#f28cb1"],
12
+ "circle-radius": ["step", ["get", "point_count"], 20, 100, 30, 750, 40]
13
+ }
14
+ };
15
+ const count = {
16
+ id: `${id}-count`,
17
+ type: "symbol",
18
+ source: sourceId,
19
+ filter: ["has", "point_count"],
20
+ layout: options.countLayout ?? {
21
+ "text-field": ["get", "point_count_abbreviated"],
22
+ "text-size": 12,
23
+ ...textFontLayout()
24
+ },
25
+ paint: options.countPaint ?? {
26
+ "text-color": "#fff"
27
+ }
28
+ };
29
+ const points = {
30
+ id: `${id}-points`,
31
+ type: "circle",
32
+ source: sourceId,
33
+ filter: ["!", ["has", "point_count"]],
34
+ paint: options.pointPaint ?? {
35
+ "circle-color": "#11b4da",
36
+ "circle-radius": 6,
37
+ "circle-stroke-width": 1.5,
38
+ "circle-stroke-color": "#fff"
39
+ }
40
+ };
41
+ return { clusters, count, points };
42
+ }
@@ -0,0 +1,12 @@
1
+ /** 常用坐标系标识,对齐 gcoord 的 CRS 常量 */
2
+ export type CRS = 'WGS84' | 'GCJ02' | 'BD09' | 'EPSG3857';
3
+ export interface TransformOptions {
4
+ /**
5
+ * 输出坐标保留的小数位数,省略则保留完整精度
6
+ */
7
+ precision?: number;
8
+ }
9
+ /** 转换单个经纬度点,返回新坐标。 */
10
+ export declare function transformPoint(point: [number, number], from: CRS, to: CRS, options?: TransformOptions): [number, number];
11
+ /** 转换任意 GeoJSON(点/线/面/集合),返回新对象,不修改入参。 */
12
+ export declare function transformGeoJSON<T>(geojson: T, from: CRS, to: CRS, options?: TransformOptions): T;
@@ -0,0 +1,44 @@
1
+ import gcoord from "gcoord";
2
+ const CRS_MAP = {
3
+ WGS84: gcoord.WGS84,
4
+ GCJ02: gcoord.GCJ02,
5
+ BD09: gcoord.BD09,
6
+ EPSG3857: gcoord.EPSG3857
7
+ };
8
+ function roundNum(n, precision) {
9
+ const factor = 10 ** precision;
10
+ return Math.round(n * factor) / factor;
11
+ }
12
+ function roundCoords(coords, precision) {
13
+ if (!Array.isArray(coords)) return;
14
+ if (typeof coords[0] === "number") {
15
+ for (let i = 0; i < coords.length; i++) {
16
+ coords[i] = roundNum(coords[i], precision);
17
+ }
18
+ return;
19
+ }
20
+ for (const child of coords) roundCoords(child, precision);
21
+ }
22
+ function roundGeoJSON(node, precision) {
23
+ if (!node || typeof node !== "object") return;
24
+ const obj = node;
25
+ if (Array.isArray(obj.features)) {
26
+ for (const feature of obj.features) roundGeoJSON(feature, precision);
27
+ }
28
+ if (obj.geometry) roundGeoJSON(obj.geometry, precision);
29
+ if (Array.isArray(obj.geometries)) {
30
+ for (const geometry of obj.geometries) roundGeoJSON(geometry, precision);
31
+ }
32
+ if (obj.coordinates) roundCoords(obj.coordinates, precision);
33
+ }
34
+ export function transformPoint(point, from, to, options = {}) {
35
+ const result = gcoord.transform(point, CRS_MAP[from], CRS_MAP[to]);
36
+ if (options.precision === void 0) return result;
37
+ return [roundNum(result[0], options.precision), roundNum(result[1], options.precision)];
38
+ }
39
+ export function transformGeoJSON(geojson, from, to, options = {}) {
40
+ const input = structuredClone(geojson);
41
+ const result = gcoord.transform(input, CRS_MAP[from], CRS_MAP[to]);
42
+ if (options.precision !== void 0) roundGeoJSON(result, options.precision);
43
+ return result;
44
+ }
@@ -0,0 +1,47 @@
1
+ import type { GeoJSONStoreFeatures, HexColor } from 'terra-draw';
2
+ export interface DrawThemeOptions {
3
+ /**
4
+ * 非激活态主色
5
+ * @defaultValue '#3b82f6'
6
+ */
7
+ color?: HexColor;
8
+ /**
9
+ * 激活态(绘制辅助点/选中)主色
10
+ * @defaultValue '#f59e0b'
11
+ */
12
+ activeColor?: HexColor;
13
+ /**
14
+ * 多边形填充不透明度
15
+ * @defaultValue 0.1
16
+ */
17
+ fillOpacity?: number;
18
+ /**
19
+ * 线宽
20
+ * @defaultValue 2
21
+ */
22
+ lineWidth?: number;
23
+ /**
24
+ * 顶点圆半径
25
+ * @defaultValue 5
26
+ */
27
+ vertexRadius?: number;
28
+ }
29
+ type ColorStyle = (feature: GeoJSONStoreFeatures) => HexColor;
30
+ type ModeStyles = Record<string, number | HexColor | ColorStyle>;
31
+ /** 各模式的 terra-draw styles,键为模式名 */
32
+ export interface DrawThemeStyles {
33
+ select: Record<string, number | HexColor>;
34
+ point: ModeStyles;
35
+ linestring: ModeStyles;
36
+ polygon: ModeStyles;
37
+ rectangle: ModeStyles;
38
+ circle: ModeStyles;
39
+ ellipse: ModeStyles;
40
+ sector: ModeStyles;
41
+ }
42
+ /**
43
+ * 生成 terra-draw 各模式的主题样式。
44
+ * 要素 `properties.color` 优先于主题色,便于按要素单独着色(配合 setFeatureProperty)。
45
+ */
46
+ export declare function drawThemeStyles(options?: DrawThemeOptions): DrawThemeStyles;
47
+ export {};
@@ -0,0 +1,39 @@
1
+ export function drawThemeStyles(options = {}) {
2
+ const color = options.color ?? "#3b82f6";
3
+ const activeColor = options.activeColor ?? "#f59e0b";
4
+ const fillOpacity = options.fillOpacity ?? 0.1;
5
+ const lineWidth = options.lineWidth ?? 2;
6
+ const vertexRadius = options.vertexRadius ?? 5;
7
+ const themed = (feature) => feature.properties?.color ?? color;
8
+ const shape = { fillColor: themed, fillOpacity, outlineColor: themed, outlineWidth: lineWidth };
9
+ const guidance = (prefix) => ({
10
+ [`${prefix}Color`]: activeColor,
11
+ [`${prefix}Width`]: vertexRadius,
12
+ [`${prefix}OutlineColor`]: "#ffffff",
13
+ [`${prefix}OutlineWidth`]: 2
14
+ });
15
+ return {
16
+ select: {
17
+ selectedPointColor: activeColor,
18
+ selectedPointWidth: vertexRadius + 1,
19
+ selectedLineStringColor: activeColor,
20
+ selectedLineStringWidth: lineWidth,
21
+ selectedPolygonColor: activeColor,
22
+ selectedPolygonFillOpacity: fillOpacity,
23
+ selectedPolygonOutlineColor: activeColor,
24
+ selectedPolygonOutlineWidth: lineWidth,
25
+ ...guidance("selectionPoint"),
26
+ midPointColor: activeColor,
27
+ midPointWidth: Math.max(vertexRadius - 2, 1),
28
+ midPointOutlineColor: "#ffffff",
29
+ midPointOutlineWidth: 1
30
+ },
31
+ point: { pointColor: themed, pointWidth: vertexRadius, pointOutlineColor: "#ffffff", pointOutlineWidth: 2 },
32
+ linestring: { lineStringColor: themed, lineStringWidth: lineWidth, ...guidance("closingPoint"), ...guidance("coordinatePoint") },
33
+ polygon: { ...shape, ...guidance("closingPoint"), ...guidance("coordinatePoint") },
34
+ rectangle: shape,
35
+ circle: shape,
36
+ ellipse: shape,
37
+ sector: shape
38
+ };
39
+ }
@@ -0,0 +1,34 @@
1
+ export type Position2D = [number, number];
2
+ export interface ArcLineOptions {
3
+ /**
4
+ * 弧线弯曲程度(相对两点距离的比例)
5
+ * @defaultValue 0.3
6
+ */
7
+ curvature?: number;
8
+ /**
9
+ * 采样段数
10
+ * @defaultValue 64
11
+ */
12
+ segments?: number;
13
+ }
14
+ /** 二次贝塞尔弧线:控制点取中点沿垂直方向偏移 curvature × 距离。 */
15
+ export declare function arcLine(from: Position2D, to: Position2D, options?: ArcLineOptions): Position2D[];
16
+ /**
17
+ * 预计算累计长度的沿线采样器:t ∈ [0,1](按长度占比)→ 坐标。
18
+ * 供迁徙粒子/轨迹每帧取位,避免逐帧重算长度表。
19
+ */
20
+ export declare function createLineSampler(coords: Position2D[]): (t: number) => Position2D;
21
+ /** 第 ring 圈在当前时刻的扩散相位 [0,1):线性推进 + 按圈序均匀错相。 */
22
+ export declare function ringProgress(ring: number, rings: number, elapsedMs: number, durationMs: number): number;
23
+ /** 扩散圈不透明度包络:两端为 0(保证取模回绕处无缝),中点峰值 1。 */
24
+ export declare function ringFade(progress: number): number;
25
+ /**
26
+ * 轨迹彗尾的 line-gradient 表达式:head 为头部 line-progress,
27
+ * 尾部到头部由透明渐变到主色,头部之后立即透明。停靠点保证严格递增。
28
+ */
29
+ export declare function trailGradient(head: number, trailLength: number, color: string): unknown[];
30
+ /**
31
+ * 生成雷达扇形扫描贴图(透明到主色的角向渐变)。
32
+ * 无 canvas 2d 环境(SSR/测试)时返回 undefined。
33
+ */
34
+ export declare function radarSweepImage(size: number, color: string): ImageData | undefined;
@@ -0,0 +1,78 @@
1
+ export function arcLine(from, to, options = {}) {
2
+ const curvature = options.curvature ?? 0.3;
3
+ const segments = options.segments ?? 64;
4
+ const dx = to[0] - from[0];
5
+ const dy = to[1] - from[1];
6
+ const mid = [from[0] + dx / 2, from[1] + dy / 2];
7
+ const control = [mid[0] - dy * curvature, mid[1] + dx * curvature];
8
+ const coords = [];
9
+ for (let i = 0; i <= segments; i++) {
10
+ const t = i / segments;
11
+ const a = 1 - t;
12
+ coords.push([
13
+ a * a * from[0] + 2 * a * t * control[0] + t * t * to[0],
14
+ a * a * from[1] + 2 * a * t * control[1] + t * t * to[1]
15
+ ]);
16
+ }
17
+ coords[0] = [...from];
18
+ coords[segments] = [...to];
19
+ return coords;
20
+ }
21
+ export function createLineSampler(coords) {
22
+ const cumulative = [0];
23
+ for (let i = 1; i < coords.length; i++) {
24
+ const dx = coords[i][0] - coords[i - 1][0];
25
+ const dy = coords[i][1] - coords[i - 1][1];
26
+ cumulative.push(cumulative[i - 1] + Math.hypot(dx, dy));
27
+ }
28
+ const total = cumulative[cumulative.length - 1];
29
+ return (t) => {
30
+ if (t <= 0 || total === 0) return [...coords[0]];
31
+ if (t >= 1) return [...coords[coords.length - 1]];
32
+ const target = t * total;
33
+ let i = 1;
34
+ while (cumulative[i] < target) i++;
35
+ const segStart = cumulative[i - 1];
36
+ const ratio = (target - segStart) / (cumulative[i] - segStart);
37
+ const a = coords[i - 1];
38
+ const b = coords[i];
39
+ return [a[0] + (b[0] - a[0]) * ratio, a[1] + (b[1] - a[1]) * ratio];
40
+ };
41
+ }
42
+ export function ringProgress(ring, rings, elapsedMs, durationMs) {
43
+ return (elapsedMs / durationMs + ring / rings) % 1;
44
+ }
45
+ export function ringFade(progress) {
46
+ return Math.sin(progress * Math.PI);
47
+ }
48
+ export function trailGradient(head, trailLength, color) {
49
+ const eps = 1e-4;
50
+ const transparent = "rgba(0, 0, 0, 0)";
51
+ const h = Math.min(Math.max(head, eps), 1);
52
+ const tail = Math.max(h - Math.max(trailLength, eps), 0);
53
+ const expr = ["interpolate", ["linear"], ["line-progress"], tail, transparent, h, color];
54
+ if (h + eps < 1) expr.push(h + eps, transparent);
55
+ return expr;
56
+ }
57
+ export function radarSweepImage(size, color) {
58
+ if (typeof document === "undefined") return void 0;
59
+ const canvas = document.createElement("canvas");
60
+ canvas.width = size;
61
+ canvas.height = size;
62
+ const context = canvas.getContext("2d", { willReadFrequently: true });
63
+ if (!context) return void 0;
64
+ const half = size / 2;
65
+ const steps = 120;
66
+ const sweep = Math.PI * 1.5;
67
+ for (let i = 0; i < steps; i++) {
68
+ const angle = i / steps * sweep;
69
+ context.beginPath();
70
+ context.moveTo(half, half);
71
+ context.arc(half, half, half, angle, angle + sweep / steps + 0.01);
72
+ context.closePath();
73
+ context.globalAlpha = i / steps * 0.85;
74
+ context.fillStyle = color;
75
+ context.fill();
76
+ }
77
+ return context.getImageData(0, 0, size, size);
78
+ }
@@ -0,0 +1,6 @@
1
+ import type { Map as MaplibreMap } from 'maplibre-gl';
2
+ /**
3
+ * 表驱动地绑定地图事件并转发,返回解绑函数。
4
+ * 传入 layerId 时绑定到指定图层(用于图层级交互事件)。
5
+ */
6
+ export declare function bindMapEvents<E extends string>(map: MaplibreMap, events: readonly E[], handler: (type: E, event: unknown) => void, layerId?: string): () => void;
@@ -0,0 +1,20 @@
1
+ export function bindMapEvents(map, events, handler, layerId) {
2
+ const bound = events.map((type) => {
3
+ const listener = (event) => handler(type, event);
4
+ if (layerId) {
5
+ map.on(type, layerId, listener);
6
+ } else {
7
+ map.on(type, listener);
8
+ }
9
+ return { type, listener };
10
+ });
11
+ return () => {
12
+ for (const { type, listener } of bound) {
13
+ if (layerId) {
14
+ map.off(type, layerId, listener);
15
+ } else {
16
+ map.off(type, listener);
17
+ }
18
+ }
19
+ };
20
+ }
@@ -0,0 +1,27 @@
1
+ import type { Map as MaplibreMap, StyleImageInterface } from 'maplibre-gl';
2
+ /**
3
+ * 按经过时间选当前帧索引。
4
+ * 有 durations(每帧 ms,长度=total)按累积时长循环选帧;否则按固定 fps。
5
+ */
6
+ export declare function pickFrameIndex(elapsedMs: number, durations: number[] | undefined, fps: number, total: number): number;
7
+ export interface FrameStyleImageOptions {
8
+ /** 纹理边长(像素),帧统一缩放到 size×size */
9
+ size: number;
10
+ /** 当前帧序列(响应式取值) */
11
+ frames: () => ImageData[];
12
+ /** 取地图实例以触发重绘 */
13
+ getMap: () => MaplibreMap | undefined;
14
+ /**
15
+ * 固定帧率;durations 缺省时生效
16
+ * @defaultValue 12
17
+ */
18
+ fps?: number;
19
+ /** 每帧时长 ms(响应式取值),优先于 fps */
20
+ durations?: () => number[] | undefined;
21
+ }
22
+ /**
23
+ * 构造帧动画 StyleImageInterface:maplibre 每帧调 render 取当前帧并自重绘。
24
+ * 帧未就绪时首次返回 true 以初始透明 data 建立纹理(maplibre 仅在 render 首次返回 true 时建纹理),
25
+ * 避免 symbol 图层 styleimagemissing。
26
+ */
27
+ export declare function createFrameStyleImage(options: FrameStyleImageOptions): StyleImageInterface;
@@ -0,0 +1,45 @@
1
+ export function pickFrameIndex(elapsedMs, durations, fps, total) {
2
+ if (total <= 0) return 0;
3
+ if (durations && durations.length === total) {
4
+ const cycle = durations.reduce((sum, d) => sum + d, 0);
5
+ if (cycle <= 0) return 0;
6
+ let t = elapsedMs % cycle;
7
+ for (let i = 0; i < total; i++) {
8
+ if (t < durations[i]) return i;
9
+ t -= durations[i];
10
+ }
11
+ return total - 1;
12
+ }
13
+ return Math.floor(elapsedMs / 1e3 * fps) % total;
14
+ }
15
+ export function createFrameStyleImage(options) {
16
+ const { size, frames, getMap } = options;
17
+ const fps = options.fps ?? 12;
18
+ let start = 0;
19
+ let lastIndex = -1;
20
+ let committed = false;
21
+ const image = {
22
+ width: size,
23
+ height: size,
24
+ data: new Uint8Array(size * size * 4),
25
+ render() {
26
+ const fs = frames();
27
+ const total = fs.length;
28
+ if (!total) {
29
+ if (committed) return false;
30
+ committed = true;
31
+ return true;
32
+ }
33
+ const map = getMap();
34
+ if (map) map.triggerRepaint();
35
+ committed = true;
36
+ if (!start) start = performance.now();
37
+ const index = pickFrameIndex(performance.now() - start, options.durations?.(), fps, total);
38
+ if (index === lastIndex) return false;
39
+ lastIndex = index;
40
+ image.data = fs[index].data;
41
+ return true;
42
+ }
43
+ };
44
+ return image;
45
+ }
@@ -0,0 +1,5 @@
1
+ import type { GeoJSON } from 'geojson';
2
+ /** 西南/东北角包围盒,可直接传给 map.fitBounds */
3
+ export type LngLatBoundsTuple = [[number, number], [number, number]];
4
+ /** 扫描任意 GeoJSON 的全部坐标求包围盒;无坐标时返回 undefined。 */
5
+ export declare function boundsOfGeoJSON(input: GeoJSON): LngLatBoundsTuple | undefined;
@@ -0,0 +1,41 @@
1
+ export function boundsOfGeoJSON(input) {
2
+ let west = Infinity;
3
+ let south = Infinity;
4
+ let east = -Infinity;
5
+ let north = -Infinity;
6
+ let found = false;
7
+ function visitPosition(position) {
8
+ const [lng, lat] = position;
9
+ if (typeof lng !== "number" || typeof lat !== "number") return;
10
+ found = true;
11
+ if (lng < west) west = lng;
12
+ if (lng > east) east = lng;
13
+ if (lat < south) south = lat;
14
+ if (lat > north) north = lat;
15
+ }
16
+ function visitCoordinates(coordinates) {
17
+ if (coordinates.length === 0) return;
18
+ if (typeof coordinates[0] === "number") {
19
+ visitPosition(coordinates);
20
+ return;
21
+ }
22
+ for (const child of coordinates) visitCoordinates(child);
23
+ }
24
+ function visitGeometry(geometry) {
25
+ if (geometry.type === "GeometryCollection") {
26
+ for (const child of geometry.geometries) visitGeometry(child);
27
+ return;
28
+ }
29
+ visitCoordinates(geometry.coordinates);
30
+ }
31
+ if (input.type === "FeatureCollection") {
32
+ for (const feature of input.features) {
33
+ if (feature.geometry) visitGeometry(feature.geometry);
34
+ }
35
+ } else if (input.type === "Feature") {
36
+ if (input.geometry) visitGeometry(input.geometry);
37
+ } else {
38
+ visitGeometry(input);
39
+ }
40
+ return found ? [[west, south], [east, north]] : void 0;
41
+ }
@@ -0,0 +1,36 @@
1
+ type PropBag = Record<string, unknown>;
2
+ export interface HeatmapPaintOptions {
3
+ /**
4
+ * 权重取值的要素属性
5
+ * @defaultValue 'temperature'
6
+ */
7
+ weightProperty?: string;
8
+ /**
9
+ * 权重属性取值范围 [min, max],线性映射到 0..1 热力权重
10
+ * @defaultValue `[0, 40]`
11
+ */
12
+ weightRange?: [number, number];
13
+ /** 密度-颜色断点 [密度比 0..1, 颜色][];缺省为蓝→红五档;density 0 处自动透明 */
14
+ colorStops?: [number, string][];
15
+ /**
16
+ * 热力半径(像素)
17
+ * @defaultValue 30
18
+ */
19
+ radius?: number;
20
+ /**
21
+ * 热力强度
22
+ * @defaultValue 1
23
+ */
24
+ intensity?: number;
25
+ /**
26
+ * 整体不透明度
27
+ * @defaultValue 1
28
+ */
29
+ opacity?: number;
30
+ }
31
+ /**
32
+ * 生成 maplibre heatmap 图层 paint:温度属性经 weightRange 线性映射为热力权重,
33
+ * heatmap-density 经 colorStops 着色(0 处必透明,否则全图铺底色)。
34
+ */
35
+ export declare function heatmapPaint(options?: HeatmapPaintOptions): PropBag;
36
+ export {};
@@ -0,0 +1,30 @@
1
+ const DEFAULT_COLOR_STOPS = [
2
+ [0.2, "#2c7bb6"],
3
+ [0.4, "#00a6ca"],
4
+ [0.6, "#7fbc41"],
5
+ [0.8, "#fdae61"],
6
+ [1, "#d7191c"]
7
+ ];
8
+ export function heatmapPaint(options = {}) {
9
+ const weightProperty = options.weightProperty ?? "temperature";
10
+ const [min, max] = options.weightRange ?? [0, 40];
11
+ const colorStops = options.colorStops ?? DEFAULT_COLOR_STOPS;
12
+ const weightExpr = [
13
+ "interpolate",
14
+ ["linear"],
15
+ ["get", weightProperty],
16
+ min,
17
+ 0,
18
+ max,
19
+ 1
20
+ ];
21
+ const colorExpr = ["interpolate", ["linear"], ["heatmap-density"], 0, "rgba(0, 0, 0, 0)"];
22
+ for (const [stop, color] of colorStops) colorExpr.push(stop, color);
23
+ return {
24
+ "heatmap-weight": weightExpr,
25
+ "heatmap-intensity": options.intensity ?? 1,
26
+ "heatmap-color": colorExpr,
27
+ "heatmap-radius": options.radius ?? 30,
28
+ "heatmap-opacity": options.opacity ?? 1
29
+ };
30
+ }
@@ -0,0 +1,13 @@
1
+ import type { Map as MaplibreMap } from 'maplibre-gl';
2
+ type PropBag = Record<string, unknown>;
3
+ export interface LayerUpdate {
4
+ id: string;
5
+ paint?: PropBag;
6
+ layout?: PropBag;
7
+ filter?: unknown;
8
+ minzoom?: number;
9
+ maxzoom?: number;
10
+ }
11
+ /** 把图层的响应式变更(缩放范围、paint、layout、filter)增量应用到地图。 */
12
+ export declare function applyLayerProps(map: MaplibreMap, next: LayerUpdate, prev?: LayerUpdate): void;
13
+ export {};
@@ -0,0 +1,17 @@
1
+ import { equalsBy } from "@movk/core";
2
+ function applyChangedProps(next, prev, apply) {
3
+ for (const key of Object.keys(next)) {
4
+ if (!equalsBy(next[key], prev[key])) apply(key, next[key]);
5
+ }
6
+ }
7
+ export function applyLayerProps(map, next, prev) {
8
+ const id = next.id;
9
+ if (next.minzoom !== prev?.minzoom || next.maxzoom !== prev?.maxzoom) {
10
+ map.setLayerZoomRange(id, next.minzoom ?? 0, next.maxzoom ?? 24);
11
+ }
12
+ applyChangedProps(next.paint ?? {}, prev?.paint ?? {}, (key, value) => map.setPaintProperty(id, key, value));
13
+ applyChangedProps(next.layout ?? {}, prev?.layout ?? {}, (key, value) => map.setLayoutProperty(id, key, value));
14
+ if (!equalsBy(next.filter, prev?.filter)) {
15
+ map.setFilter(id, next.filter);
16
+ }
17
+ }
@@ -0,0 +1,2 @@
1
+ /** 运行时日志器,跨 Nuxt 与纯 Vue 可用;统一携带 @movk/maplibre 标签 */
2
+ export declare const logger: import("consola").ConsolaInstance;
@@ -0,0 +1,2 @@
1
+ import { consola } from "consola";
2
+ export const logger = consola.withTag("@movk/maplibre");
@@ -0,0 +1,4 @@
1
+ /** 距离格式化:千米以下取整米,以上保留两位 km。 */
2
+ export declare function formatDistance(meters: number): string;
3
+ /** 面积格式化:平方千米以下取整平方米,以上保留两位 km²。 */
4
+ export declare function formatArea(squareMeters: number): string;
@@ -0,0 +1,8 @@
1
+ export function formatDistance(meters) {
2
+ if (meters < 1e3) return `${Math.round(meters)} m`;
3
+ return `${(meters / 1e3).toFixed(2)} km`;
4
+ }
5
+ export function formatArea(squareMeters) {
6
+ if (squareMeters < 1e6) return `${Math.round(squareMeters)} m\xB2`;
7
+ return `${(squareMeters / 1e6).toFixed(2)} km\xB2`;
8
+ }
@@ -0,0 +1,31 @@
1
+ export interface SpriteGrid {
2
+ /** 雪碧图列数 */
3
+ columns: number;
4
+ /**
5
+ * 雪碧图行数
6
+ * @defaultValue 1
7
+ */
8
+ rows?: number;
9
+ /** 单帧宽(像素) */
10
+ frameWidth: number;
11
+ /** 单帧高(像素) */
12
+ frameHeight: number;
13
+ /** 总帧数;缺省为 columns * rows */
14
+ frames?: number;
15
+ }
16
+ export interface FrameRect {
17
+ x: number;
18
+ y: number;
19
+ w: number;
20
+ h: number;
21
+ }
22
+ /**
23
+ * 计算雪碧图中第 index 帧的裁剪矩形(行优先排布)。
24
+ * index 越界按总帧数回绕,支持负数。
25
+ */
26
+ export declare function spriteFrameRect(index: number, grid: SpriteGrid): FrameRect;
27
+ /**
28
+ * 从已加载的雪碧图裁剪一帧到 size×size 画布,返回 ImageData。
29
+ * 无 canvas 2d 环境(SSR/测试)返回 undefined。
30
+ */
31
+ export declare function spriteFrame(source: CanvasImageSource, rect: FrameRect, size: number): ImageData | undefined;
@@ -0,0 +1,23 @@
1
+ export function spriteFrameRect(index, grid) {
2
+ const rows = grid.rows ?? 1;
3
+ const total = grid.frames ?? grid.columns * rows;
4
+ const i = (index % total + total) % total;
5
+ const col = i % grid.columns;
6
+ const row = Math.floor(i / grid.columns);
7
+ return {
8
+ x: col * grid.frameWidth,
9
+ y: row * grid.frameHeight,
10
+ w: grid.frameWidth,
11
+ h: grid.frameHeight
12
+ };
13
+ }
14
+ export function spriteFrame(source, rect, size) {
15
+ if (typeof document === "undefined") return void 0;
16
+ const canvas = document.createElement("canvas");
17
+ canvas.width = size;
18
+ canvas.height = size;
19
+ const context = canvas.getContext("2d", { willReadFrequently: true });
20
+ if (!context) return void 0;
21
+ context.drawImage(source, rect.x, rect.y, rect.w, rect.h, 0, 0, size, size);
22
+ return context.getImageData(0, 0, size, size);
23
+ }
@@ -0,0 +1,3 @@
1
+ import type { AdministrativeDivision, AdministrativeOptions } from '../types';
2
+ /** 行政区划查询:按名称(或国标码)查中心点、边界轮廓、下级行政区。 */
3
+ export declare function administrative(keyword: string, options: AdministrativeOptions, tk: string): Promise<AdministrativeDivision[]>;