@movk/maplibre 1.0.0 → 1.2.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.
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/dist/module.d.mts +12 -3
- package/dist/module.d.ts +12 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +26 -11
- package/dist/runtime/components/CustomLayer.d.vue.ts +1 -1
- package/dist/runtime/components/CustomLayer.vue +18 -4
- package/dist/runtime/components/CustomLayer.vue.d.ts +1 -1
- package/dist/runtime/components/Layer.d.vue.ts +4 -4
- package/dist/runtime/components/Layer.vue +43 -18
- package/dist/runtime/components/Layer.vue.d.ts +4 -4
- package/dist/runtime/components/LayerGroup.d.vue.ts +23 -10
- package/dist/runtime/components/LayerGroup.vue +44 -4
- package/dist/runtime/components/LayerGroup.vue.d.ts +23 -10
- package/dist/runtime/components/LottieMarker.d.vue.ts +3 -3
- package/dist/runtime/components/LottieMarker.vue +6 -2
- package/dist/runtime/components/LottieMarker.vue.d.ts +3 -3
- package/dist/runtime/components/Map.d.vue.ts +2 -1
- package/dist/runtime/components/Map.vue +2 -6
- package/dist/runtime/components/Map.vue.d.ts +2 -1
- package/dist/runtime/components/Marker.d.vue.ts +2 -1
- package/dist/runtime/components/Marker.vue +33 -9
- package/dist/runtime/components/Marker.vue.d.ts +2 -1
- package/dist/runtime/components/Popup.d.vue.ts +1 -1
- package/dist/runtime/components/Popup.vue +23 -4
- package/dist/runtime/components/Popup.vue.d.ts +1 -1
- package/dist/runtime/components/Source.d.vue.ts +2 -2
- package/dist/runtime/components/Source.vue +3 -15
- package/dist/runtime/components/Source.vue.d.ts +2 -2
- package/dist/runtime/components/Tooltip.d.vue.ts +2 -2
- package/dist/runtime/components/Tooltip.vue +47 -19
- package/dist/runtime/components/Tooltip.vue.d.ts +2 -2
- package/dist/runtime/components/buffers/BufferCircle.d.vue.ts +1 -1
- package/dist/runtime/components/buffers/BufferCircle.vue.d.ts +1 -1
- package/dist/runtime/components/buffers/BufferEllipse.d.vue.ts +1 -1
- package/dist/runtime/components/buffers/BufferEllipse.vue.d.ts +1 -1
- package/dist/runtime/components/buffers/BufferLine.d.vue.ts +1 -1
- package/dist/runtime/components/buffers/BufferLine.vue.d.ts +1 -1
- package/dist/runtime/components/buffers/BufferPolygon.d.vue.ts +1 -1
- package/dist/runtime/components/buffers/BufferPolygon.vue.d.ts +1 -1
- package/dist/runtime/components/buffers/BufferSector.d.vue.ts +1 -1
- package/dist/runtime/components/buffers/BufferSector.vue.d.ts +1 -1
- package/dist/runtime/components/controls/BasemapControl.d.vue.ts +35 -0
- package/dist/runtime/components/controls/BasemapControl.vue +60 -0
- package/dist/runtime/components/controls/BasemapControl.vue.d.ts +35 -0
- package/dist/runtime/components/controls/Control.d.vue.ts +51 -0
- package/dist/runtime/components/controls/Control.vue +95 -0
- package/dist/runtime/components/controls/Control.vue.d.ts +51 -0
- package/dist/runtime/components/controls/GlobeControl.d.vue.ts +18 -0
- package/dist/runtime/components/controls/GlobeControl.vue +15 -0
- package/dist/runtime/components/controls/GlobeControl.vue.d.ts +18 -0
- package/dist/runtime/components/controls/LayerControl.d.vue.ts +44 -0
- package/dist/runtime/components/controls/LayerControl.vue +63 -0
- package/dist/runtime/components/controls/LayerControl.vue.d.ts +44 -0
- package/dist/runtime/components/controls/Legend.d.vue.ts +47 -0
- package/dist/runtime/components/controls/Legend.vue +69 -0
- package/dist/runtime/components/controls/Legend.vue.d.ts +47 -0
- package/dist/runtime/components/controls/Minimap.d.vue.ts +45 -0
- package/dist/runtime/components/controls/Minimap.vue +31 -0
- package/dist/runtime/components/controls/Minimap.vue.d.ts +45 -0
- package/dist/runtime/components/effects/AnimatedImage.d.vue.ts +1 -1
- package/dist/runtime/components/effects/AnimatedImage.vue +9 -6
- package/dist/runtime/components/effects/AnimatedImage.vue.d.ts +1 -1
- package/dist/runtime/components/effects/DiffusionCircle.d.vue.ts +1 -1
- package/dist/runtime/components/effects/DiffusionCircle.vue.d.ts +1 -1
- package/dist/runtime/components/effects/FlowBuilding.d.vue.ts +1 -1
- package/dist/runtime/components/effects/FlowBuilding.vue.d.ts +1 -1
- package/dist/runtime/components/effects/GlowCircle.d.vue.ts +1 -1
- package/dist/runtime/components/effects/GlowCircle.vue.d.ts +1 -1
- package/dist/runtime/components/effects/GradientBuilding.d.vue.ts +1 -1
- package/dist/runtime/components/effects/GradientBuilding.vue.d.ts +1 -1
- package/dist/runtime/components/effects/Migration.d.vue.ts +1 -1
- package/dist/runtime/components/effects/Migration.vue.d.ts +1 -1
- package/dist/runtime/components/effects/Radar.d.vue.ts +1 -1
- package/dist/runtime/components/effects/Radar.vue.d.ts +1 -1
- package/dist/runtime/components/effects/SpriteImage.d.vue.ts +1 -1
- package/dist/runtime/components/effects/SpriteImage.vue +40 -24
- package/dist/runtime/components/effects/SpriteImage.vue.d.ts +1 -1
- package/dist/runtime/components/effects/TextureBuilding.d.vue.ts +1 -1
- package/dist/runtime/components/effects/TextureBuilding.vue +1 -1
- package/dist/runtime/components/effects/TextureBuilding.vue.d.ts +1 -1
- package/dist/runtime/components/effects/Trail.d.vue.ts +1 -1
- package/dist/runtime/components/effects/Trail.vue.d.ts +1 -1
- package/dist/runtime/components/effects/WaveCircle.d.vue.ts +1 -1
- package/dist/runtime/components/effects/WaveCircle.vue.d.ts +1 -1
- package/dist/runtime/components/effects/WindowBuilding.d.vue.ts +1 -1
- package/dist/runtime/components/effects/WindowBuilding.vue.d.ts +1 -1
- package/dist/runtime/components/environment/Projection.d.vue.ts +28 -0
- package/dist/runtime/components/environment/Projection.vue +27 -0
- package/dist/runtime/components/environment/Projection.vue.d.ts +28 -0
- package/dist/runtime/components/environment/Temperature.d.vue.ts +1 -1
- package/dist/runtime/components/environment/Temperature.vue.d.ts +1 -1
- package/dist/runtime/components/environment/Terrain.d.vue.ts +1 -1
- package/dist/runtime/components/environment/Terrain.vue +5 -0
- package/dist/runtime/components/environment/Terrain.vue.d.ts +1 -1
- package/dist/runtime/components/extensions/DrawControl.vue +23 -19
- package/dist/runtime/components/extensions/Swipe.d.vue.ts +48 -0
- package/dist/runtime/components/extensions/Swipe.vue +141 -0
- package/dist/runtime/components/extensions/Swipe.vue.d.ts +48 -0
- package/dist/runtime/components/layers/BuildingLayer.d.vue.ts +1 -1
- package/dist/runtime/components/layers/BuildingLayer.vue.d.ts +1 -1
- package/dist/runtime/components/layers/ClusterLayer.d.vue.ts +1 -1
- package/dist/runtime/components/layers/ClusterLayer.vue.d.ts +1 -1
- package/dist/runtime/components/layers/ContourLayer.d.vue.ts +59 -0
- package/dist/runtime/components/layers/ContourLayer.vue +84 -0
- package/dist/runtime/components/layers/ContourLayer.vue.d.ts +59 -0
- package/dist/runtime/components/layers/GraticuleLayer.d.vue.ts +31 -0
- package/dist/runtime/components/layers/GraticuleLayer.vue +88 -0
- package/dist/runtime/components/layers/GraticuleLayer.vue.d.ts +31 -0
- package/dist/runtime/components/layers/ImageLayer.d.vue.ts +1 -1
- package/dist/runtime/components/layers/ImageLayer.vue.d.ts +1 -1
- package/dist/runtime/components/layers/MaskLayer.d.vue.ts +44 -0
- package/dist/runtime/components/layers/MaskLayer.vue +32 -0
- package/dist/runtime/components/layers/MaskLayer.vue.d.ts +44 -0
- package/dist/runtime/components/layers/RasterLayer.d.vue.ts +5 -3
- package/dist/runtime/components/layers/RasterLayer.vue +9 -2
- package/dist/runtime/components/layers/RasterLayer.vue.d.ts +5 -3
- package/dist/runtime/components/layers/VideoLayer.d.vue.ts +1 -1
- package/dist/runtime/components/layers/VideoLayer.vue.d.ts +1 -1
- package/dist/runtime/composables/useFeatureState.js +27 -5
- package/dist/runtime/composables/useFrameIcon.d.ts +4 -3
- package/dist/runtime/composables/useFrameIcon.js +18 -8
- package/dist/runtime/composables/useLayerTree.d.ts +11 -0
- package/dist/runtime/composables/useLayerTree.js +12 -0
- package/dist/runtime/composables/useMapAnimation.d.ts +4 -2
- package/dist/runtime/composables/useMapAnimation.js +5 -4
- package/dist/runtime/composables/useMapExport.js +2 -5
- package/dist/runtime/composables/useMapSync.d.ts +16 -0
- package/dist/runtime/composables/useMapSync.js +42 -0
- package/dist/runtime/composables/useMaplibreCamera.d.ts +1 -1
- package/dist/runtime/composables/useMaplibreCamera.js +1 -1
- package/dist/runtime/composables/useMaplibreImage.d.ts +3 -3
- package/dist/runtime/composables/useMaplibreImage.js +26 -5
- package/dist/runtime/domains/map/config.js +2 -3
- package/dist/runtime/domains/map/context.js +15 -0
- package/dist/runtime/domains/map/control.d.ts +1 -1
- package/dist/runtime/domains/map/control.js +1 -1
- package/dist/runtime/domains/map/draw-modes.d.ts +9 -0
- package/dist/runtime/domains/map/draw-modes.js +53 -0
- package/dist/runtime/domains/map/draw-registry.d.ts +2 -3
- package/dist/runtime/domains/map/draw-registry.js +6 -9
- package/dist/runtime/domains/map/draw-theme.d.ts +12 -0
- package/dist/runtime/domains/map/draw-toolbar.js +11 -10
- package/dist/runtime/domains/map/layer-group.d.ts +15 -4
- package/dist/runtime/domains/map/layer-tree.d.ts +3 -0
- package/dist/runtime/domains/map/layer-tree.js +10 -0
- package/dist/runtime/domains/map/minimap.d.ts +18 -0
- package/dist/runtime/domains/map/minimap.js +86 -0
- package/dist/runtime/domains/map/registry.js +4 -3
- package/dist/runtime/domains/map/style-layers.d.ts +7 -0
- package/dist/runtime/domains/map/style-layers.js +54 -0
- package/dist/runtime/domains/map/style.d.ts +3 -0
- package/dist/runtime/domains/map/style.js +5 -0
- package/dist/runtime/domains/map/swipe.d.ts +9 -0
- package/dist/runtime/domains/map/swipe.js +62 -0
- package/dist/runtime/index.css +1 -1
- package/dist/runtime/types/draw.d.ts +34 -1
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/layer.d.ts +40 -0
- package/dist/runtime/types/layer.js +0 -0
- package/dist/runtime/types/map.d.ts +6 -0
- package/dist/runtime/utils/cog.d.ts +2 -0
- package/dist/runtime/utils/cog.js +9 -0
- package/dist/runtime/utils/effects.js +2 -1
- package/dist/runtime/utils/events.d.ts +6 -0
- package/dist/runtime/utils/events.js +25 -0
- package/dist/runtime/utils/frame-icon.d.ts +2 -5
- package/dist/runtime/utils/frame-icon.js +10 -4
- package/dist/runtime/utils/graticule.d.ts +19 -0
- package/dist/runtime/utils/graticule.js +62 -0
- package/dist/runtime/utils/layer-opacity.d.ts +7 -0
- package/dist/runtime/utils/layer-opacity.js +59 -0
- package/dist/runtime/utils/layer.js +2 -1
- package/dist/runtime/utils/legend.d.ts +9 -0
- package/dist/runtime/utils/legend.js +52 -0
- package/dist/runtime/utils/marker.d.ts +11 -0
- package/dist/runtime/utils/marker.js +28 -0
- package/dist/runtime/utils/mask.d.ts +8 -0
- package/dist/runtime/utils/mask.js +33 -0
- package/dist/runtime/utils/minimap.d.ts +6 -0
- package/dist/runtime/utils/minimap.js +15 -0
- package/dist/runtime/utils/pmtiles.d.ts +3 -0
- package/dist/runtime/utils/pmtiles.js +10 -0
- package/dist/runtime/utils/source.d.ts +7 -0
- package/dist/runtime/utils/source.js +35 -0
- package/dist/runtime/utils/swipe.d.ts +32 -0
- package/dist/runtime/utils/swipe.js +18 -0
- package/dist/runtime/utils/tianditu.d.ts +10 -1
- package/dist/runtime/utils/tianditu.js +11 -0
- package/dist/runtime/utils/zzts-tile.d.ts +54 -0
- package/dist/runtime/utils/zzts-tile.js +85 -0
- package/dist/runtime/utils/zzts.d.ts +14 -0
- package/dist/runtime/utils/zzts.js +72 -0
- package/dist/unplugin.d.mts +1 -1
- package/dist/unplugin.d.ts +1 -1
- package/dist/unplugin.mjs +1 -7
- package/package.json +29 -21
- package/dist/runtime/draw-modes/index.d.ts +0 -16
- package/dist/runtime/draw-modes/index.js +0 -32
- package/dist/runtime/utils/draw-theme.d.ts +0 -47
- /package/dist/runtime/{utils → domains/map}/draw-theme.js +0 -0
package/README.en.md
CHANGED
|
@@ -130,8 +130,8 @@ All components are prefixed with `Maplibre` by default (configurable). Grouped b
|
|
|
130
130
|
| Core | `MaplibreMap` `MaplibreSource` `MaplibreLayer` `MaplibreLayerGroup` `MaplibreCustomLayer` `MaplibreMarker` `MaplibreLottieMarker` `MaplibrePopup` `MaplibreTooltip` |
|
|
131
131
|
| Layers | `MaplibreBuildingLayer` `MaplibreClusterLayer` `MaplibreImageLayer` `MaplibreRasterLayer` `MaplibreVideoLayer` |
|
|
132
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` |
|
|
133
|
+
| Environment | `MaplibreSky` `MaplibreProjection` `MaplibreTerrain` `MaplibreTemperature` |
|
|
134
|
+
| Controls | `MaplibreNavigationControl` `MaplibreGeolocateControl` `MaplibreFullscreenControl` `MaplibreGlobeControl` `MaplibreScaleControl` `MaplibreAttributionControl` |
|
|
135
135
|
| Extensions | `MaplibreDrawControl` `MaplibreTiandituLayer` `MaplibreWmsLayer` `MaplibreWmtsLayer` |
|
|
136
136
|
| Buffers | `MaplibreBufferCircle` `MaplibreBufferEllipse` `MaplibreBufferLine` `MaplibreBufferPolygon` `MaplibreBufferSector` |
|
|
137
137
|
|
package/README.md
CHANGED
|
@@ -129,8 +129,8 @@ const zoom = ref(9)
|
|
|
129
129
|
| 核心 | `MaplibreMap` `MaplibreSource` `MaplibreLayer` `MaplibreLayerGroup` `MaplibreCustomLayer` `MaplibreMarker` `MaplibreLottieMarker` `MaplibrePopup` `MaplibreTooltip` |
|
|
130
130
|
| 图层 | `MaplibreBuildingLayer` `MaplibreClusterLayer` `MaplibreImageLayer` `MaplibreRasterLayer` `MaplibreVideoLayer` |
|
|
131
131
|
| 效果 | `MaplibreRadar` `MaplibreDiffusionCircle` `MaplibreGlowCircle` `MaplibreWaveCircle` `MaplibreGradientBuilding` `MaplibreTextureBuilding` `MaplibreWindowBuilding` `MaplibreFlowBuilding` `MaplibreMigration` `MaplibreTrail` `MaplibreAnimatedImage` `MaplibreSpriteImage` |
|
|
132
|
-
| 环境 | `MaplibreSky` `MaplibreTerrain` `MaplibreTemperature` |
|
|
133
|
-
| 控件 | `MaplibreNavigationControl` `MaplibreGeolocateControl` `MaplibreFullscreenControl` `MaplibreScaleControl` `MaplibreAttributionControl` |
|
|
132
|
+
| 环境 | `MaplibreSky` `MaplibreProjection` `MaplibreTerrain` `MaplibreTemperature` |
|
|
133
|
+
| 控件 | `MaplibreNavigationControl` `MaplibreGeolocateControl` `MaplibreFullscreenControl` `MaplibreGlobeControl` `MaplibreScaleControl` `MaplibreAttributionControl` |
|
|
134
134
|
| 扩展 | `MaplibreDrawControl` `MaplibreTiandituLayer` `MaplibreWmsLayer` `MaplibreWmtsLayer` |
|
|
135
135
|
| 缓冲 | `MaplibreBufferCircle` `MaplibreBufferEllipse` `MaplibreBufferLine` `MaplibreBufferPolygon` `MaplibreBufferSector` |
|
|
136
136
|
|
package/dist/module.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
2
|
export * from '../dist/runtime/types/index.js';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions {
|
|
@@ -13,8 +13,17 @@ interface ModuleOptions {
|
|
|
13
13
|
* @defaultValue 'Maplibre'
|
|
14
14
|
*/
|
|
15
15
|
prefix?: string;
|
|
16
|
+
/** 按需注册数据协议(需安装对应可选依赖);开启后在客户端插件中注册,未开启时不打包相关依赖 */
|
|
17
|
+
protocols?: {
|
|
18
|
+
/** 注册 `pmtiles://` 协议,依赖 pmtiles */
|
|
19
|
+
pmtiles?: boolean;
|
|
20
|
+
/** 注册 `cog://` 协议,依赖 @geomatico/maplibre-cog-protocol */
|
|
21
|
+
cog?: boolean;
|
|
22
|
+
/** 注册 `zzts://` 协议(ZZTS 二维动态切片服务),无额外依赖;需自定义请求时改为自行调用 `registerZztsProtocol` */
|
|
23
|
+
zzts?: boolean;
|
|
24
|
+
};
|
|
16
25
|
}
|
|
17
|
-
declare const
|
|
26
|
+
declare const module$1: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
18
27
|
|
|
19
|
-
export {
|
|
28
|
+
export { module$1 as default };
|
|
20
29
|
export type { ModuleOptions };
|
package/dist/module.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NuxtModule } from '@nuxt/schema';
|
|
2
2
|
export * from '../dist/runtime/types/index.js';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions {
|
|
@@ -13,8 +13,17 @@ interface ModuleOptions {
|
|
|
13
13
|
* @defaultValue 'Maplibre'
|
|
14
14
|
*/
|
|
15
15
|
prefix?: string;
|
|
16
|
+
/** 按需注册数据协议(需安装对应可选依赖);开启后在客户端插件中注册,未开启时不打包相关依赖 */
|
|
17
|
+
protocols?: {
|
|
18
|
+
/** 注册 `pmtiles://` 协议,依赖 pmtiles */
|
|
19
|
+
pmtiles?: boolean;
|
|
20
|
+
/** 注册 `cog://` 协议,依赖 @geomatico/maplibre-cog-protocol */
|
|
21
|
+
cog?: boolean;
|
|
22
|
+
/** 注册 `zzts://` 协议(ZZTS 二维动态切片服务),无额外依赖;需自定义请求时改为自行调用 `registerZztsProtocol` */
|
|
23
|
+
zzts?: boolean;
|
|
24
|
+
};
|
|
16
25
|
}
|
|
17
|
-
declare const
|
|
26
|
+
declare const module$1: NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
18
27
|
|
|
19
|
-
export {
|
|
28
|
+
export { module$1 as default };
|
|
20
29
|
export type { ModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir,
|
|
2
|
+
import { defineNuxtModule, createResolver, addComponentsDir, addImportsDir, addPlugin, addPluginTemplate, extendViteConfig } from '@nuxt/kit';
|
|
3
3
|
import { defu } from 'defu';
|
|
4
4
|
|
|
5
5
|
const name = "@movk/maplibre";
|
|
6
|
-
const version = "1.
|
|
6
|
+
const version = "1.2.0";
|
|
7
7
|
|
|
8
|
+
const OPTIONAL_DEPS = ["lottie-web", "pmtiles", "@geomatico/maplibre-cog-protocol", "maplibre-contour"];
|
|
8
9
|
const module$1 = defineNuxtModule({
|
|
9
10
|
meta: {
|
|
10
11
|
name,
|
|
@@ -31,10 +32,6 @@ const module$1 = defineNuxtModule({
|
|
|
31
32
|
pathPrefix: false
|
|
32
33
|
});
|
|
33
34
|
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
35
|
addPlugin({ src: resolve("./runtime/plugins/config") });
|
|
39
36
|
addPluginTemplate({
|
|
40
37
|
filename: "movk-maplibre-worker.client.mjs",
|
|
@@ -46,15 +43,33 @@ const module$1 = defineNuxtModule({
|
|
|
46
43
|
`export default defineNuxtPlugin(() => { setMaplibreConfig({ workerUrl }) })`
|
|
47
44
|
].join("\n")
|
|
48
45
|
});
|
|
46
|
+
const protocols = [
|
|
47
|
+
options.protocols?.pmtiles && { path: "./runtime/utils/pmtiles", register: "registerPmtilesProtocol" },
|
|
48
|
+
options.protocols?.cog && { path: "./runtime/utils/cog", register: "registerCogProtocol" },
|
|
49
|
+
options.protocols?.zzts && { path: "./runtime/utils/zzts", register: "registerZztsProtocol" }
|
|
50
|
+
].filter((item) => !!item);
|
|
51
|
+
if (protocols.length) {
|
|
52
|
+
addPluginTemplate({
|
|
53
|
+
filename: "movk-maplibre-protocols.client.mjs",
|
|
54
|
+
mode: "client",
|
|
55
|
+
getContents: () => [
|
|
56
|
+
`import { defineNuxtPlugin } from '#app'`,
|
|
57
|
+
...protocols.map(({ path, register }) => `import { ${register} } from ${JSON.stringify(resolve(path))}`),
|
|
58
|
+
`export default defineNuxtPlugin(() => { ${protocols.map(({ register }) => `${register}()`).join("; ")} })`
|
|
59
|
+
].join("\n")
|
|
60
|
+
});
|
|
61
|
+
}
|
|
49
62
|
extendViteConfig((config) => {
|
|
50
63
|
config.optimizeDeps ||= {};
|
|
51
64
|
const include = config.optimizeDeps.include ||= [];
|
|
52
65
|
const require = createRequire(import.meta.url);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
for (const dep of OPTIONAL_DEPS) {
|
|
67
|
+
if (include.includes(dep)) continue;
|
|
68
|
+
try {
|
|
69
|
+
require.resolve(dep, { paths: [nuxt.options.rootDir] });
|
|
70
|
+
include.push(dep);
|
|
71
|
+
} catch {
|
|
72
|
+
}
|
|
58
73
|
}
|
|
59
74
|
});
|
|
60
75
|
}
|
|
@@ -2,7 +2,7 @@ import type { CustomLayerInterface } from 'maplibre-gl';
|
|
|
2
2
|
/** CustomLayerInterface 逃生舱:托管自定义 WebGL 图层的挂载/卸载与样式重载重建。 */
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
/**
|
|
5
|
-
* 自定义图层实现(含 id/type/render
|
|
5
|
+
* 自定义图层实现(含 id/type/render);按引用比较,替换对象时移除旧图层并添加新图层
|
|
6
6
|
* @see https://maplibre.org/maplibre-gl-js/docs/API/interfaces/CustomLayerInterface/
|
|
7
7
|
*/
|
|
8
8
|
layer: CustomLayerInterface;
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { onUnmounted } from "vue";
|
|
2
|
+
import { onUnmounted, toRaw, watch } from "vue";
|
|
3
3
|
import { useMap } from "../composables/useMap";
|
|
4
4
|
const props = defineProps({
|
|
5
5
|
layer: { type: Object, required: true },
|
|
6
6
|
beforeId: { type: String, required: false }
|
|
7
7
|
});
|
|
8
8
|
const ctx = useMap();
|
|
9
|
-
|
|
9
|
+
function resolveBeforeId(map) {
|
|
10
|
+
return props.beforeId && map.getLayer(props.beforeId) ? props.beforeId : void 0;
|
|
11
|
+
}
|
|
12
|
+
function addLayer(map) {
|
|
10
13
|
if (map.getLayer(props.layer.id)) return;
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
map.addLayer(toRaw(props.layer), resolveBeforeId(map));
|
|
15
|
+
}
|
|
16
|
+
const stopReady = ctx.onReady(addLayer);
|
|
17
|
+
watch(() => props.layer, (_next, prev) => {
|
|
18
|
+
const map = ctx.map.value;
|
|
19
|
+
if (!map?.getLayer(prev.id)) return;
|
|
20
|
+
map.removeLayer(prev.id);
|
|
21
|
+
addLayer(map);
|
|
22
|
+
});
|
|
23
|
+
watch(() => props.beforeId, () => {
|
|
24
|
+
const map = ctx.map.value;
|
|
25
|
+
if (!map?.getLayer(props.layer.id)) return;
|
|
26
|
+
map.moveLayer(props.layer.id, resolveBeforeId(map));
|
|
13
27
|
});
|
|
14
28
|
onUnmounted(() => {
|
|
15
29
|
stopReady();
|
|
@@ -2,7 +2,7 @@ import type { CustomLayerInterface } from 'maplibre-gl';
|
|
|
2
2
|
/** CustomLayerInterface 逃生舱:托管自定义 WebGL 图层的挂载/卸载与样式重载重建。 */
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
/**
|
|
5
|
-
* 自定义图层实现(含 id/type/render
|
|
5
|
+
* 自定义图层实现(含 id/type/render);按引用比较,替换对象时移除旧图层并添加新图层
|
|
6
6
|
* @see https://maplibre.org/maplibre-gl-js/docs/API/interfaces/CustomLayerInterface/
|
|
7
7
|
*/
|
|
8
8
|
layer: CustomLayerInterface;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { FilterSpecification, LayerSpecification, SourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
2
|
type PropBag = Record<string, unknown>;
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
/** 图层 id
|
|
4
|
+
/** 图层 id,全局唯一;变更需配合 `:key` 重建 */
|
|
5
5
|
layerId: string;
|
|
6
6
|
/**
|
|
7
|
-
* 图层类型,决定渲染方式与可用的 paint / layout
|
|
7
|
+
* 图层类型,决定渲染方式与可用的 paint / layout 属性;变更需配合 `:key` 重建
|
|
8
8
|
* @see https://maplibre.org/maplibre-style-spec/layers/
|
|
9
9
|
*/
|
|
10
10
|
type: LayerSpecification['type'];
|
|
11
|
-
/** source id 字符串引用,或内联 source
|
|
11
|
+
/** source id 字符串引用,或内联 source 对象(自动创建匿名源并随图层卸载,内容变化时增量更新);二者之间切换需配合 `:key` 重建 */
|
|
12
12
|
source?: string | SourceSpecification;
|
|
13
|
-
/** 矢量瓦片源内的子图层名(source-layer
|
|
13
|
+
/** 矢量瓦片源内的子图层名(source-layer),消费矢量源时必填;变更需配合 `:key` 重建 */
|
|
14
14
|
sourceLayer?: string;
|
|
15
15
|
/**
|
|
16
16
|
* 绘制样式属性,响应式变更经 setPaintProperty 增量下发
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { inject, onUnmounted, watch } from "vue";
|
|
2
|
+
import { computed, inject, onUnmounted, watch } from "vue";
|
|
3
3
|
import { omitUndefined } from "@movk/core";
|
|
4
4
|
import { useMap } from "../composables/useMap";
|
|
5
5
|
import { LayerGroupKey } from "../domains/map/layer-group";
|
|
6
6
|
import { applyLayerProps } from "../utils/layer";
|
|
7
|
+
import { opacityPropsFor, scaleOpacity } from "../utils/layer-opacity";
|
|
7
8
|
import { bindMapEvents } from "../utils/events";
|
|
9
|
+
import { updateSource } from "../utils/source";
|
|
8
10
|
const props = defineProps({
|
|
9
11
|
layerId: { type: String, required: true },
|
|
10
12
|
type: { type: String, required: true },
|
|
@@ -21,6 +23,22 @@ const emit = defineEmits(["click", "dblclick", "mousedown", "mouseup", "mousemov
|
|
|
21
23
|
const LAYER_EVENTS = ["click", "dblclick", "mousedown", "mouseup", "mousemove", "mouseenter", "mouseleave", "contextmenu"];
|
|
22
24
|
const ctx = useMap();
|
|
23
25
|
const group = inject(LayerGroupKey, null);
|
|
26
|
+
const effectiveLayout = computed(() => {
|
|
27
|
+
if (!group) return props.layout;
|
|
28
|
+
const visibility = group.visible.value ? props.layout?.visibility ?? "visible" : "none";
|
|
29
|
+
return { ...props.layout, visibility };
|
|
30
|
+
});
|
|
31
|
+
const effectivePaint = computed(() => {
|
|
32
|
+
const factor = group?.opacity.value ?? 1;
|
|
33
|
+
if (factor === 1) return props.paint;
|
|
34
|
+
const scaled = Object.fromEntries(
|
|
35
|
+
opacityPropsFor(props.type).map((key) => [key, scaleOpacity(props.paint?.[key], factor)])
|
|
36
|
+
);
|
|
37
|
+
return { ...props.paint, ...scaled };
|
|
38
|
+
});
|
|
39
|
+
if (group) {
|
|
40
|
+
onUnmounted(group.registerLayer(() => ({ layerId: props.layerId, type: props.type, paint: props.paint })));
|
|
41
|
+
}
|
|
24
42
|
const inlineSourceId = `${props.layerId}__source`;
|
|
25
43
|
const hasInlineSource = typeof props.source === "object";
|
|
26
44
|
function resolveSourceId() {
|
|
@@ -32,8 +50,8 @@ function buildSpec() {
|
|
|
32
50
|
id: props.layerId,
|
|
33
51
|
type: props.type,
|
|
34
52
|
source: resolveSourceId(),
|
|
35
|
-
paint:
|
|
36
|
-
layout:
|
|
53
|
+
paint: effectivePaint.value,
|
|
54
|
+
layout: effectiveLayout.value,
|
|
37
55
|
filter: props.filter,
|
|
38
56
|
minzoom: props.minzoom,
|
|
39
57
|
maxzoom: props.maxzoom
|
|
@@ -41,17 +59,21 @@ function buildSpec() {
|
|
|
41
59
|
if (props.sourceLayer) spec["source-layer"] = props.sourceLayer;
|
|
42
60
|
return spec;
|
|
43
61
|
}
|
|
62
|
+
function resolveBeforeId(map) {
|
|
63
|
+
const anchor = props.beforeId ?? group?.beforeId.value;
|
|
64
|
+
return anchor && map.getLayer(anchor) ? anchor : void 0;
|
|
65
|
+
}
|
|
66
|
+
function currentUpdate() {
|
|
67
|
+
return { id: props.layerId, paint: effectivePaint.value, layout: effectiveLayout.value, filter: props.filter, minzoom: props.minzoom, maxzoom: props.maxzoom };
|
|
68
|
+
}
|
|
69
|
+
let prev = currentUpdate();
|
|
44
70
|
function addLayer(map) {
|
|
45
71
|
if (map.getLayer(props.layerId)) return;
|
|
46
72
|
if (hasInlineSource && !map.getSource(inlineSourceId)) {
|
|
47
73
|
map.addSource(inlineSourceId, props.source);
|
|
48
74
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
map.addLayer(buildSpec(), before);
|
|
52
|
-
if (group && !group.visible.value) {
|
|
53
|
-
map.setLayoutProperty(props.layerId, "visibility", "none");
|
|
54
|
-
}
|
|
75
|
+
map.addLayer(buildSpec(), resolveBeforeId(map));
|
|
76
|
+
prev = currentUpdate();
|
|
55
77
|
}
|
|
56
78
|
let stopEvents;
|
|
57
79
|
let onSourceData;
|
|
@@ -77,25 +99,28 @@ function bindLayerEvents(map) {
|
|
|
77
99
|
stopEvents?.();
|
|
78
100
|
stopEvents = bindMapEvents(map, LAYER_EVENTS, (type, event) => emit(type, event), props.layerId);
|
|
79
101
|
}
|
|
80
|
-
let prev = { id: props.layerId, paint: props.paint, layout: props.layout, filter: props.filter, minzoom: props.minzoom, maxzoom: props.maxzoom };
|
|
81
102
|
watch(
|
|
82
|
-
() => [
|
|
103
|
+
() => [effectivePaint.value, effectiveLayout.value, props.filter, props.minzoom, props.maxzoom],
|
|
83
104
|
() => {
|
|
84
105
|
const map = ctx.map.value;
|
|
85
106
|
if (!map?.getLayer(props.layerId)) return;
|
|
86
|
-
const next =
|
|
107
|
+
const next = currentUpdate();
|
|
87
108
|
applyLayerProps(map, next, prev);
|
|
88
109
|
prev = next;
|
|
89
110
|
},
|
|
90
111
|
{ deep: true }
|
|
91
112
|
);
|
|
92
|
-
if (
|
|
93
|
-
watch(
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
});
|
|
113
|
+
if (hasInlineSource) {
|
|
114
|
+
watch(() => props.source, (next, prev2) => {
|
|
115
|
+
const source = ctx.map.value?.getSource(inlineSourceId);
|
|
116
|
+
if (source) updateSource(source, next, prev2);
|
|
117
|
+
}, { deep: true });
|
|
98
118
|
}
|
|
119
|
+
watch(() => props.beforeId ?? group?.beforeId.value, () => {
|
|
120
|
+
const map = ctx.map.value;
|
|
121
|
+
if (!map?.getLayer(props.layerId)) return;
|
|
122
|
+
map.moveLayer(props.layerId, resolveBeforeId(map));
|
|
123
|
+
});
|
|
99
124
|
onUnmounted(() => {
|
|
100
125
|
stopReady();
|
|
101
126
|
stopEvents?.();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { FilterSpecification, LayerSpecification, SourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
2
|
type PropBag = Record<string, unknown>;
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
/** 图层 id
|
|
4
|
+
/** 图层 id,全局唯一;变更需配合 `:key` 重建 */
|
|
5
5
|
layerId: string;
|
|
6
6
|
/**
|
|
7
|
-
* 图层类型,决定渲染方式与可用的 paint / layout
|
|
7
|
+
* 图层类型,决定渲染方式与可用的 paint / layout 属性;变更需配合 `:key` 重建
|
|
8
8
|
* @see https://maplibre.org/maplibre-style-spec/layers/
|
|
9
9
|
*/
|
|
10
10
|
type: LayerSpecification['type'];
|
|
11
|
-
/** source id 字符串引用,或内联 source
|
|
11
|
+
/** source id 字符串引用,或内联 source 对象(自动创建匿名源并随图层卸载,内容变化时增量更新);二者之间切换需配合 `:key` 重建 */
|
|
12
12
|
source?: string | SourceSpecification;
|
|
13
|
-
/** 矢量瓦片源内的子图层名(source-layer
|
|
13
|
+
/** 矢量瓦片源内的子图层名(source-layer),消费矢量源时必填;变更需配合 `:key` 重建 */
|
|
14
14
|
sourceLayer?: string;
|
|
15
15
|
/**
|
|
16
16
|
* 绘制样式属性,响应式变更经 setPaintProperty 增量下发
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import type { LegendItem, StyleLayerPredicate } from '../types';
|
|
2
|
+
/** 图层组:统一子图层的插入锚点、显隐与透明度;带 title 时进入图层树,供图层控件、图例与 useLayerTree 使用。 */
|
|
2
3
|
type __VLS_Props = {
|
|
3
|
-
/**
|
|
4
|
+
/** 组内图层缺省插入到该图层之前;未设置时继承父组 */
|
|
4
5
|
beforeId?: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/** 组标题;设置后注册到图层树,出现在 MaplibreLayerControl、MaplibreLegend 与 useLayerTree 中 */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** 图例项;省略时由子图层颜色推导 */
|
|
9
|
+
legend?: LegendItem[];
|
|
10
|
+
/** 认领底图样式自带的图层(按类型、source-layer 等匹配),与子图层一起受组的显隐与透明度控制 */
|
|
11
|
+
styleLayers?: StyleLayerPredicate;
|
|
10
12
|
};
|
|
13
|
+
type __VLS_ModelProps = {
|
|
14
|
+
/** 组级显隐(组开关优先于子图层自身的 layout.visibility) */
|
|
15
|
+
'visible'?: boolean;
|
|
16
|
+
/** 组级透明度 0..1,按图层类型缩放各透明度属性 */
|
|
17
|
+
'opacity'?: number;
|
|
18
|
+
};
|
|
19
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
20
|
declare var __VLS_1: {};
|
|
12
21
|
type __VLS_Slots = {} & {
|
|
13
22
|
default?: (props: typeof __VLS_1) => any;
|
|
14
23
|
};
|
|
15
|
-
declare const __VLS_base: import("vue").DefineComponent<
|
|
16
|
-
visible: boolean;
|
|
17
|
-
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
"update:visible": (value: boolean) => any;
|
|
26
|
+
"update:opacity": (value: number) => any;
|
|
27
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
28
|
+
"onUpdate:visible"?: ((value: boolean) => any) | undefined;
|
|
29
|
+
"onUpdate:opacity"?: ((value: number) => any) | undefined;
|
|
30
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
31
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
19
32
|
declare const _default: typeof __VLS_export;
|
|
20
33
|
export default _default;
|
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { provide,
|
|
2
|
+
import { computed, inject, provide, reactive, shallowReactive, useId, watch } from "vue";
|
|
3
|
+
import { clamp } from "@movk/core";
|
|
4
|
+
import { useMap } from "../composables/useMap";
|
|
3
5
|
import { LayerGroupKey } from "../domains/map/layer-group";
|
|
6
|
+
import { getLayerTree } from "../domains/map/layer-tree";
|
|
7
|
+
import { useStyleLayerAdoption } from "../domains/map/style-layers";
|
|
8
|
+
import { deriveLegend } from "../utils/legend";
|
|
4
9
|
const props = defineProps({
|
|
5
10
|
beforeId: { type: String, required: false },
|
|
6
|
-
|
|
11
|
+
title: { type: String, required: false },
|
|
12
|
+
legend: { type: Array, required: false },
|
|
13
|
+
styleLayers: { type: Function, required: false }
|
|
7
14
|
});
|
|
15
|
+
const visible = defineModel("visible", { type: Boolean, ...{ default: true } });
|
|
16
|
+
const opacity = defineModel("opacity", { type: Number, ...{ default: 1 } });
|
|
17
|
+
const ctx = useMap();
|
|
18
|
+
const parent = inject(LayerGroupKey, null);
|
|
19
|
+
const effectiveVisible = computed(() => (parent?.visible.value ?? true) && visible.value);
|
|
20
|
+
const effectiveOpacity = computed(() => (parent?.opacity.value ?? 1) * clamp(opacity.value, 0, 1));
|
|
21
|
+
const layers = shallowReactive(/* @__PURE__ */ new Set());
|
|
22
|
+
function registerLayer(descriptor) {
|
|
23
|
+
if (!props.title && parent) return parent.registerLayer(descriptor);
|
|
24
|
+
layers.add(descriptor);
|
|
25
|
+
return () => layers.delete(descriptor);
|
|
26
|
+
}
|
|
8
27
|
provide(LayerGroupKey, {
|
|
9
|
-
beforeId:
|
|
10
|
-
visible:
|
|
28
|
+
beforeId: computed(() => props.beforeId ?? parent?.beforeId.value),
|
|
29
|
+
visible: effectiveVisible,
|
|
30
|
+
opacity: effectiveOpacity,
|
|
31
|
+
registerLayer
|
|
11
32
|
});
|
|
33
|
+
useStyleLayerAdoption(() => props.styleLayers, effectiveVisible, effectiveOpacity);
|
|
34
|
+
const legendItems = computed(() => props.legend ?? deriveLegend([...layers].map((get) => get()), props.title ?? ""));
|
|
35
|
+
const item = reactive({
|
|
36
|
+
id: useId(),
|
|
37
|
+
title: computed(() => props.title ?? ""),
|
|
38
|
+
visible,
|
|
39
|
+
opacity,
|
|
40
|
+
legend: legendItems,
|
|
41
|
+
setVisible: (value) => {
|
|
42
|
+
visible.value = value;
|
|
43
|
+
},
|
|
44
|
+
setOpacity: (value) => {
|
|
45
|
+
opacity.value = clamp(value, 0, 1);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
watch(() => Boolean(props.title), (titled, _, onCleanup) => {
|
|
49
|
+
if (!titled) return;
|
|
50
|
+
onCleanup(getLayerTree(ctx).register(item.id, item));
|
|
51
|
+
}, { immediate: true });
|
|
12
52
|
</script>
|
|
13
53
|
|
|
14
54
|
<template>
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
import type { LegendItem, StyleLayerPredicate } from '../types';
|
|
2
|
+
/** 图层组:统一子图层的插入锚点、显隐与透明度;带 title 时进入图层树,供图层控件、图例与 useLayerTree 使用。 */
|
|
2
3
|
type __VLS_Props = {
|
|
3
|
-
/**
|
|
4
|
+
/** 组内图层缺省插入到该图层之前;未设置时继承父组 */
|
|
4
5
|
beforeId?: string;
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
/** 组标题;设置后注册到图层树,出现在 MaplibreLayerControl、MaplibreLegend 与 useLayerTree 中 */
|
|
7
|
+
title?: string;
|
|
8
|
+
/** 图例项;省略时由子图层颜色推导 */
|
|
9
|
+
legend?: LegendItem[];
|
|
10
|
+
/** 认领底图样式自带的图层(按类型、source-layer 等匹配),与子图层一起受组的显隐与透明度控制 */
|
|
11
|
+
styleLayers?: StyleLayerPredicate;
|
|
10
12
|
};
|
|
13
|
+
type __VLS_ModelProps = {
|
|
14
|
+
/** 组级显隐(组开关优先于子图层自身的 layout.visibility) */
|
|
15
|
+
'visible'?: boolean;
|
|
16
|
+
/** 组级透明度 0..1,按图层类型缩放各透明度属性 */
|
|
17
|
+
'opacity'?: number;
|
|
18
|
+
};
|
|
19
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
11
20
|
declare var __VLS_1: {};
|
|
12
21
|
type __VLS_Slots = {} & {
|
|
13
22
|
default?: (props: typeof __VLS_1) => any;
|
|
14
23
|
};
|
|
15
|
-
declare const __VLS_base: import("vue").DefineComponent<
|
|
16
|
-
visible: boolean;
|
|
17
|
-
|
|
24
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
"update:visible": (value: boolean) => any;
|
|
26
|
+
"update:opacity": (value: number) => any;
|
|
27
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
28
|
+
"onUpdate:visible"?: ((value: boolean) => any) | undefined;
|
|
29
|
+
"onUpdate:opacity"?: ((value: number) => any) | undefined;
|
|
30
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
31
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
19
32
|
declare const _default: typeof __VLS_export;
|
|
20
33
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LngLatLike } from 'maplibre-gl';
|
|
2
2
|
/** Lottie 标记:在地图标记位用 lottie-web 渲染矢量动画(走 Marker DOM,非 icon 帧驱动)。 */
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
/** lottie 动画数据(JSON 对象);与 path
|
|
4
|
+
/** lottie 动画数据(JSON 对象);与 path 二选一,按引用比较,替换对象才重新加载 */
|
|
5
5
|
animationData?: object;
|
|
6
6
|
/** lottie 动画 URL;与 animationData 二选一 */
|
|
7
7
|
path?: string;
|
|
@@ -40,11 +40,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
40
40
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
41
41
|
"onUpdate:lnglat"?: ((value: LngLatLike) => any) | undefined;
|
|
42
42
|
}>, {
|
|
43
|
-
width: number;
|
|
44
|
-
height: number;
|
|
45
43
|
loop: boolean;
|
|
46
44
|
autoplay: boolean;
|
|
47
45
|
speed: number;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
48
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
49
49
|
declare const _default: typeof __VLS_export;
|
|
50
50
|
export default _default;
|
|
@@ -14,12 +14,16 @@ const props = defineProps({
|
|
|
14
14
|
const lnglat = defineModel("lnglat", { type: [Object, Array], ...{ required: true } });
|
|
15
15
|
const container = useTemplateRef("container");
|
|
16
16
|
let anim;
|
|
17
|
-
|
|
17
|
+
function load() {
|
|
18
|
+
anim?.destroy();
|
|
19
|
+
anim = void 0;
|
|
18
20
|
if (!container.value) return;
|
|
19
21
|
const base = { container: container.value, renderer: "svg", loop: props.loop, autoplay: props.autoplay };
|
|
20
22
|
anim = props.path ? lottie.loadAnimation({ ...base, path: props.path }) : lottie.loadAnimation({ ...base, animationData: props.animationData });
|
|
21
23
|
anim.setSpeed(props.speed);
|
|
22
|
-
}
|
|
24
|
+
}
|
|
25
|
+
onMounted(load);
|
|
26
|
+
watch([() => props.path, () => props.animationData, () => props.loop, () => props.autoplay], load);
|
|
23
27
|
watch(() => props.speed, (speed) => anim?.setSpeed(speed));
|
|
24
28
|
onUnmounted(() => anim?.destroy());
|
|
25
29
|
</script>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LngLatLike } from 'maplibre-gl';
|
|
2
2
|
/** Lottie 标记:在地图标记位用 lottie-web 渲染矢量动画(走 Marker DOM,非 icon 帧驱动)。 */
|
|
3
3
|
type __VLS_Props = {
|
|
4
|
-
/** lottie 动画数据(JSON 对象);与 path
|
|
4
|
+
/** lottie 动画数据(JSON 对象);与 path 二选一,按引用比较,替换对象才重新加载 */
|
|
5
5
|
animationData?: object;
|
|
6
6
|
/** lottie 动画 URL;与 animationData 二选一 */
|
|
7
7
|
path?: string;
|
|
@@ -40,11 +40,11 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {},
|
|
|
40
40
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
41
41
|
"onUpdate:lnglat"?: ((value: LngLatLike) => any) | undefined;
|
|
42
42
|
}>, {
|
|
43
|
-
width: number;
|
|
44
|
-
height: number;
|
|
45
43
|
loop: boolean;
|
|
46
44
|
autoplay: boolean;
|
|
47
45
|
speed: number;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
48
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
49
49
|
declare const _default: typeof __VLS_export;
|
|
50
50
|
export default _default;
|
|
@@ -4,7 +4,8 @@ type __VLS_Props = {
|
|
|
4
4
|
/** 地图 id;省略时自动生成。提供后可经 useMaplibre(id) 外部访问 */
|
|
5
5
|
mapId?: string;
|
|
6
6
|
/**
|
|
7
|
-
* maplibre-gl Map 初始化选项(container 由组件接管);缺省 style
|
|
7
|
+
* maplibre-gl Map 初始化选项(container 由组件接管);缺省 style 时使用空白样式。
|
|
8
|
+
* 除 style 外仅在创建时读取,变更需配合 `:key` 重建
|
|
8
9
|
* @see https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/
|
|
9
10
|
*/
|
|
10
11
|
options?: MaplibreMapOptions;
|
|
@@ -5,14 +5,10 @@ import { omitUndefined } from "@movk/core";
|
|
|
5
5
|
import { LngLat } from "maplibre-gl";
|
|
6
6
|
import { createMaplibreContext, MaplibreContextKey } from "../domains/map/context";
|
|
7
7
|
import { createMaplibreGl } from "../domains/map/create-map";
|
|
8
|
-
import {
|
|
8
|
+
import { blankStyle } from "../domains/map/style";
|
|
9
9
|
import { getMapContext, registerMap, unregisterMap } from "../domains/map/registry";
|
|
10
10
|
import { bindMapEvents } from "../utils/events";
|
|
11
11
|
defineOptions({ inheritAttrs: false });
|
|
12
|
-
function blankStyle() {
|
|
13
|
-
const { glyphs } = getMaplibreConfig();
|
|
14
|
-
return { version: 8, ...glyphs ? { glyphs } : {}, sources: {}, layers: [] };
|
|
15
|
-
}
|
|
16
12
|
const props = defineProps({
|
|
17
13
|
mapId: { type: String, required: false },
|
|
18
14
|
options: { type: Object, required: false },
|
|
@@ -130,5 +126,5 @@ defineExpose({
|
|
|
130
126
|
</template>
|
|
131
127
|
|
|
132
128
|
<style>
|
|
133
|
-
@layer components{:where(.movk-maplibre){height:100%;position:relative;width:100%}}.movk-maplibre>.movk-maplibre__container{inset:0;position:absolute}
|
|
129
|
+
@layer components{:where(.movk-maplibre){height:100%;position:relative;width:100%}}.movk-maplibre{isolation:isolate}.movk-maplibre>.movk-maplibre__container{inset:0;position:absolute}
|
|
134
130
|
</style>
|
|
@@ -4,7 +4,8 @@ type __VLS_Props = {
|
|
|
4
4
|
/** 地图 id;省略时自动生成。提供后可经 useMaplibre(id) 外部访问 */
|
|
5
5
|
mapId?: string;
|
|
6
6
|
/**
|
|
7
|
-
* maplibre-gl Map 初始化选项(container 由组件接管);缺省 style
|
|
7
|
+
* maplibre-gl Map 初始化选项(container 由组件接管);缺省 style 时使用空白样式。
|
|
8
|
+
* 除 style 外仅在创建时读取,变更需配合 `:key` 重建
|
|
8
9
|
* @see https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MapOptions/
|
|
9
10
|
*/
|
|
10
11
|
options?: MaplibreMapOptions;
|
|
@@ -3,7 +3,8 @@ import type { LngLatLike, MarkerOptions, PopupOptions } from 'maplibre-gl';
|
|
|
3
3
|
import type { PopupTrigger } from '../types';
|
|
4
4
|
type __VLS_Props = {
|
|
5
5
|
/**
|
|
6
|
-
* 标记选项;element
|
|
6
|
+
* 标记选项;element 由默认插槽提供,无需在此传入。
|
|
7
|
+
* 有 setter 的字段(rotation、draggable 等)增量更新,anchor、color、scale 变化时重建
|
|
7
8
|
* @see https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/MarkerOptions/
|
|
8
9
|
*/
|
|
9
10
|
options?: Omit<MarkerOptions, 'element'>;
|