@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.
- package/LICENSE +21 -0
- package/README.en.md +192 -0
- package/README.md +191 -0
- package/dist/module.d.mts +20 -0
- package/dist/module.d.ts +20 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +63 -0
- package/dist/runtime/components/CustomLayer.d.vue.ts +24 -0
- package/dist/runtime/components/CustomLayer.vue +23 -0
- package/dist/runtime/components/CustomLayer.vue.d.ts +24 -0
- package/dist/runtime/components/Layer.d.vue.ts +75 -0
- package/dist/runtime/components/Layer.vue +112 -0
- package/dist/runtime/components/Layer.vue.d.ts +75 -0
- package/dist/runtime/components/LayerGroup.d.vue.ts +25 -0
- package/dist/runtime/components/LayerGroup.vue +16 -0
- package/dist/runtime/components/LayerGroup.vue.d.ts +25 -0
- package/dist/runtime/components/LottieMarker.d.vue.ts +50 -0
- package/dist/runtime/components/LottieMarker.vue +31 -0
- package/dist/runtime/components/LottieMarker.vue.d.ts +50 -0
- package/dist/runtime/components/Map.d.vue.ts +84 -0
- package/dist/runtime/components/Map.vue +134 -0
- package/dist/runtime/components/Map.vue.d.ts +84 -0
- package/dist/runtime/components/Marker.d.vue.ts +54 -0
- package/dist/runtime/components/Marker.vue +86 -0
- package/dist/runtime/components/Marker.vue.d.ts +54 -0
- package/dist/runtime/components/Popup.d.vue.ts +30 -0
- package/dist/runtime/components/Popup.vue +33 -0
- package/dist/runtime/components/Popup.vue.d.ts +30 -0
- package/dist/runtime/components/Source.d.vue.ts +23 -0
- package/dist/runtime/components/Source.vue +44 -0
- package/dist/runtime/components/Source.vue.d.ts +23 -0
- package/dist/runtime/components/Tooltip.d.vue.ts +45 -0
- package/dist/runtime/components/Tooltip.vue +106 -0
- package/dist/runtime/components/Tooltip.vue.d.ts +45 -0
- package/dist/runtime/components/buffers/BufferCircle.d.vue.ts +27 -0
- package/dist/runtime/components/buffers/BufferCircle.vue +30 -0
- package/dist/runtime/components/buffers/BufferCircle.vue.d.ts +27 -0
- package/dist/runtime/components/buffers/BufferEllipse.d.vue.ts +35 -0
- package/dist/runtime/components/buffers/BufferEllipse.vue +36 -0
- package/dist/runtime/components/buffers/BufferEllipse.vue.d.ts +35 -0
- package/dist/runtime/components/buffers/BufferLine.d.vue.ts +21 -0
- package/dist/runtime/components/buffers/BufferLine.vue +40 -0
- package/dist/runtime/components/buffers/BufferLine.vue.d.ts +21 -0
- package/dist/runtime/components/buffers/BufferPolygon.d.vue.ts +21 -0
- package/dist/runtime/components/buffers/BufferPolygon.vue +40 -0
- package/dist/runtime/components/buffers/BufferPolygon.vue.d.ts +21 -0
- package/dist/runtime/components/buffers/BufferSector.d.vue.ts +31 -0
- package/dist/runtime/components/buffers/BufferSector.vue +35 -0
- package/dist/runtime/components/buffers/BufferSector.vue.d.ts +31 -0
- package/dist/runtime/components/controls/AttributionControl.d.vue.ts +24 -0
- package/dist/runtime/components/controls/AttributionControl.vue +18 -0
- package/dist/runtime/components/controls/AttributionControl.vue.d.ts +24 -0
- package/dist/runtime/components/controls/FullscreenControl.d.vue.ts +24 -0
- package/dist/runtime/components/controls/FullscreenControl.vue +18 -0
- package/dist/runtime/components/controls/FullscreenControl.vue.d.ts +24 -0
- package/dist/runtime/components/controls/GeolocateControl.d.vue.ts +24 -0
- package/dist/runtime/components/controls/GeolocateControl.vue +18 -0
- package/dist/runtime/components/controls/GeolocateControl.vue.d.ts +24 -0
- package/dist/runtime/components/controls/NavigationControl.d.vue.ts +24 -0
- package/dist/runtime/components/controls/NavigationControl.vue +18 -0
- package/dist/runtime/components/controls/NavigationControl.vue.d.ts +24 -0
- package/dist/runtime/components/controls/ScaleControl.d.vue.ts +24 -0
- package/dist/runtime/components/controls/ScaleControl.vue +18 -0
- package/dist/runtime/components/controls/ScaleControl.vue.d.ts +24 -0
- package/dist/runtime/components/effects/AnimatedImage.d.vue.ts +28 -0
- package/dist/runtime/components/effects/AnimatedImage.vue +50 -0
- package/dist/runtime/components/effects/AnimatedImage.vue.d.ts +28 -0
- package/dist/runtime/components/effects/DiffusionCircle.d.vue.ts +44 -0
- package/dist/runtime/components/effects/DiffusionCircle.vue +47 -0
- package/dist/runtime/components/effects/DiffusionCircle.vue.d.ts +44 -0
- package/dist/runtime/components/effects/FlowBuilding.d.vue.ts +53 -0
- package/dist/runtime/components/effects/FlowBuilding.vue +64 -0
- package/dist/runtime/components/effects/FlowBuilding.vue.d.ts +53 -0
- package/dist/runtime/components/effects/GlowCircle.d.vue.ts +44 -0
- package/dist/runtime/components/effects/GlowCircle.vue +42 -0
- package/dist/runtime/components/effects/GlowCircle.vue.d.ts +44 -0
- package/dist/runtime/components/effects/GradientBuilding.d.vue.ts +25 -0
- package/dist/runtime/components/effects/GradientBuilding.vue +37 -0
- package/dist/runtime/components/effects/GradientBuilding.vue.d.ts +25 -0
- package/dist/runtime/components/effects/Migration.d.vue.ts +50 -0
- package/dist/runtime/components/effects/Migration.vue +90 -0
- package/dist/runtime/components/effects/Migration.vue.d.ts +50 -0
- package/dist/runtime/components/effects/Radar.d.vue.ts +32 -0
- package/dist/runtime/components/effects/Radar.vue +49 -0
- package/dist/runtime/components/effects/Radar.vue.d.ts +32 -0
- package/dist/runtime/components/effects/SpriteImage.d.vue.ts +41 -0
- package/dist/runtime/components/effects/SpriteImage.vue +67 -0
- package/dist/runtime/components/effects/SpriteImage.vue.d.ts +41 -0
- package/dist/runtime/components/effects/TextureBuilding.d.vue.ts +25 -0
- package/dist/runtime/components/effects/TextureBuilding.vue +39 -0
- package/dist/runtime/components/effects/TextureBuilding.vue.d.ts +25 -0
- package/dist/runtime/components/effects/Trail.d.vue.ts +44 -0
- package/dist/runtime/components/effects/Trail.vue +61 -0
- package/dist/runtime/components/effects/Trail.vue.d.ts +44 -0
- package/dist/runtime/components/effects/WaveCircle.d.vue.ts +44 -0
- package/dist/runtime/components/effects/WaveCircle.vue +55 -0
- package/dist/runtime/components/effects/WaveCircle.vue.d.ts +44 -0
- package/dist/runtime/components/effects/WindowBuilding.d.vue.ts +53 -0
- package/dist/runtime/components/effects/WindowBuilding.vue +61 -0
- package/dist/runtime/components/effects/WindowBuilding.vue.d.ts +53 -0
- package/dist/runtime/components/environment/Sky.d.vue.ts +21 -0
- package/dist/runtime/components/environment/Sky.vue +15 -0
- package/dist/runtime/components/environment/Sky.vue.d.ts +21 -0
- package/dist/runtime/components/environment/Temperature.d.vue.ts +47 -0
- package/dist/runtime/components/environment/Temperature.vue +41 -0
- package/dist/runtime/components/environment/Temperature.vue.d.ts +47 -0
- package/dist/runtime/components/environment/Terrain.d.vue.ts +34 -0
- package/dist/runtime/components/environment/Terrain.vue +47 -0
- package/dist/runtime/components/environment/Terrain.vue.d.ts +34 -0
- package/dist/runtime/components/extensions/DrawControl.d.vue.ts +0 -0
- package/dist/runtime/components/extensions/DrawControl.vue +168 -0
- package/dist/runtime/components/extensions/DrawControl.vue.d.ts +0 -0
- package/dist/runtime/components/extensions/TiandituLayer.d.vue.ts +20 -0
- package/dist/runtime/components/extensions/TiandituLayer.vue +26 -0
- package/dist/runtime/components/extensions/TiandituLayer.vue.d.ts +20 -0
- package/dist/runtime/components/extensions/WmsLayer.d.vue.ts +50 -0
- package/dist/runtime/components/extensions/WmsLayer.vue +39 -0
- package/dist/runtime/components/extensions/WmsLayer.vue.d.ts +50 -0
- package/dist/runtime/components/extensions/WmtsLayer.d.vue.ts +42 -0
- package/dist/runtime/components/extensions/WmtsLayer.vue +37 -0
- package/dist/runtime/components/extensions/WmtsLayer.vue.d.ts +42 -0
- package/dist/runtime/components/layers/BuildingLayer.d.vue.ts +28 -0
- package/dist/runtime/components/layers/BuildingLayer.vue +41 -0
- package/dist/runtime/components/layers/BuildingLayer.vue.d.ts +28 -0
- package/dist/runtime/components/layers/ClusterLayer.d.vue.ts +55 -0
- package/dist/runtime/components/layers/ClusterLayer.vue +86 -0
- package/dist/runtime/components/layers/ClusterLayer.vue.d.ts +55 -0
- package/dist/runtime/components/layers/ImageLayer.d.vue.ts +21 -0
- package/dist/runtime/components/layers/ImageLayer.vue +25 -0
- package/dist/runtime/components/layers/ImageLayer.vue.d.ts +21 -0
- package/dist/runtime/components/layers/RasterLayer.d.vue.ts +35 -0
- package/dist/runtime/components/layers/RasterLayer.vue +34 -0
- package/dist/runtime/components/layers/RasterLayer.vue.d.ts +35 -0
- package/dist/runtime/components/layers/VideoLayer.d.vue.ts +28 -0
- package/dist/runtime/components/layers/VideoLayer.vue +38 -0
- package/dist/runtime/components/layers/VideoLayer.vue.d.ts +28 -0
- package/dist/runtime/composables/defineMaplibreControl.d.ts +3 -0
- package/dist/runtime/composables/defineMaplibreControl.js +6 -0
- package/dist/runtime/composables/useFeatureState.d.ts +35 -0
- package/dist/runtime/composables/useFeatureState.js +76 -0
- package/dist/runtime/composables/useFrameIcon.d.ts +17 -0
- package/dist/runtime/composables/useFrameIcon.js +36 -0
- package/dist/runtime/composables/useMap.d.ts +3 -0
- package/dist/runtime/composables/useMap.js +9 -0
- package/dist/runtime/composables/useMapAnimation.d.ts +21 -0
- package/dist/runtime/composables/useMapAnimation.js +13 -0
- package/dist/runtime/composables/useMapExport.d.ts +34 -0
- package/dist/runtime/composables/useMapExport.js +35 -0
- package/dist/runtime/composables/useMaplibre.d.ts +6 -0
- package/dist/runtime/composables/useMaplibre.js +4 -0
- package/dist/runtime/composables/useMaplibreCamera.d.ts +15 -0
- package/dist/runtime/composables/useMaplibreCamera.js +32 -0
- package/dist/runtime/composables/useMaplibreDraw.d.ts +10 -0
- package/dist/runtime/composables/useMaplibreDraw.js +34 -0
- package/dist/runtime/composables/useMaplibreImage.d.ts +19 -0
- package/dist/runtime/composables/useMaplibreImage.js +33 -0
- package/dist/runtime/composables/useMeasure.d.ts +25 -0
- package/dist/runtime/composables/useMeasure.js +173 -0
- package/dist/runtime/domains/map/config.d.ts +7 -0
- package/dist/runtime/domains/map/config.js +13 -0
- package/dist/runtime/domains/map/context.d.ts +13 -0
- package/dist/runtime/domains/map/context.js +51 -0
- package/dist/runtime/domains/map/control.d.ts +4 -0
- package/dist/runtime/domains/map/control.js +28 -0
- package/dist/runtime/domains/map/create-map.d.ts +3 -0
- package/dist/runtime/domains/map/create-map.js +21 -0
- package/dist/runtime/domains/map/draw-context.d.ts +26 -0
- package/dist/runtime/domains/map/draw-context.js +73 -0
- package/dist/runtime/domains/map/draw-registry.d.ts +5 -0
- package/dist/runtime/domains/map/draw-registry.js +15 -0
- package/dist/runtime/domains/map/draw-toolbar.d.ts +15 -0
- package/dist/runtime/domains/map/draw-toolbar.js +52 -0
- package/dist/runtime/domains/map/draw.d.ts +4 -0
- package/dist/runtime/domains/map/draw.js +1 -0
- package/dist/runtime/domains/map/layer-group.d.ts +9 -0
- package/dist/runtime/domains/map/layer-group.js +1 -0
- package/dist/runtime/domains/map/registry.d.ts +4 -0
- package/dist/runtime/domains/map/registry.js +10 -0
- package/dist/runtime/domains/map/resolve.d.ts +7 -0
- package/dist/runtime/domains/map/resolve.js +7 -0
- package/dist/runtime/domains/map/style-effect.d.ts +6 -0
- package/dist/runtime/domains/map/style-effect.js +21 -0
- package/dist/runtime/draw-modes/index.d.ts +16 -0
- package/dist/runtime/draw-modes/index.js +32 -0
- package/dist/runtime/index.css +1 -0
- package/dist/runtime/plugins/config.d.ts +2 -0
- package/dist/runtime/plugins/config.js +6 -0
- package/dist/runtime/types/draw.d.ts +30 -0
- package/dist/runtime/types/draw.js +0 -0
- package/dist/runtime/types/index.d.ts +3 -0
- package/dist/runtime/types/index.js +0 -0
- package/dist/runtime/types/map.d.ts +45 -0
- package/dist/runtime/types/map.js +0 -0
- package/dist/runtime/types/tianditu.d.ts +247 -0
- package/dist/runtime/types/tianditu.js +0 -0
- package/dist/runtime/utils/animated-image.d.ts +13 -0
- package/dist/runtime/utils/animated-image.js +47 -0
- package/dist/runtime/utils/buffer.d.ts +24 -0
- package/dist/runtime/utils/buffer.js +13 -0
- package/dist/runtime/utils/building-effects.d.ts +73 -0
- package/dist/runtime/utils/building-effects.js +50 -0
- package/dist/runtime/utils/building.d.ts +53 -0
- package/dist/runtime/utils/building.js +26 -0
- package/dist/runtime/utils/cluster.d.ts +24 -0
- package/dist/runtime/utils/cluster.js +42 -0
- package/dist/runtime/utils/coordinate.d.ts +12 -0
- package/dist/runtime/utils/coordinate.js +44 -0
- package/dist/runtime/utils/draw-theme.d.ts +47 -0
- package/dist/runtime/utils/draw-theme.js +39 -0
- package/dist/runtime/utils/effects.d.ts +34 -0
- package/dist/runtime/utils/effects.js +78 -0
- package/dist/runtime/utils/events.d.ts +6 -0
- package/dist/runtime/utils/events.js +20 -0
- package/dist/runtime/utils/frame-icon.d.ts +27 -0
- package/dist/runtime/utils/frame-icon.js +45 -0
- package/dist/runtime/utils/geometry.d.ts +5 -0
- package/dist/runtime/utils/geometry.js +41 -0
- package/dist/runtime/utils/heatmap.d.ts +36 -0
- package/dist/runtime/utils/heatmap.js +30 -0
- package/dist/runtime/utils/layer.d.ts +13 -0
- package/dist/runtime/utils/layer.js +17 -0
- package/dist/runtime/utils/logger.d.ts +2 -0
- package/dist/runtime/utils/logger.js +2 -0
- package/dist/runtime/utils/measure.d.ts +4 -0
- package/dist/runtime/utils/measure.js +8 -0
- package/dist/runtime/utils/sprite.d.ts +31 -0
- package/dist/runtime/utils/sprite.js +23 -0
- package/dist/runtime/utils/tianditu-administrative.d.ts +3 -0
- package/dist/runtime/utils/tianditu-administrative.js +48 -0
- package/dist/runtime/utils/tianditu-client.d.ts +30 -0
- package/dist/runtime/utils/tianditu-client.js +17 -0
- package/dist/runtime/utils/tianditu-geocoder.d.ts +5 -0
- package/dist/runtime/utils/tianditu-geocoder.js +37 -0
- package/dist/runtime/utils/tianditu-request.d.ts +20 -0
- package/dist/runtime/utils/tianditu-request.js +42 -0
- package/dist/runtime/utils/tianditu-route.d.ts +3 -0
- package/dist/runtime/utils/tianditu-route.js +40 -0
- package/dist/runtime/utils/tianditu-search.d.ts +15 -0
- package/dist/runtime/utils/tianditu-search.js +183 -0
- package/dist/runtime/utils/tianditu.d.ts +21 -0
- package/dist/runtime/utils/tianditu.js +26 -0
- package/dist/runtime/utils/wms.d.ts +43 -0
- package/dist/runtime/utils/wms.js +30 -0
- package/dist/runtime/utils/wmts.d.ts +35 -0
- package/dist/runtime/utils/wmts.js +29 -0
- package/dist/types.d.mts +5 -0
- package/dist/unplugin.d.mts +30 -0
- package/dist/unplugin.d.ts +30 -0
- package/dist/unplugin.mjs +53 -0
- package/dist/vite.d.mts +7 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.mjs +11 -0
- package/dist/vue-plugin.d.mts +9 -0
- package/dist/vue-plugin.d.ts +9 -0
- package/dist/vue-plugin.mjs +9 -0
- package/package.json +174 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useId } from "vue";
|
|
3
|
+
import { buildingGradientPaint } from "../../utils/building-effects";
|
|
4
|
+
import { useMapAnimation } from "../../composables/useMapAnimation";
|
|
5
|
+
import { DEFAULT_HEIGHT_PROPERTY } from "../../utils/building";
|
|
6
|
+
import MaplibreBuildingLayer from "../layers/BuildingLayer.vue";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
source: { type: String, required: true },
|
|
9
|
+
sourceLayer: { type: String, required: false },
|
|
10
|
+
heightProperty: { type: String, required: false },
|
|
11
|
+
baseProperty: { type: String, required: false },
|
|
12
|
+
layerId: { type: String, required: false },
|
|
13
|
+
color: { type: String, required: false, default: "#1e3a8a" },
|
|
14
|
+
flowColor: { type: String, required: false, default: "#67e8f9" },
|
|
15
|
+
duration: { type: Number, required: false, default: 3e3 },
|
|
16
|
+
bandHeight: { type: Number, required: false, default: 60 },
|
|
17
|
+
maxHeight: { type: Number, required: false, default: 300 },
|
|
18
|
+
opacity: { type: Number, required: false },
|
|
19
|
+
minzoom: { type: Number, required: false, default: 15 },
|
|
20
|
+
beforeId: { type: String, required: false }
|
|
21
|
+
});
|
|
22
|
+
const id = props.layerId ?? `movk-flow-building-${useId()}`;
|
|
23
|
+
const initialPaint = computed(() => buildingGradientPaint({
|
|
24
|
+
stops: [[0, props.color], [props.maxHeight, props.color]],
|
|
25
|
+
opacity: props.opacity,
|
|
26
|
+
minzoom: props.minzoom,
|
|
27
|
+
heightProperty: props.heightProperty,
|
|
28
|
+
baseProperty: props.baseProperty
|
|
29
|
+
}));
|
|
30
|
+
useMapAnimation((map, elapsed) => {
|
|
31
|
+
if (!map.getLayer(id)) return;
|
|
32
|
+
const center = elapsed % props.duration / props.duration * props.maxHeight;
|
|
33
|
+
const lo = Math.max(center - props.bandHeight / 2, 0);
|
|
34
|
+
const hi = center + props.bandHeight / 2;
|
|
35
|
+
map.setPaintProperty(id, "fill-extrusion-color", [
|
|
36
|
+
"interpolate",
|
|
37
|
+
["linear"],
|
|
38
|
+
["get", props.heightProperty ?? DEFAULT_HEIGHT_PROPERTY],
|
|
39
|
+
Math.max(lo - 1, 0),
|
|
40
|
+
props.color,
|
|
41
|
+
lo,
|
|
42
|
+
props.color,
|
|
43
|
+
center,
|
|
44
|
+
props.flowColor,
|
|
45
|
+
hi,
|
|
46
|
+
props.color,
|
|
47
|
+
hi + 1,
|
|
48
|
+
props.color
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<MaplibreBuildingLayer
|
|
55
|
+
:layer-id="id"
|
|
56
|
+
:source="source"
|
|
57
|
+
:source-layer="sourceLayer"
|
|
58
|
+
:height-property="heightProperty"
|
|
59
|
+
:base-property="baseProperty"
|
|
60
|
+
:minzoom="minzoom"
|
|
61
|
+
:paint="initialPaint"
|
|
62
|
+
:before-id="beforeId"
|
|
63
|
+
/>
|
|
64
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BuildingSourceOptions } from '../../utils/building';
|
|
2
|
+
/** 流动建筑:渐变着色 + 高亮带沿建筑高度循环流动。 */
|
|
3
|
+
type __VLS_Props = BuildingSourceOptions & {
|
|
4
|
+
/** 图层 id;省略时自动生成 */
|
|
5
|
+
layerId?: string;
|
|
6
|
+
/**
|
|
7
|
+
* 基色
|
|
8
|
+
* @defaultValue '#1e3a8a'
|
|
9
|
+
*/
|
|
10
|
+
color?: string;
|
|
11
|
+
/**
|
|
12
|
+
* 流动高亮色
|
|
13
|
+
* @defaultValue '#67e8f9'
|
|
14
|
+
*/
|
|
15
|
+
flowColor?: string;
|
|
16
|
+
/**
|
|
17
|
+
* 流动周期(毫秒)
|
|
18
|
+
* @defaultValue 3000
|
|
19
|
+
*/
|
|
20
|
+
duration?: number;
|
|
21
|
+
/**
|
|
22
|
+
* 高亮带覆盖的高度范围(米)
|
|
23
|
+
* @defaultValue 60
|
|
24
|
+
*/
|
|
25
|
+
bandHeight?: number;
|
|
26
|
+
/**
|
|
27
|
+
* 建筑最大参考高度(米)
|
|
28
|
+
* @defaultValue 300
|
|
29
|
+
*/
|
|
30
|
+
maxHeight?: number;
|
|
31
|
+
/**
|
|
32
|
+
* 整体透明度
|
|
33
|
+
* @defaultValue 0.85
|
|
34
|
+
*/
|
|
35
|
+
opacity?: number;
|
|
36
|
+
/**
|
|
37
|
+
* 最小缩放级别
|
|
38
|
+
* @defaultValue 15
|
|
39
|
+
*/
|
|
40
|
+
minzoom?: number;
|
|
41
|
+
/** 插入到该图层之前 */
|
|
42
|
+
beforeId?: string;
|
|
43
|
+
};
|
|
44
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
45
|
+
minzoom: number;
|
|
46
|
+
color: string;
|
|
47
|
+
duration: number;
|
|
48
|
+
flowColor: string;
|
|
49
|
+
bandHeight: number;
|
|
50
|
+
maxHeight: number;
|
|
51
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
52
|
+
declare const _default: typeof __VLS_export;
|
|
53
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { GeoJSONSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
+
/** 炫光圆:实心内核 + 模糊光晕,可选呼吸脉冲。 */
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** 点要素数据(GeoJSON 或其 URL) */
|
|
5
|
+
data: GeoJSONSourceSpecification['data'];
|
|
6
|
+
/** 图层 id 前缀;省略时自动生成 */
|
|
7
|
+
layerId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 主色
|
|
10
|
+
* @defaultValue '#f59e0b'
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 内核半径(像素)
|
|
15
|
+
* @defaultValue 6
|
|
16
|
+
*/
|
|
17
|
+
radius?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 光晕半径倍数
|
|
20
|
+
* @defaultValue 3
|
|
21
|
+
*/
|
|
22
|
+
glowScale?: number;
|
|
23
|
+
/**
|
|
24
|
+
* 呼吸脉冲(光晕半径 ±25% 正弦摆动)
|
|
25
|
+
* @defaultValue false
|
|
26
|
+
*/
|
|
27
|
+
pulse?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 脉冲周期(毫秒)
|
|
30
|
+
* @defaultValue 2000
|
|
31
|
+
*/
|
|
32
|
+
duration?: number;
|
|
33
|
+
/** 插入到该图层之前 */
|
|
34
|
+
beforeId?: string;
|
|
35
|
+
};
|
|
36
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
37
|
+
color: string;
|
|
38
|
+
radius: number;
|
|
39
|
+
duration: number;
|
|
40
|
+
glowScale: number;
|
|
41
|
+
pulse: boolean;
|
|
42
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const _default: typeof __VLS_export;
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useId } from "vue";
|
|
3
|
+
import { useMapAnimation } from "../../composables/useMapAnimation";
|
|
4
|
+
import MaplibreSource from "../Source.vue";
|
|
5
|
+
import MaplibreLayer from "../Layer.vue";
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
data: { type: null, required: true },
|
|
8
|
+
layerId: { type: String, required: false },
|
|
9
|
+
color: { type: String, required: false, default: "#f59e0b" },
|
|
10
|
+
radius: { type: Number, required: false, default: 6 },
|
|
11
|
+
glowScale: { type: Number, required: false, default: 3 },
|
|
12
|
+
pulse: { type: Boolean, required: false, default: false },
|
|
13
|
+
duration: { type: Number, required: false, default: 2e3 },
|
|
14
|
+
beforeId: { type: String, required: false }
|
|
15
|
+
});
|
|
16
|
+
const id = props.layerId ?? `movk-glow-${useId()}`;
|
|
17
|
+
const source = computed(() => ({ type: "geojson", data: props.data }));
|
|
18
|
+
const glowRadius = computed(() => props.radius * props.glowScale);
|
|
19
|
+
const glowPaint = computed(() => ({
|
|
20
|
+
"circle-color": props.color,
|
|
21
|
+
"circle-radius": glowRadius.value,
|
|
22
|
+
"circle-blur": 1,
|
|
23
|
+
"circle-opacity": 0.7
|
|
24
|
+
}));
|
|
25
|
+
const corePaint = computed(() => ({
|
|
26
|
+
"circle-color": props.color,
|
|
27
|
+
"circle-radius": props.radius
|
|
28
|
+
}));
|
|
29
|
+
useMapAnimation((map, elapsed) => {
|
|
30
|
+
const layerId = `${id}-glow`;
|
|
31
|
+
if (!map.getLayer(layerId)) return;
|
|
32
|
+
const wave = Math.sin(elapsed / props.duration * Math.PI * 2);
|
|
33
|
+
map.setPaintProperty(layerId, "circle-radius", glowRadius.value * (1 + wave * 0.25));
|
|
34
|
+
}, { immediate: props.pulse });
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<MaplibreSource :source-id="id" :source="source">
|
|
39
|
+
<MaplibreLayer :layer-id="`${id}-glow`" type="circle" :source="id" :paint="glowPaint" :before-id="beforeId" />
|
|
40
|
+
<MaplibreLayer :layer-id="`${id}-core`" type="circle" :source="id" :paint="corePaint" :before-id="beforeId" />
|
|
41
|
+
</MaplibreSource>
|
|
42
|
+
</template>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { GeoJSONSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
+
/** 炫光圆:实心内核 + 模糊光晕,可选呼吸脉冲。 */
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** 点要素数据(GeoJSON 或其 URL) */
|
|
5
|
+
data: GeoJSONSourceSpecification['data'];
|
|
6
|
+
/** 图层 id 前缀;省略时自动生成 */
|
|
7
|
+
layerId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 主色
|
|
10
|
+
* @defaultValue '#f59e0b'
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 内核半径(像素)
|
|
15
|
+
* @defaultValue 6
|
|
16
|
+
*/
|
|
17
|
+
radius?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 光晕半径倍数
|
|
20
|
+
* @defaultValue 3
|
|
21
|
+
*/
|
|
22
|
+
glowScale?: number;
|
|
23
|
+
/**
|
|
24
|
+
* 呼吸脉冲(光晕半径 ±25% 正弦摆动)
|
|
25
|
+
* @defaultValue false
|
|
26
|
+
*/
|
|
27
|
+
pulse?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 脉冲周期(毫秒)
|
|
30
|
+
* @defaultValue 2000
|
|
31
|
+
*/
|
|
32
|
+
duration?: number;
|
|
33
|
+
/** 插入到该图层之前 */
|
|
34
|
+
beforeId?: string;
|
|
35
|
+
};
|
|
36
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
37
|
+
color: string;
|
|
38
|
+
radius: number;
|
|
39
|
+
duration: number;
|
|
40
|
+
glowScale: number;
|
|
41
|
+
pulse: boolean;
|
|
42
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const _default: typeof __VLS_export;
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BuildingSourceOptions } from '../../utils/building';
|
|
2
|
+
/** 渐变建筑:按高度插值着色的 3D 建筑。 */
|
|
3
|
+
type __VLS_Props = BuildingSourceOptions & {
|
|
4
|
+
/** 图层 id;省略时自动生成 */
|
|
5
|
+
layerId?: string;
|
|
6
|
+
/** 高度-颜色断点 */
|
|
7
|
+
stops?: [number, string][];
|
|
8
|
+
/**
|
|
9
|
+
* 整体透明度
|
|
10
|
+
* @defaultValue 0.85
|
|
11
|
+
*/
|
|
12
|
+
opacity?: number;
|
|
13
|
+
/**
|
|
14
|
+
* 最小缩放级别
|
|
15
|
+
* @defaultValue 15
|
|
16
|
+
*/
|
|
17
|
+
minzoom?: number;
|
|
18
|
+
/** 插入到该图层之前 */
|
|
19
|
+
beforeId?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
22
|
+
minzoom: number;
|
|
23
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useId } from "vue";
|
|
3
|
+
import { buildingGradientPaint } from "../../utils/building-effects";
|
|
4
|
+
import MaplibreBuildingLayer from "../layers/BuildingLayer.vue";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
source: { type: String, required: true },
|
|
7
|
+
sourceLayer: { type: String, required: false },
|
|
8
|
+
heightProperty: { type: String, required: false },
|
|
9
|
+
baseProperty: { type: String, required: false },
|
|
10
|
+
layerId: { type: String, required: false },
|
|
11
|
+
stops: { type: Array, required: false },
|
|
12
|
+
opacity: { type: Number, required: false },
|
|
13
|
+
minzoom: { type: Number, required: false, default: 15 },
|
|
14
|
+
beforeId: { type: String, required: false }
|
|
15
|
+
});
|
|
16
|
+
const id = props.layerId ?? `movk-gradient-building-${useId()}`;
|
|
17
|
+
const paint = computed(() => buildingGradientPaint({
|
|
18
|
+
stops: props.stops,
|
|
19
|
+
opacity: props.opacity,
|
|
20
|
+
minzoom: props.minzoom,
|
|
21
|
+
heightProperty: props.heightProperty,
|
|
22
|
+
baseProperty: props.baseProperty
|
|
23
|
+
}));
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<MaplibreBuildingLayer
|
|
28
|
+
:layer-id="id"
|
|
29
|
+
:source="source"
|
|
30
|
+
:source-layer="sourceLayer"
|
|
31
|
+
:height-property="heightProperty"
|
|
32
|
+
:base-property="baseProperty"
|
|
33
|
+
:minzoom="minzoom"
|
|
34
|
+
:paint="paint"
|
|
35
|
+
:before-id="beforeId"
|
|
36
|
+
/>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BuildingSourceOptions } from '../../utils/building';
|
|
2
|
+
/** 渐变建筑:按高度插值着色的 3D 建筑。 */
|
|
3
|
+
type __VLS_Props = BuildingSourceOptions & {
|
|
4
|
+
/** 图层 id;省略时自动生成 */
|
|
5
|
+
layerId?: string;
|
|
6
|
+
/** 高度-颜色断点 */
|
|
7
|
+
stops?: [number, string][];
|
|
8
|
+
/**
|
|
9
|
+
* 整体透明度
|
|
10
|
+
* @defaultValue 0.85
|
|
11
|
+
*/
|
|
12
|
+
opacity?: number;
|
|
13
|
+
/**
|
|
14
|
+
* 最小缩放级别
|
|
15
|
+
* @defaultValue 15
|
|
16
|
+
*/
|
|
17
|
+
minzoom?: number;
|
|
18
|
+
/** 插入到该图层之前 */
|
|
19
|
+
beforeId?: string;
|
|
20
|
+
};
|
|
21
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
22
|
+
minzoom: number;
|
|
23
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Position2D } from '../../utils/effects';
|
|
2
|
+
export interface MigrationRoute {
|
|
3
|
+
from: Position2D;
|
|
4
|
+
to: Position2D;
|
|
5
|
+
/** 透传到弧线与粒子要素的属性 */
|
|
6
|
+
properties?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
/** 迁徙图:OD 对生成贝塞尔弧线,粒子沿线循环飞行 + 渐变尾迹。 */
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
/** 起讫点对列表 */
|
|
11
|
+
data: MigrationRoute[];
|
|
12
|
+
/** 图层 id 前缀;省略时自动生成 */
|
|
13
|
+
layerId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 主色
|
|
16
|
+
* @defaultValue '#f43f5e'
|
|
17
|
+
*/
|
|
18
|
+
color?: string;
|
|
19
|
+
/**
|
|
20
|
+
* 弧线弯曲程度
|
|
21
|
+
* @defaultValue 0.3
|
|
22
|
+
*/
|
|
23
|
+
curvature?: number;
|
|
24
|
+
/**
|
|
25
|
+
* 单程飞行周期(毫秒)
|
|
26
|
+
* @defaultValue 3000
|
|
27
|
+
*/
|
|
28
|
+
duration?: number;
|
|
29
|
+
/**
|
|
30
|
+
* 线宽(像素)
|
|
31
|
+
* @defaultValue 2
|
|
32
|
+
*/
|
|
33
|
+
lineWidth?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 粒子半径(像素)
|
|
36
|
+
* @defaultValue 4
|
|
37
|
+
*/
|
|
38
|
+
particleRadius?: number;
|
|
39
|
+
/** 插入到该图层之前 */
|
|
40
|
+
beforeId?: string;
|
|
41
|
+
};
|
|
42
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
43
|
+
color: string;
|
|
44
|
+
duration: number;
|
|
45
|
+
curvature: number;
|
|
46
|
+
lineWidth: number;
|
|
47
|
+
particleRadius: number;
|
|
48
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
49
|
+
declare const _default: typeof __VLS_export;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, useId } from "vue";
|
|
3
|
+
import { arcLine, createLineSampler } from "../../utils/effects";
|
|
4
|
+
import { useMapAnimation } from "../../composables/useMapAnimation";
|
|
5
|
+
import MaplibreSource from "../Source.vue";
|
|
6
|
+
import MaplibreLayer from "../Layer.vue";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
data: { type: Array, required: true },
|
|
9
|
+
layerId: { type: String, required: false },
|
|
10
|
+
color: { type: String, required: false, default: "#f43f5e" },
|
|
11
|
+
curvature: { type: Number, required: false, default: 0.3 },
|
|
12
|
+
duration: { type: Number, required: false, default: 3e3 },
|
|
13
|
+
lineWidth: { type: Number, required: false, default: 2 },
|
|
14
|
+
particleRadius: { type: Number, required: false, default: 4 },
|
|
15
|
+
beforeId: { type: String, required: false }
|
|
16
|
+
});
|
|
17
|
+
const id = props.layerId ?? `movk-migration-${useId()}`;
|
|
18
|
+
const linesId = `${id}-lines`;
|
|
19
|
+
const particlesId = `${id}-particles`;
|
|
20
|
+
const arcs = computed(() => props.data.map((route) => ({
|
|
21
|
+
coords: arcLine(route.from, route.to, { curvature: props.curvature }),
|
|
22
|
+
properties: route.properties ?? {}
|
|
23
|
+
})));
|
|
24
|
+
const samplers = computed(() => arcs.value.map((arc) => createLineSampler(arc.coords)));
|
|
25
|
+
const linesSource = computed(() => ({
|
|
26
|
+
type: "geojson",
|
|
27
|
+
lineMetrics: true,
|
|
28
|
+
data: {
|
|
29
|
+
type: "FeatureCollection",
|
|
30
|
+
features: arcs.value.map((arc) => ({
|
|
31
|
+
type: "Feature",
|
|
32
|
+
properties: arc.properties,
|
|
33
|
+
geometry: { type: "LineString", coordinates: arc.coords }
|
|
34
|
+
}))
|
|
35
|
+
}
|
|
36
|
+
}));
|
|
37
|
+
const particlesSource = {
|
|
38
|
+
type: "geojson",
|
|
39
|
+
data: { type: "FeatureCollection", features: [] }
|
|
40
|
+
};
|
|
41
|
+
const linePaint = computed(() => ({
|
|
42
|
+
"line-width": props.lineWidth,
|
|
43
|
+
"line-gradient": [
|
|
44
|
+
"interpolate",
|
|
45
|
+
["linear"],
|
|
46
|
+
["line-progress"],
|
|
47
|
+
0,
|
|
48
|
+
"rgba(0, 0, 0, 0)",
|
|
49
|
+
1,
|
|
50
|
+
props.color
|
|
51
|
+
]
|
|
52
|
+
}));
|
|
53
|
+
const lineLayout = { "line-cap": "round", "line-join": "round" };
|
|
54
|
+
const particlePaint = computed(() => ({
|
|
55
|
+
"circle-color": "#ffffff",
|
|
56
|
+
"circle-radius": props.particleRadius,
|
|
57
|
+
"circle-stroke-color": props.color,
|
|
58
|
+
"circle-stroke-width": 2
|
|
59
|
+
}));
|
|
60
|
+
useMapAnimation((map, elapsed) => {
|
|
61
|
+
const source = map.getSource(particlesId);
|
|
62
|
+
if (!source) return;
|
|
63
|
+
const base = elapsed % props.duration / props.duration;
|
|
64
|
+
const features = samplers.value.map((sample, index) => {
|
|
65
|
+
const t = (base + index / Math.max(samplers.value.length, 1)) % 1;
|
|
66
|
+
return {
|
|
67
|
+
type: "Feature",
|
|
68
|
+
properties: arcs.value[index].properties,
|
|
69
|
+
geometry: { type: "Point", coordinates: sample(t) }
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
source.setData({ type: "FeatureCollection", features });
|
|
73
|
+
});
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<MaplibreSource :source-id="linesId" :source="linesSource">
|
|
78
|
+
<MaplibreLayer
|
|
79
|
+
:layer-id="linesId"
|
|
80
|
+
type="line"
|
|
81
|
+
:source="linesId"
|
|
82
|
+
:layout="lineLayout"
|
|
83
|
+
:paint="linePaint"
|
|
84
|
+
:before-id="beforeId"
|
|
85
|
+
/>
|
|
86
|
+
</MaplibreSource>
|
|
87
|
+
<MaplibreSource :source-id="particlesId" :source="particlesSource">
|
|
88
|
+
<MaplibreLayer :layer-id="particlesId" type="circle" :source="particlesId" :paint="particlePaint" :before-id="beforeId" />
|
|
89
|
+
</MaplibreSource>
|
|
90
|
+
</template>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type Position2D } from '../../utils/effects';
|
|
2
|
+
export interface MigrationRoute {
|
|
3
|
+
from: Position2D;
|
|
4
|
+
to: Position2D;
|
|
5
|
+
/** 透传到弧线与粒子要素的属性 */
|
|
6
|
+
properties?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
/** 迁徙图:OD 对生成贝塞尔弧线,粒子沿线循环飞行 + 渐变尾迹。 */
|
|
9
|
+
type __VLS_Props = {
|
|
10
|
+
/** 起讫点对列表 */
|
|
11
|
+
data: MigrationRoute[];
|
|
12
|
+
/** 图层 id 前缀;省略时自动生成 */
|
|
13
|
+
layerId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* 主色
|
|
16
|
+
* @defaultValue '#f43f5e'
|
|
17
|
+
*/
|
|
18
|
+
color?: string;
|
|
19
|
+
/**
|
|
20
|
+
* 弧线弯曲程度
|
|
21
|
+
* @defaultValue 0.3
|
|
22
|
+
*/
|
|
23
|
+
curvature?: number;
|
|
24
|
+
/**
|
|
25
|
+
* 单程飞行周期(毫秒)
|
|
26
|
+
* @defaultValue 3000
|
|
27
|
+
*/
|
|
28
|
+
duration?: number;
|
|
29
|
+
/**
|
|
30
|
+
* 线宽(像素)
|
|
31
|
+
* @defaultValue 2
|
|
32
|
+
*/
|
|
33
|
+
lineWidth?: number;
|
|
34
|
+
/**
|
|
35
|
+
* 粒子半径(像素)
|
|
36
|
+
* @defaultValue 4
|
|
37
|
+
*/
|
|
38
|
+
particleRadius?: number;
|
|
39
|
+
/** 插入到该图层之前 */
|
|
40
|
+
beforeId?: string;
|
|
41
|
+
};
|
|
42
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
43
|
+
color: string;
|
|
44
|
+
duration: number;
|
|
45
|
+
curvature: number;
|
|
46
|
+
lineWidth: number;
|
|
47
|
+
particleRadius: number;
|
|
48
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
49
|
+
declare const _default: typeof __VLS_export;
|
|
50
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GeoJSONSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
+
/** 雷达:canvas 生成扇形扫描贴图,symbol 图层按帧旋转。 */
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** 点要素数据(GeoJSON 或其 URL) */
|
|
5
|
+
data: GeoJSONSourceSpecification['data'];
|
|
6
|
+
/** 图层 id 前缀;省略时自动生成 */
|
|
7
|
+
layerId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 主色
|
|
10
|
+
* @defaultValue '#22c55e'
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 扫描半径(像素)
|
|
15
|
+
* @defaultValue 60
|
|
16
|
+
*/
|
|
17
|
+
radius?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 旋转速度(度/秒)
|
|
20
|
+
* @defaultValue 120
|
|
21
|
+
*/
|
|
22
|
+
speed?: number;
|
|
23
|
+
/** 插入到该图层之前 */
|
|
24
|
+
beforeId?: string;
|
|
25
|
+
};
|
|
26
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
27
|
+
color: string;
|
|
28
|
+
speed: number;
|
|
29
|
+
radius: number;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, onUnmounted, useId } from "vue";
|
|
3
|
+
import { radarSweepImage } from "../../utils/effects";
|
|
4
|
+
import { useMap } from "../../composables/useMap";
|
|
5
|
+
import { useMapAnimation } from "../../composables/useMapAnimation";
|
|
6
|
+
import MaplibreSource from "../Source.vue";
|
|
7
|
+
import MaplibreLayer from "../Layer.vue";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
data: { type: null, required: true },
|
|
10
|
+
layerId: { type: String, required: false },
|
|
11
|
+
color: { type: String, required: false, default: "#22c55e" },
|
|
12
|
+
radius: { type: Number, required: false, default: 60 },
|
|
13
|
+
speed: { type: Number, required: false, default: 120 },
|
|
14
|
+
beforeId: { type: String, required: false }
|
|
15
|
+
});
|
|
16
|
+
const IMAGE_SIZE = 256;
|
|
17
|
+
const ctx = useMap();
|
|
18
|
+
const id = props.layerId ?? `movk-radar-${useId()}`;
|
|
19
|
+
const imageName = `${id}-sweep`;
|
|
20
|
+
const source = computed(() => ({ type: "geojson", data: props.data }));
|
|
21
|
+
const layout = computed(() => ({
|
|
22
|
+
"icon-image": imageName,
|
|
23
|
+
"icon-size": props.radius * 2 / IMAGE_SIZE,
|
|
24
|
+
"icon-allow-overlap": true,
|
|
25
|
+
"icon-ignore-placement": true,
|
|
26
|
+
// 贴图随地图旋转而非屏幕,扫描方位与地理方向一致
|
|
27
|
+
"icon-rotation-alignment": "map"
|
|
28
|
+
}));
|
|
29
|
+
const stopReady = ctx.onReady((map) => {
|
|
30
|
+
if (map.hasImage(imageName)) return;
|
|
31
|
+
const image = radarSweepImage(IMAGE_SIZE, props.color);
|
|
32
|
+
if (image) map.addImage(imageName, image);
|
|
33
|
+
});
|
|
34
|
+
useMapAnimation((map, elapsed) => {
|
|
35
|
+
if (!map.getLayer(id)) return;
|
|
36
|
+
map.setLayoutProperty(id, "icon-rotate", elapsed / 1e3 * props.speed % 360);
|
|
37
|
+
});
|
|
38
|
+
onUnmounted(() => {
|
|
39
|
+
stopReady();
|
|
40
|
+
const map = ctx.map.value;
|
|
41
|
+
if (map?.hasImage(imageName)) map.removeImage(imageName);
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<MaplibreSource :source-id="id" :source="source">
|
|
47
|
+
<MaplibreLayer :layer-id="id" type="symbol" :source="id" :layout="layout" :before-id="beforeId" />
|
|
48
|
+
</MaplibreSource>
|
|
49
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GeoJSONSourceSpecification } from '@maplibre/maplibre-gl-style-spec';
|
|
2
|
+
/** 雷达:canvas 生成扇形扫描贴图,symbol 图层按帧旋转。 */
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** 点要素数据(GeoJSON 或其 URL) */
|
|
5
|
+
data: GeoJSONSourceSpecification['data'];
|
|
6
|
+
/** 图层 id 前缀;省略时自动生成 */
|
|
7
|
+
layerId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 主色
|
|
10
|
+
* @defaultValue '#22c55e'
|
|
11
|
+
*/
|
|
12
|
+
color?: string;
|
|
13
|
+
/**
|
|
14
|
+
* 扫描半径(像素)
|
|
15
|
+
* @defaultValue 60
|
|
16
|
+
*/
|
|
17
|
+
radius?: number;
|
|
18
|
+
/**
|
|
19
|
+
* 旋转速度(度/秒)
|
|
20
|
+
* @defaultValue 120
|
|
21
|
+
*/
|
|
22
|
+
speed?: number;
|
|
23
|
+
/** 插入到该图层之前 */
|
|
24
|
+
beforeId?: string;
|
|
25
|
+
};
|
|
26
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
27
|
+
color: string;
|
|
28
|
+
speed: number;
|
|
29
|
+
radius: number;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
declare const _default: typeof __VLS_export;
|
|
32
|
+
export default _default;
|