@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 YiXuan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md ADDED
@@ -0,0 +1,192 @@
1
+ [![Movk MapLibre](https://maplibre.mhaibaraai.cn/og-image.png)](https://maplibre.mhaibaraai.cn/)
2
+
3
+ English | [简体中文](./README.md)
4
+
5
+ > A declarative MapLibre GL wrapper — compose maps with `MaplibreMap` / `MaplibreSource` / `MaplibreLayer` components and composables. The same `src/runtime` ships as a Nuxt 4 module and works in plain Vue + Vite projects via a Vite plugin. Built-in 3D buildings, dynamic effects (radar / diffusion / glow), sky / terrain environments, drawing (terra-draw), Tianditu tiles, WMS / WMTS, and multi-CRS localization support.
6
+
7
+ [![Install MCP in Cursor](https://maplibre.mhaibaraai.cn/mcp/badge.svg)](https://maplibre.mhaibaraai.cn/mcp/deeplink)
8
+ [![Install MCP in VS Code](https://maplibre.mhaibaraai.cn/mcp/badge.svg?ide=vscode)](https://maplibre.mhaibaraai.cn/mcp/deeplink?ide=vscode)
9
+
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
11
+ [![Nuxt](https://img.shields.io/badge/Nuxt-4-00DC82.svg)](https://nuxt.com/)
12
+ [![MapLibre GL](https://img.shields.io/badge/MapLibre%20GL-v6-396cb2.svg)](https://maplibre.org/maplibre-gl-js/docs/)
13
+ [![npm version][npm-version-src]][npm-version-href]
14
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
15
+ [![License][license-src]][license-href]
16
+
17
+ - 📖 [Documentation](https://maplibre.mhaibaraai.cn)
18
+ - 🇨🇳 [中文 README](./README.md)
19
+
20
+ ## ✨ Features
21
+
22
+ - **Declarative composition** — Build maps, sources, layers, markers, popups, and controls with components. No imperative instance lifecycle management required.
23
+ - **Context injection architecture** — `MaplibreContext` is propagated via provide/inject. Child components access the instance with `useMap()` directly, no id lookup needed.
24
+ - **Two-way camera binding** — `v-model:center` / `zoom` / `bearing` / `pitch`, with cross-route persistence (`persistent` + keepalive).
25
+ - **Rich layers and effects** — circle / fill / line / symbol / fill-extrusion / heatmap, clustering, buildings, raster, video, plus dynamic effects: radar / diffusion / glow / wave / migration / trail.
26
+ - **3D environment** — Sky and atmosphere, terrain, and temperature heatmaps.
27
+ - **Localization extensions** — Tianditu base tiles, WMS / WMTS services, `MaplibreDrawControl` drawing, and gcoord multi-CRS conversion (WGS84 / GCJ02 / BD09).
28
+ - **SSR safe** — Map instances are created client-side in `onMounted` inside the component. No `<ClientOnly>` wrapper needed.
29
+ - **AI friendly** — Built-in MCP Server and `llms.txt`. Components, composables, and docs are indexable by AI agents.
30
+
31
+ The same components work in both Nuxt 4 and plain Vue + Vite. Drawing capabilities require the optional `terra-draw` and `terra-draw-maplibre-gl-adapter` packages.
32
+
33
+ ## 🚀 Quick Start
34
+
35
+ ### Installation
36
+
37
+ ```bash
38
+ # pnpm
39
+ pnpm add @movk/maplibre maplibre-gl
40
+
41
+ # yarn
42
+ yarn add @movk/maplibre maplibre-gl
43
+
44
+ # npm
45
+ npm install @movk/maplibre maplibre-gl
46
+ ```
47
+
48
+ ```bash
49
+ # Optional: drawing support
50
+ pnpm add terra-draw terra-draw-maplibre-gl-adapter
51
+ ```
52
+
53
+ ### Nuxt
54
+
55
+ Register the module in `nuxt.config.ts`:
56
+
57
+ ```ts
58
+ export default defineNuxtConfig({
59
+ modules: ['@movk/maplibre']
60
+ })
61
+ ```
62
+
63
+ MapLibre needs no access token; when using Tianditu basemaps, the Tianditu token is read from an environment variable:
64
+
65
+ ```bash
66
+ NUXT_PUBLIC_MAPLIBRE_TK=your_tianditu_tk
67
+ ```
68
+
69
+ Components and composables are auto-imported — ready to use out of the box.
70
+
71
+ ### Vue + Vite
72
+
73
+ Use the Vite plugin and Vue plugin in plain Vue + Vite projects. The API is identical to Nuxt:
74
+
75
+ ```ts
76
+ // vite.config.ts
77
+ import vue from '@vitejs/plugin-vue'
78
+ import Maplibre from '@movk/maplibre/vite'
79
+
80
+ export default defineConfig({
81
+ plugins: [vue(), Maplibre()]
82
+ })
83
+ ```
84
+
85
+ ```ts
86
+ // main.ts
87
+ import { createApp } from 'vue'
88
+ import MaplibrePlugin from '@movk/maplibre/vue-plugin'
89
+ import '@movk/maplibre/index.css'
90
+ // maplibre-gl v6 needs an explicit worker URL when bundled by Vite
91
+ import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'
92
+ import App from './App.vue'
93
+
94
+ createApp(App)
95
+ .use(MaplibrePlugin, { workerUrl, tk: import.meta.env.VITE_TIANDITU_TK })
96
+ .mount('#app')
97
+ ```
98
+
99
+ ### Basic Example
100
+
101
+ Map instances are created client-side in `onMounted`. The component handles SSR safety internally — **no `<ClientOnly>` wrapper needed**:
102
+
103
+ ```vue
104
+ <script setup lang="ts">
105
+ const center = ref<[number, number]>([116.397, 39.908])
106
+ const zoom = ref(9)
107
+ </script>
108
+
109
+ <template>
110
+ <MaplibreMap v-model:center="center" v-model:zoom="zoom" :options="{ style: 'https://tiles.openfreemap.org/styles/liberty' }">
111
+ <MaplibreLayer
112
+ layer-id="points"
113
+ type="circle"
114
+ :source="{ type: 'geojson', data: '/points.geojson' }"
115
+ :paint="{ 'circle-radius': 8, 'circle-color': '#e11d48' }"
116
+ />
117
+ <MaplibreNavigationControl position="top-right" />
118
+ </MaplibreMap>
119
+ </template>
120
+ ```
121
+
122
+ ## 📦 Core Features
123
+
124
+ ### Declarative Components
125
+
126
+ All components are prefixed with `Maplibre` by default (configurable). Grouped by domain:
127
+
128
+ | Category | Components |
129
+ | --- | --- |
130
+ | Core | `MaplibreMap` `MaplibreSource` `MaplibreLayer` `MaplibreLayerGroup` `MaplibreCustomLayer` `MaplibreMarker` `MaplibreLottieMarker` `MaplibrePopup` `MaplibreTooltip` |
131
+ | Layers | `MaplibreBuildingLayer` `MaplibreClusterLayer` `MaplibreImageLayer` `MaplibreRasterLayer` `MaplibreVideoLayer` |
132
+ | Effects | `MaplibreRadar` `MaplibreDiffusionCircle` `MaplibreGlowCircle` `MaplibreWaveCircle` `MaplibreGradientBuilding` `MaplibreTextureBuilding` `MaplibreWindowBuilding` `MaplibreFlowBuilding` `MaplibreMigration` `MaplibreTrail` `MaplibreAnimatedImage` `MaplibreSpriteImage` |
133
+ | Environment | `MaplibreSky` `MaplibreTerrain` `MaplibreTemperature` |
134
+ | Controls | `MaplibreNavigationControl` `MaplibreGeolocateControl` `MaplibreFullscreenControl` `MaplibreScaleControl` `MaplibreAttributionControl` |
135
+ | Extensions | `MaplibreDrawControl` `MaplibreTiandituLayer` `MaplibreWmsLayer` `MaplibreWmtsLayer` |
136
+ | Buffers | `MaplibreBufferCircle` `MaplibreBufferEllipse` `MaplibreBufferLine` `MaplibreBufferPolygon` `MaplibreBufferSector` |
137
+
138
+ ### Composables
139
+
140
+ - `useMap()` — Inject the current map context (`map` / `isLoaded` / `whenLoaded()` / `onReady()`).
141
+ - `useMaplibre(id)` — Retrieve context by id from the registry (cross-tree / cross-route escape hatch).
142
+ - `useMaplibreCamera()` — Read and control the camera (center / zoom / bearing / pitch).
143
+ - `useMaplibreImage()` — Load and manage map images (icons / patterns).
144
+ - `useFrameIcon()` — Animated icon management based on frame sequences.
145
+ - `useFeatureState()` — Feature state (hover / active) management.
146
+ - `useMapAnimation()` — Frame-by-frame animation driver with lifecycle control.
147
+ - `useMapExport()` — Export map canvas as an image.
148
+ - `useMeasure()` — Distance and area measurement.
149
+ - `useMaplibreDraw(options?)` — Access the draw context; pass `mapId` to drive drawing from outside the component tree.
150
+ - `defineMaplibreControl(onAdd, onRemove)` — Define a custom map control.
151
+
152
+ ### Coordinate Conversion
153
+
154
+ ```ts
155
+ import { transformPoint, transformGeoJSON } from '@movk/maplibre/utils/coordinate'
156
+
157
+ transformPoint([116.397, 39.908], 'WGS84', 'GCJ02')
158
+ transformGeoJSON(featureCollection, 'GCJ02', 'WGS84')
159
+ ```
160
+
161
+ ## 🏗️ Architecture
162
+
163
+ All runtime code lives in `src/runtime`, shared by both distribution paths:
164
+
165
+ - **Nuxt module** — `src/module.ts` registers components and composables, writes config such as the Tianditu token to `runtimeConfig.public.maplibre`, and sets up the `#maplibre` alias pointing to the runtime.
166
+ - **Vite + unplugin** — `src/vite.ts` / `src/vue-plugin.ts` / `src/unplugin.ts` expose plugin entry points for component resolution and auto-imports. Runtime config is shared as a `globalThis` singleton so both build targets read the same config.
167
+ - **Runtime** — Map instances are distributed via provide/inject context. `onReady()` is the unified entry point for child components to register sources and layers, and automatically rebuilds them after `setStyle`.
168
+ - **Foundation** — Built on [MapLibre GL JS v6](https://maplibre.org/maplibre-gl-js/docs/), [@movk/core](https://github.com/mhaibaraai), [Turf.js](https://turfjs.org/), [gcoord](https://github.com/hujiulong/gcoord), and [VueUse](https://vueuse.org/).
169
+
170
+ ## ⚡ Tech Stack
171
+
172
+ - [MapLibre GL JS v6](https://maplibre.org/maplibre-gl-js/docs/) — Interactive vector map rendering engine
173
+ - [Nuxt 4](https://nuxt.com/) — The Intuitive Vue Framework
174
+ - [Vue 3.5](https://vuejs.org/) — The Progressive JavaScript Framework
175
+ - [TypeScript](https://www.typescriptlang.org/) — JavaScript with syntax for types
176
+ - [Turf.js](https://turfjs.org/) — Geospatial analysis; [gcoord](https://github.com/hujiulong/gcoord) — Multi-CRS conversion
177
+ - [Vitest](https://vitest.dev/) — Next Generation Testing Framework
178
+
179
+ ## 📄 License
180
+
181
+ [MIT](./LICENSE) License © 2024-PRESENT [YiXuan](https://github.com/mhaibaraai)
182
+
183
+ <!-- Badges -->
184
+
185
+ [npm-version-src]: https://img.shields.io/npm/v/@movk/maplibre?style=flat&colorA=080f12&colorB=1fa669
186
+ [npm-version-href]: https://npmjs.com/package/@movk/maplibre
187
+
188
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@movk/maplibre?style=flat&colorA=080f12&colorB=1fa669
189
+ [npm-downloads-href]: https://npmjs.com/package/@movk/maplibre
190
+
191
+ [license-src]: https://img.shields.io/github/license/mhaibaraai/movk-maplibre.svg?style=flat&colorA=080f12&colorB=1fa669
192
+ [license-href]: https://github.com/mhaibaraai/movk-maplibre/blob/main/LICENSE
package/README.md ADDED
@@ -0,0 +1,191 @@
1
+ [![Movk MapLibre](https://maplibre.mhaibaraai.cn/og-image.png)](https://maplibre.mhaibaraai.cn/)
2
+
3
+ 简体中文 | [English](./README.en.md)
4
+
5
+ > 声明式 MapLibre GL 封装库 —— 用 `MaplibreMap` / `MaplibreSource` / `MaplibreLayer` 等组件与 composables 组合地图。同一套 `src/runtime` 既作为 Nuxt 4 模块发布,也经 Vite 插件在纯 Vue + Vite 项目中使用。无需 access token,内置 3D 建筑、雷达 / 扩散 / 辉光等动态效果,sky / terrain 环境,绘制(terra-draw)、天地图、WMS / WMTS 与多坐标系本土化支持。
6
+
7
+ [![Install MCP in Cursor](https://maplibre.mhaibaraai.cn/mcp/badge.svg)](https://maplibre.mhaibaraai.cn/mcp/deeplink)
8
+ [![Install MCP in VS Code](https://maplibre.mhaibaraai.cn/mcp/badge.svg?ide=vscode)](https://maplibre.mhaibaraai.cn/mcp/deeplink?ide=vscode)
9
+
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)
11
+ [![Nuxt](https://img.shields.io/badge/Nuxt-4-00DC82.svg)](https://nuxt.com/)
12
+ [![MapLibre GL](https://img.shields.io/badge/MapLibre%20GL-v6-396cb2.svg)](https://maplibre.org/maplibre-gl-js/docs/)
13
+ [![npm version][npm-version-src]][npm-version-href]
14
+ [![npm downloads][npm-downloads-src]][npm-downloads-href]
15
+ [![License][license-src]][license-href]
16
+
17
+ - 📖 [在线文档](https://maplibre.mhaibaraai.cn)
18
+
19
+ ## ✨ 特性
20
+
21
+ - **声明式组合** - 用组件搭建地图、数据源、图层、标记、弹窗、控件,无需命令式管理实例生命周期。
22
+ - **上下文注入架构** - `MaplibreContext` 经 provide/inject 下发,子组件用 `useMap()` 直接取实例,不靠 id 查表。
23
+ - **相机双向绑定** - `v-model:center` / `zoom` / `bearing` / `pitch`,支持跨路由持久化(`persistent` + keepalive)。
24
+ - **丰富图层与效果** - circle / fill / line / symbol / fill-extrusion / heatmap、聚合、建筑、栅格、视频,叠加雷达 / 扩散 / 辉光 / 波纹 / 迁徙 / 轨迹等动态效果。
25
+ - **三维环境** - sky 天空与大气、terrain 地形与 temperature 温度热力。
26
+ - **本土化扩展** - 天地图底图、WMS / WMTS 服务、`MaplibreDrawControl` 绘制与 gcoord 多坐标系(WGS84 / GCJ02 / BD09)转换。
27
+ - **SSR 安全** - 地图实例只在客户端 `onMounted` 创建,组件内已处理,无需 `<ClientOnly>` 包裹。
28
+ - **AI 友好** - 内置 MCP Server 与 llms.txt,组件、composable、文档可被 AI 智能体检索。
29
+
30
+ 同一套组件在 Nuxt 4 与纯 Vue + Vite 下通用,仅绘制能力需可选安装 `terra-draw` 与 `terra-draw-maplibre-gl-adapter`。
31
+
32
+ ## 🚀 快速开始
33
+
34
+ ### 安装
35
+
36
+ ```bash
37
+ # pnpm
38
+ pnpm add @movk/maplibre maplibre-gl
39
+
40
+ # yarn
41
+ yarn add @movk/maplibre maplibre-gl
42
+
43
+ # npm
44
+ npm install @movk/maplibre maplibre-gl
45
+ ```
46
+
47
+ ```bash
48
+ # 可选:绘制能力
49
+ pnpm add terra-draw terra-draw-maplibre-gl-adapter
50
+ ```
51
+
52
+ ### Nuxt
53
+
54
+ 在 `nuxt.config.ts` 中注册模块:
55
+
56
+ ```ts
57
+ export default defineNuxtConfig({
58
+ modules: ['@movk/maplibre']
59
+ })
60
+ ```
61
+
62
+ MapLibre 无需 access token;使用天地图底图时,天地图 token 从环境变量读取:
63
+
64
+ ```bash
65
+ NUXT_PUBLIC_MAPLIBRE_TK=your_tianditu_tk
66
+ ```
67
+
68
+ 组件与 composables 自动导入,开箱即用。
69
+
70
+ ### Vue + Vite
71
+
72
+ 在纯 Vue + Vite 项目中经 Vite 插件 + Vue 插件使用,用法与 Nuxt 完全一致:
73
+
74
+ ```ts
75
+ // vite.config.ts
76
+ import vue from '@vitejs/plugin-vue'
77
+ import Maplibre from '@movk/maplibre/vite'
78
+
79
+ export default defineConfig({
80
+ plugins: [vue(), Maplibre()]
81
+ })
82
+ ```
83
+
84
+ ```ts
85
+ // main.ts
86
+ import { createApp } from 'vue'
87
+ import MaplibrePlugin from '@movk/maplibre/vue-plugin'
88
+ import '@movk/maplibre/index.css'
89
+ // maplibre-gl v6 经 Vite 打包时需显式提供 worker 地址
90
+ import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'
91
+ import App from './App.vue'
92
+
93
+ createApp(App)
94
+ .use(MaplibrePlugin, { workerUrl, tk: import.meta.env.VITE_TIANDITU_TK })
95
+ .mount('#app')
96
+ ```
97
+
98
+ ### 基础示例
99
+
100
+ 地图实例只在客户端 `onMounted` 创建,组件已做 SSR 安全处理,**无需 `<ClientOnly>` 包裹**:
101
+
102
+ ```vue
103
+ <script setup lang="ts">
104
+ const center = ref<[number, number]>([116.397, 39.908])
105
+ const zoom = ref(9)
106
+ </script>
107
+
108
+ <template>
109
+ <MaplibreMap v-model:center="center" v-model:zoom="zoom" :options="{ style: 'https://tiles.openfreemap.org/styles/liberty' }">
110
+ <MaplibreLayer
111
+ layer-id="points"
112
+ type="circle"
113
+ :source="{ type: 'geojson', data: '/points.geojson' }"
114
+ :paint="{ 'circle-radius': 8, 'circle-color': '#e11d48' }"
115
+ />
116
+ <MaplibreNavigationControl position="top-right" />
117
+ </MaplibreMap>
118
+ </template>
119
+ ```
120
+
121
+ ## 📦 核心功能
122
+
123
+ ### 声明式组件
124
+
125
+ 组件全局加 `Maplibre` 前缀(默认前缀可配),按领域分组:
126
+
127
+ | 分类 | 组件 |
128
+ | --- | --- |
129
+ | 核心 | `MaplibreMap` `MaplibreSource` `MaplibreLayer` `MaplibreLayerGroup` `MaplibreCustomLayer` `MaplibreMarker` `MaplibreLottieMarker` `MaplibrePopup` `MaplibreTooltip` |
130
+ | 图层 | `MaplibreBuildingLayer` `MaplibreClusterLayer` `MaplibreImageLayer` `MaplibreRasterLayer` `MaplibreVideoLayer` |
131
+ | 效果 | `MaplibreRadar` `MaplibreDiffusionCircle` `MaplibreGlowCircle` `MaplibreWaveCircle` `MaplibreGradientBuilding` `MaplibreTextureBuilding` `MaplibreWindowBuilding` `MaplibreFlowBuilding` `MaplibreMigration` `MaplibreTrail` `MaplibreAnimatedImage` `MaplibreSpriteImage` |
132
+ | 环境 | `MaplibreSky` `MaplibreTerrain` `MaplibreTemperature` |
133
+ | 控件 | `MaplibreNavigationControl` `MaplibreGeolocateControl` `MaplibreFullscreenControl` `MaplibreScaleControl` `MaplibreAttributionControl` |
134
+ | 扩展 | `MaplibreDrawControl` `MaplibreTiandituLayer` `MaplibreWmsLayer` `MaplibreWmtsLayer` |
135
+ | 缓冲 | `MaplibreBufferCircle` `MaplibreBufferEllipse` `MaplibreBufferLine` `MaplibreBufferPolygon` `MaplibreBufferSector` |
136
+
137
+ ### Composables
138
+
139
+ - `useMap()` — 注入当前地图上下文(`map` / `isLoaded` / `whenLoaded()` / `onReady()`)。
140
+ - `useMaplibre(id)` — 按 id 从注册表获取上下文(跨树 / 跨路由逃生口)。
141
+ - `useMaplibreCamera()` — 读取与控制相机(center / zoom / bearing / pitch)。
142
+ - `useMaplibreImage()` — 地图图像(icon / pattern)的加载与管理。
143
+ - `useFrameIcon()` — 基于帧序列的动画图标管理。
144
+ - `useFeatureState()` — 要素状态(hover / active)管理。
145
+ - `useMapAnimation()` — 逐帧动画驱动与生命周期控制。
146
+ - `useMapExport()` — 地图画布截图导出。
147
+ - `useMeasure()` — 距离 / 面积量算。
148
+ - `useMaplibreDraw(options?)` — 获取绘制上下文;传 `mapId` 可在组件树外驱动绘制。
149
+ - `defineMaplibreControl(onAdd, onRemove)` — 定义自定义控件。
150
+
151
+ ### 坐标转换
152
+
153
+ ```ts
154
+ import { transformPoint, transformGeoJSON } from '@movk/maplibre/utils/coordinate'
155
+
156
+ transformPoint([116.397, 39.908], 'WGS84', 'GCJ02')
157
+ transformGeoJSON(featureCollection, 'GCJ02', 'WGS84')
158
+ ```
159
+
160
+ ## 🏗️ 架构分层
161
+
162
+ 库的全部运行时实现都在 `src/runtime`,两条分发链共用同一套代码:
163
+
164
+ - **Nuxt 模块** - `src/module.ts` 注册组件与 composables,把天地图 token 等配置写入 `runtimeConfig.public.maplibre`,并挂 `#maplibre` 别名指向 runtime。
165
+ - **Vite + unplugin** - `src/vite.ts` / `src/vue-plugin.ts` / `src/unplugin.ts` 对外暴露插件入口,解析组件与自动导入;运行时配置以 `globalThis` 单例共享,使双构建读到同一份配置。
166
+ - **运行时** - `src/runtime` 内地图实例经 provide/inject 下发上下文,`onReady()` 是子组件建 source / layer 的统一入口,并在 `setStyle` 后自动重建。
167
+ - **基座** - 构建于 [MapLibre GL JS v6](https://maplibre.org/maplibre-gl-js/docs/)、[@movk/core](https://github.com/mhaibaraai)、[Turf.js](https://turfjs.org/)、[gcoord](https://github.com/hujiulong/gcoord) 与 [VueUse](https://vueuse.org/)。
168
+
169
+ ## ⚡ 技术栈
170
+
171
+ - [MapLibre GL JS v6](https://maplibre.org/maplibre-gl-js/docs/) - 交互式矢量地图渲染引擎
172
+ - [Nuxt 4](https://nuxt.com/) - The Intuitive Vue Framework
173
+ - [Vue 3.5](https://vuejs.org/) - The Progressive JavaScript Framework
174
+ - [TypeScript](https://www.typescriptlang.org/) - JavaScript with syntax for types
175
+ - [Turf.js](https://turfjs.org/) - 地理空间分析;[gcoord](https://github.com/hujiulong/gcoord) - 多坐标系转换
176
+ - [Vitest](https://vitest.dev/) - Next Generation Testing Framework
177
+
178
+ ## 📄 许可证
179
+
180
+ [MIT](./LICENSE) License © 2024-PRESENT [YiXuan](https://github.com/mhaibaraai)
181
+
182
+ <!-- Badges -->
183
+
184
+ [npm-version-src]: https://img.shields.io/npm/v/@movk/maplibre?style=flat&colorA=080f12&colorB=1fa669
185
+ [npm-version-href]: https://npmjs.com/package/@movk/maplibre
186
+
187
+ [npm-downloads-src]: https://img.shields.io/npm/dm/@movk/maplibre?style=flat&colorA=080f12&colorB=1fa669
188
+ [npm-downloads-href]: https://npmjs.com/package/@movk/maplibre
189
+
190
+ [license-src]: https://img.shields.io/github/license/mhaibaraai/movk-maplibre.svg?style=flat&colorA=080f12&colorB=1fa669
191
+ [license-href]: https://github.com/mhaibaraai/movk-maplibre/blob/main/LICENSE
@@ -0,0 +1,20 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ export * from '../dist/runtime/types/index.js';
3
+
4
+ interface ModuleOptions {
5
+ /** 天地图服务 token(tk) */
6
+ tk?: string;
7
+ /** 空白样式的字体 pbf 地址模板(含 {fontstack} 与 {range}) */
8
+ glyphs?: string;
9
+ /** 库内置文字图层使用的字体栈 */
10
+ textFont?: string[];
11
+ /**
12
+ * 组件前缀
13
+ * @defaultValue 'Maplibre'
14
+ */
15
+ prefix?: string;
16
+ }
17
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
18
+
19
+ export { _default as default };
20
+ export type { ModuleOptions };
@@ -0,0 +1,20 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+ export * from '../dist/runtime/types/index.js';
3
+
4
+ interface ModuleOptions {
5
+ /** 天地图服务 token(tk) */
6
+ tk?: string;
7
+ /** 空白样式的字体 pbf 地址模板(含 {fontstack} 与 {range}) */
8
+ glyphs?: string;
9
+ /** 库内置文字图层使用的字体栈 */
10
+ textFont?: string[];
11
+ /**
12
+ * 组件前缀
13
+ * @defaultValue 'Maplibre'
14
+ */
15
+ prefix?: string;
16
+ }
17
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
18
+
19
+ export { _default as default };
20
+ export type { ModuleOptions };
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@movk/maplibre",
3
+ "version": "1.0.0",
4
+ "configKey": "maplibre",
5
+ "compatibility": {
6
+ "nuxt": ">=4.0.0"
7
+ },
8
+ "builder": {
9
+ "@nuxt/module-builder": "1.0.3",
10
+ "unbuild": "3.6.1"
11
+ }
12
+ }
@@ -0,0 +1,63 @@
1
+ import { createRequire } from 'node:module';
2
+ import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addImports, addPlugin, addPluginTemplate, extendViteConfig } from '@nuxt/kit';
3
+ import { defu } from 'defu';
4
+
5
+ const name = "@movk/maplibre";
6
+ const version = "1.0.0";
7
+
8
+ const module$1 = defineNuxtModule({
9
+ meta: {
10
+ name,
11
+ version,
12
+ configKey: "maplibre",
13
+ compatibility: { nuxt: ">=4.0.0" }
14
+ },
15
+ defaults: {
16
+ prefix: "Maplibre"
17
+ },
18
+ setup(options, nuxt) {
19
+ const { resolve } = createResolver(import.meta.url);
20
+ nuxt.options.alias["#maplibre"] = resolve("./runtime");
21
+ const publicConfig = nuxt.options.runtimeConfig.public;
22
+ publicConfig.maplibre = defu(publicConfig.maplibre, {
23
+ tk: options.tk || process.env.NUXT_PUBLIC_MAPLIBRE_TK,
24
+ glyphs: options.glyphs,
25
+ textFont: options.textFont
26
+ });
27
+ nuxt.options.css.push(resolve("./runtime/index.css"));
28
+ addComponentsDir({
29
+ path: resolve("./runtime/components"),
30
+ prefix: options.prefix,
31
+ pathPrefix: false
32
+ });
33
+ addImportsDir(resolve("./runtime/composables"));
34
+ addImports([
35
+ { name: "movkDrawModes", from: resolve("./runtime/draw-modes") },
36
+ { name: "drawThemeStyles", from: resolve("./runtime/utils/draw-theme") }
37
+ ]);
38
+ addPlugin({ src: resolve("./runtime/plugins/config") });
39
+ addPluginTemplate({
40
+ filename: "movk-maplibre-worker.client.mjs",
41
+ mode: "client",
42
+ getContents: () => [
43
+ `import { defineNuxtPlugin } from '#app'`,
44
+ `import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'`,
45
+ `import { setMaplibreConfig } from ${JSON.stringify(resolve("./runtime/domains/map/config"))}`,
46
+ `export default defineNuxtPlugin(() => { setMaplibreConfig({ workerUrl }) })`
47
+ ].join("\n")
48
+ });
49
+ extendViteConfig((config) => {
50
+ config.optimizeDeps ||= {};
51
+ const include = config.optimizeDeps.include ||= [];
52
+ const require = createRequire(import.meta.url);
53
+ if (include.includes("lottie-web")) return;
54
+ try {
55
+ require.resolve("lottie-web", { paths: [nuxt.options.rootDir] });
56
+ include.push("lottie-web");
57
+ } catch {
58
+ }
59
+ });
60
+ }
61
+ });
62
+
63
+ export { module$1 as default };
@@ -0,0 +1,24 @@
1
+ import type { CustomLayerInterface } from 'maplibre-gl';
2
+ /** CustomLayerInterface 逃生舱:托管自定义 WebGL 图层的挂载/卸载与样式重载重建。 */
3
+ type __VLS_Props = {
4
+ /**
5
+ * 自定义图层实现(含 id/type/render)
6
+ * @see https://maplibre.org/maplibre-gl-js/docs/API/interfaces/CustomLayerInterface/
7
+ */
8
+ layer: CustomLayerInterface;
9
+ /** 插入到该图层之前 */
10
+ beforeId?: string;
11
+ };
12
+ declare var __VLS_1: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_1) => any;
15
+ };
16
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
20
+ type __VLS_WithSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import { onUnmounted } from "vue";
3
+ import { useMap } from "../composables/useMap";
4
+ const props = defineProps({
5
+ layer: { type: Object, required: true },
6
+ beforeId: { type: String, required: false }
7
+ });
8
+ const ctx = useMap();
9
+ const stopReady = ctx.onReady((map) => {
10
+ if (map.getLayer(props.layer.id)) return;
11
+ const before = props.beforeId && map.getLayer(props.beforeId) ? props.beforeId : void 0;
12
+ map.addLayer(props.layer, before);
13
+ });
14
+ onUnmounted(() => {
15
+ stopReady();
16
+ const map = ctx.map.value;
17
+ if (map?.getLayer(props.layer.id)) map.removeLayer(props.layer.id);
18
+ });
19
+ </script>
20
+
21
+ <template>
22
+ <slot />
23
+ </template>
@@ -0,0 +1,24 @@
1
+ import type { CustomLayerInterface } from 'maplibre-gl';
2
+ /** CustomLayerInterface 逃生舱:托管自定义 WebGL 图层的挂载/卸载与样式重载重建。 */
3
+ type __VLS_Props = {
4
+ /**
5
+ * 自定义图层实现(含 id/type/render)
6
+ * @see https://maplibre.org/maplibre-gl-js/docs/API/interfaces/CustomLayerInterface/
7
+ */
8
+ layer: CustomLayerInterface;
9
+ /** 插入到该图层之前 */
10
+ beforeId?: string;
11
+ };
12
+ declare var __VLS_1: {};
13
+ type __VLS_Slots = {} & {
14
+ default?: (props: typeof __VLS_1) => any;
15
+ };
16
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
17
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
18
+ declare const _default: typeof __VLS_export;
19
+ export default _default;
20
+ type __VLS_WithSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };