@nuxt/scripts 1.3.5 → 2.0.0-beta.1
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/THIRD_PARTY_LICENSES.md +124 -0
- package/dist/devtools-client/200.html +1 -1
- package/dist/devtools-client/404.html +1 -1
- package/dist/devtools-client/_nuxt/{B551Pnuh.js → 2p1_IuX2.js} +1 -1
- package/dist/devtools-client/_nuxt/{KxC4Q3ev.js → 9elIQxwW.js} +1 -1
- package/dist/devtools-client/_nuxt/{DTP8MRtW.js → BNPn63Jz.js} +1 -1
- package/dist/devtools-client/_nuxt/BjRLaDIG.js +152 -0
- package/dist/devtools-client/_nuxt/BtNUYBXT.js +8 -0
- package/dist/devtools-client/_nuxt/CDDBpkXG.js +3 -0
- package/dist/devtools-client/_nuxt/Cpb0XAYP.js +1 -0
- package/dist/devtools-client/_nuxt/DAsiyhPm.js +6 -0
- package/dist/devtools-client/_nuxt/{VICyrUSM.js → DabLKy7M.js} +1 -1
- package/dist/devtools-client/_nuxt/Dat651Oh.js +1 -0
- package/dist/devtools-client/_nuxt/DcG2ZXvY.js +1 -0
- package/dist/devtools-client/_nuxt/DmlGWZ2X.js +1 -0
- package/dist/devtools-client/_nuxt/KsX6Az5B.js +1 -0
- package/dist/devtools-client/_nuxt/RL1np866.js +28 -0
- package/dist/devtools-client/_nuxt/UmWNrBO5.js +2 -0
- package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
- package/dist/devtools-client/_nuxt/builds/meta/e28b96f1-78e8-41a4-ad6f-904cd078f85e.json +1 -0
- package/dist/devtools-client/_nuxt/{entry.CYUdJFoE.css → entry.9HJPJ6Hp.css} +1 -1
- package/dist/devtools-client/_nuxt/error-404.DnwL1N6v.css +1 -0
- package/dist/devtools-client/_nuxt/error-500.DEbXRLdm.css +1 -0
- package/dist/devtools-client/docs/index.html +1 -1
- package/dist/devtools-client/first-party/index.html +1 -1
- package/dist/devtools-client/index.html +1 -1
- package/dist/devtools-client/registry/index.html +1 -1
- package/dist/module.d.mts +2 -86
- package/dist/module.d.ts +2 -86
- package/dist/module.json +3 -3
- package/dist/module.mjs +71 -328
- package/dist/registry.mjs +54 -22
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +1 -28
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +7 -50
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +1 -28
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +0 -8
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +1 -13
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +0 -8
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.d.vue.ts +4 -4
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue +9 -15
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsStaticMap.vue.d.ts +4 -4
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +0 -22
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +0 -31
- package/dist/runtime/components/Leaflet/ScriptLeafletGeoJson.d.vue.ts +31 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletGeoJson.vue +43 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletGeoJson.vue.d.ts +31 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletMap.d.vue.ts +90 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletMap.vue +171 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletMap.vue.d.ts +90 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletMarker.d.vue.ts +47 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletMarker.vue +70 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletMarker.vue.d.ts +47 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletPopup.d.vue.ts +31 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletPopup.vue +81 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletPopup.vue.d.ts +31 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletTileLayer.d.vue.ts +26 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletTileLayer.vue +38 -0
- package/dist/runtime/components/Leaflet/ScriptLeafletTileLayer.vue.d.ts +26 -0
- package/dist/runtime/components/Leaflet/useLeafletResource.d.ts +30 -0
- package/dist/runtime/components/Leaflet/useLeafletResource.js +46 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreGeoJson.d.vue.ts +39 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreGeoJson.vue +84 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreGeoJson.vue.d.ts +39 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreMap.d.vue.ts +122 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreMap.vue +214 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreMap.vue.d.ts +122 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreMarker.d.vue.ts +35 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreMarker.vue +98 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreMarker.vue.d.ts +35 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreNavigationControl.d.vue.ts +12 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreNavigationControl.vue +23 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibreNavigationControl.vue.d.ts +12 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibrePopup.d.vue.ts +31 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibrePopup.vue +99 -0
- package/dist/runtime/components/MapLibre/ScriptMapLibrePopup.vue.d.ts +31 -0
- package/dist/runtime/components/MapLibre/useMapLibreResource.d.ts +23 -0
- package/dist/runtime/components/MapLibre/useMapLibreResource.js +41 -0
- package/dist/runtime/components/ScriptCrisp.vue +20 -18
- package/dist/runtime/components/ScriptDeskCrew.d.vue.ts +40 -0
- package/dist/runtime/components/ScriptDeskCrew.vue +82 -0
- package/dist/runtime/components/ScriptDeskCrew.vue.d.ts +40 -0
- package/dist/runtime/components/ScriptIntercom.vue +21 -19
- package/dist/runtime/components/ScriptLoadingIndicator.d.vue.ts +1 -1
- package/dist/runtime/components/ScriptLoadingIndicator.vue.d.ts +1 -1
- package/dist/runtime/components/ScriptPayPalButtons.vue +7 -3
- package/dist/runtime/components/ScriptPayPalMessages.vue +8 -4
- package/dist/runtime/composables/useScript.js +96 -49
- package/dist/runtime/composables/useScriptProxyUrl.d.ts +4 -8
- package/dist/runtime/composables/useScriptProxyUrl.js +0 -7
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.d.ts +2 -1
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +3 -34
- package/dist/runtime/composables/useScriptTriggerInteraction.d.ts +2 -1
- package/dist/runtime/composables/useScriptTriggerInteraction.js +13 -46
- package/dist/runtime/composables/useScriptTriggerServiceWorker.d.ts +2 -1
- package/dist/runtime/composables/useScriptTriggerServiceWorker.js +5 -38
- package/dist/runtime/leaflet-styles.d.ts +13 -0
- package/dist/runtime/leaflet-styles.js +684 -0
- package/dist/runtime/maplibre-styles.d.ts +7 -0
- package/dist/runtime/maplibre-styles.js +25 -0
- package/dist/runtime/npm-script-api-state.d.ts +4 -0
- package/dist/runtime/npm-script-api-state.js +13 -0
- package/dist/runtime/registry/crisp.d.ts +1 -1
- package/dist/runtime/registry/crisp.js +30 -18
- package/dist/runtime/registry/deskcrew.d.ts +52 -0
- package/dist/runtime/registry/deskcrew.js +31 -0
- package/dist/runtime/registry/google-analytics.d.ts +0 -2
- package/dist/runtime/registry/google-maps.d.ts +2 -11
- package/dist/runtime/registry/google-maps.js +31 -10
- package/dist/runtime/registry/google-tag-manager.d.ts +9 -3
- package/dist/runtime/registry/leaflet.d.ts +13 -0
- package/dist/runtime/registry/leaflet.js +29 -0
- package/dist/runtime/registry/maplibre.d.ts +13 -0
- package/dist/runtime/registry/maplibre.js +29 -0
- package/dist/runtime/registry/matomo-analytics.js +1 -8
- package/dist/runtime/registry/plausible-analytics.d.ts +4 -16
- package/dist/runtime/registry/plausible-analytics.js +15 -58
- package/dist/runtime/registry/rybbit-analytics.d.ts +0 -4
- package/dist/runtime/registry/rybbit-analytics.js +1 -4
- package/dist/runtime/registry/schemas.d.ts +61 -5
- package/dist/runtime/registry/schemas.js +64 -5
- package/dist/runtime/registry/tiktok-pixel.d.ts +2 -12
- package/dist/runtime/registry/tiktok-pixel.js +1 -1
- package/dist/runtime/registry/usercentrics.js +46 -6
- package/dist/runtime/registry/youtube-player.d.ts +3 -4
- package/dist/runtime/registry/youtube-player.js +30 -23
- package/dist/runtime/server/bluesky-embed-image.d.ts +1 -1
- package/dist/runtime/server/bluesky-embed.d.ts +1 -1
- package/dist/runtime/server/bluesky-embed.js +3 -6
- package/dist/runtime/server/gravatar-proxy.d.ts +1 -1
- package/dist/runtime/server/gravatar-proxy.js +2 -3
- package/dist/runtime/server/instagram-embed-asset.d.ts +1 -1
- package/dist/runtime/server/instagram-embed-image.d.ts +1 -1
- package/dist/runtime/server/instagram-embed.d.ts +1 -1
- package/dist/runtime/server/instagram-embed.js +4 -7
- package/dist/runtime/server/utils/cached-upstream.d.ts +6 -11
- package/dist/runtime/server/utils/cached-upstream.js +94 -23
- package/dist/runtime/server/utils/embed-rewriters.d.ts +3 -5
- package/dist/runtime/server/utils/embed-rewriters.js +8 -8
- package/dist/runtime/server/utils/image-proxy.d.ts +1 -1
- package/dist/runtime/server/utils/image-proxy.js +2 -3
- package/dist/runtime/server/utils/instagram-embed.d.ts +6 -6
- package/dist/runtime/server/utils/instagram-embed.js +18 -19
- package/dist/runtime/server/utils/proxy-url.d.ts +5 -6
- package/dist/runtime/server/utils/proxy-url.js +1 -4
- package/dist/runtime/server/x-embed-image.d.ts +1 -1
- package/dist/runtime/server/x-embed.d.ts +48 -1
- package/dist/runtime/server/x-embed.js +3 -6
- package/dist/runtime/types.d.ts +13 -13
- package/dist/runtime/utils/abortable-promise.js +26 -5
- package/dist/runtime/utils/nuxt-ready-script-trigger.d.ts +3 -0
- package/dist/runtime/utils/nuxt-ready-script-trigger.js +16 -0
- package/dist/runtime/utils.js +21 -32
- package/dist/stats.mjs +13 -0
- package/dist/types-source.mjs +1173 -100
- package/dist/types.d.mts +2 -2
- package/package.json +34 -21
- package/LICENSE.md +0 -9
- package/bin/cli.mjs +0 -2
- package/dist/cli.d.mts +0 -2
- package/dist/cli.d.ts +0 -2
- package/dist/cli.mjs +0 -50
- package/dist/devtools-client/_nuxt/8ltZ0o6d.js +0 -1
- package/dist/devtools-client/_nuxt/B8_EBdhg.js +0 -152
- package/dist/devtools-client/_nuxt/BKdLzFmX.js +0 -3
- package/dist/devtools-client/_nuxt/Bf2Kt1P0.js +0 -28
- package/dist/devtools-client/_nuxt/CC0GKROJ.js +0 -1
- package/dist/devtools-client/_nuxt/CH5oUfNi.js +0 -1
- package/dist/devtools-client/_nuxt/CMXzQxJZ.js +0 -1
- package/dist/devtools-client/_nuxt/CP7c-Js6.js +0 -8
- package/dist/devtools-client/_nuxt/C_v3_O0R.js +0 -6
- package/dist/devtools-client/_nuxt/CxN78VhB.js +0 -1
- package/dist/devtools-client/_nuxt/Dkc7iTdR.js +0 -1
- package/dist/devtools-client/_nuxt/builds/meta/173480db-0944-415b-962d-d619682f0042.json +0 -1
- package/dist/devtools-client/_nuxt/error-404.Bq2JQbJs.css +0 -1
- package/dist/devtools-client/_nuxt/error-500.5E_FOzlc.css +0 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +0 -13
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +0 -15
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +0 -13
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +0 -27
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +0 -34
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +0 -27
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +0 -13
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +0 -11
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +0 -13
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.d.ts +0 -13
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.js +0 -8
- package/dist/runtime/components/GoogleMaps/injectionKeys.d.ts +0 -10
- package/dist/runtime/components/GoogleMaps/injectionKeys.js +0 -2
- package/dist/runtime/composables/useScriptProxyToken.d.ts +0 -12
- package/dist/runtime/composables/useScriptProxyToken.js +0 -4
- package/dist/runtime/npm-script-stub.d.ts +0 -20
- package/dist/runtime/npm-script-stub.js +0 -72
- package/dist/runtime/plugins/proxy-token.server.d.ts +0 -10
- package/dist/runtime/plugins/proxy-token.server.js +0 -17
- package/dist/runtime/server/google-maps-geocode-proxy.d.ts +0 -2
- package/dist/runtime/server/google-maps-geocode-proxy.js +0 -43
- package/dist/runtime/server/google-static-maps-proxy.d.ts +0 -2
- package/dist/runtime/server/google-static-maps-proxy.js +0 -56
- package/dist/runtime/server/utils/proxy-query.d.ts +0 -2
- package/dist/runtime/server/utils/proxy-query.js +0 -10
- package/dist/runtime/server/utils/sign-constants.d.ts +0 -16
- package/dist/runtime/server/utils/sign-constants.js +0 -5
- package/dist/runtime/server/utils/sign.d.ts +0 -101
- package/dist/runtime/server/utils/sign.js +0 -91
- package/dist/runtime/server/utils/withSigning.d.ts +0 -23
- package/dist/runtime/server/utils/withSigning.js +0 -19
- package/dist/runtime/unhead-features.d.ts +0 -1
- package/dist/runtime/unhead-features.js +0 -3
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export { MAPLIBRE_MAP_INJECTION_KEY } from "./useMapLibreResource";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed, onBeforeUnmount, onMounted, onUnmounted, provide, shallowRef, toRaw, useId, useTemplateRef, watch } from "vue";
|
|
7
|
+
import { useScriptTriggerElement } from "#nuxt-scripts/composables/useScriptTriggerElement";
|
|
8
|
+
import { useScriptMapLibre } from "#nuxt-scripts/registry/maplibre";
|
|
9
|
+
import ScriptAriaLoadingIndicator from "../ScriptAriaLoadingIndicator.vue";
|
|
10
|
+
import { MAPLIBRE_MAP_INJECTION_KEY } from "./useMapLibreResource";
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
trigger: { type: [String, Array, Boolean], required: false, default: "visible" },
|
|
13
|
+
mapStyle: { type: null, required: true },
|
|
14
|
+
center: { type: null, required: true },
|
|
15
|
+
zoom: { type: Number, required: false, default: 12 },
|
|
16
|
+
bearing: { type: Number, required: false, default: 0 },
|
|
17
|
+
pitch: { type: Number, required: false, default: 0 },
|
|
18
|
+
options: { type: Object, required: false },
|
|
19
|
+
injectStyles: { type: Boolean, required: false, default: true },
|
|
20
|
+
stylesheetUrl: { type: String, required: false },
|
|
21
|
+
workerUrl: { type: String, required: false },
|
|
22
|
+
width: { type: [Number, String], required: false, default: 640 },
|
|
23
|
+
height: { type: [Number, String], required: false, default: 400 },
|
|
24
|
+
ariaLabel: { type: String, required: false, default: "Interactive map" },
|
|
25
|
+
interactive: { type: Boolean, required: false, default: true },
|
|
26
|
+
rootAttrs: { type: Object, required: false }
|
|
27
|
+
});
|
|
28
|
+
const emit = defineEmits(["ready", "error", "click", "move", "moveend", "zoom", "zoomend", "rotate", "rotateend", "pitch", "pitchend", "update:center", "update:zoom", "update:bearing", "update:pitch"]);
|
|
29
|
+
const slots = defineSlots();
|
|
30
|
+
const rootEl = useTemplateRef("rootEl");
|
|
31
|
+
const mapEl = useTemplateRef("mapEl");
|
|
32
|
+
const descriptionId = `maplibre-description-${useId()}`;
|
|
33
|
+
const trigger = useScriptTriggerElement({ trigger: props.trigger, el: rootEl });
|
|
34
|
+
const { load, status, onLoaded, onError } = useScriptMapLibre({
|
|
35
|
+
injectStyles: props.injectStyles,
|
|
36
|
+
stylesheetUrl: props.stylesheetUrl,
|
|
37
|
+
workerUrl: props.workerUrl,
|
|
38
|
+
scriptOptions: { trigger }
|
|
39
|
+
});
|
|
40
|
+
const maplibre = shallowRef();
|
|
41
|
+
const map = shallowRef();
|
|
42
|
+
const isMapReady = shallowRef(false);
|
|
43
|
+
const loadError = shallowRef(new Error("MapLibre failed to load"));
|
|
44
|
+
const initializationError = shallowRef();
|
|
45
|
+
const hasError = computed(() => status.value === "error" || !!initializationError.value);
|
|
46
|
+
let isUnmounted = false;
|
|
47
|
+
onError((error) => {
|
|
48
|
+
loadError.value = error ?? new Error("MapLibre failed to load");
|
|
49
|
+
emit("error", loadError.value);
|
|
50
|
+
});
|
|
51
|
+
const exposed = { maplibre, map, load };
|
|
52
|
+
defineExpose(exposed);
|
|
53
|
+
provide(MAPLIBRE_MAP_INJECTION_KEY, {
|
|
54
|
+
maplibre,
|
|
55
|
+
map
|
|
56
|
+
});
|
|
57
|
+
function bindMapEvents(instance) {
|
|
58
|
+
instance.on("click", (event) => emit("click", event));
|
|
59
|
+
instance.on("move", (event) => emit("move", event));
|
|
60
|
+
instance.on("moveend", (event) => {
|
|
61
|
+
emit("moveend", event);
|
|
62
|
+
emit("update:center", instance.getCenter());
|
|
63
|
+
});
|
|
64
|
+
instance.on("zoom", (event) => emit("zoom", event));
|
|
65
|
+
instance.on("zoomend", (event) => {
|
|
66
|
+
emit("zoomend", event);
|
|
67
|
+
emit("update:zoom", instance.getZoom());
|
|
68
|
+
});
|
|
69
|
+
instance.on("rotate", (event) => emit("rotate", event));
|
|
70
|
+
instance.on("rotateend", (event) => {
|
|
71
|
+
emit("rotateend", event);
|
|
72
|
+
emit("update:bearing", instance.getBearing());
|
|
73
|
+
});
|
|
74
|
+
instance.on("pitch", (event) => emit("pitch", event));
|
|
75
|
+
instance.on("pitchend", (event) => {
|
|
76
|
+
emit("pitchend", event);
|
|
77
|
+
emit("update:pitch", instance.getPitch());
|
|
78
|
+
});
|
|
79
|
+
instance.on("error", (event) => {
|
|
80
|
+
loadError.value = event.error;
|
|
81
|
+
emit("error", event.error);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
onMounted(() => {
|
|
85
|
+
onLoaded((instance) => {
|
|
86
|
+
if (isUnmounted || !mapEl.value)
|
|
87
|
+
return;
|
|
88
|
+
maplibre.value = instance.maplibregl;
|
|
89
|
+
let mapInstance;
|
|
90
|
+
try {
|
|
91
|
+
mapInstance = new instance.maplibregl.Map({
|
|
92
|
+
...toRaw(props.options),
|
|
93
|
+
container: mapEl.value,
|
|
94
|
+
style: toRaw(props.mapStyle),
|
|
95
|
+
center: toRaw(props.center),
|
|
96
|
+
zoom: props.zoom,
|
|
97
|
+
bearing: props.bearing,
|
|
98
|
+
pitch: props.pitch,
|
|
99
|
+
interactive: props.interactive
|
|
100
|
+
});
|
|
101
|
+
bindMapEvents(mapInstance);
|
|
102
|
+
map.value = mapInstance;
|
|
103
|
+
mapInstance.once("load", () => {
|
|
104
|
+
if (isUnmounted)
|
|
105
|
+
return;
|
|
106
|
+
isMapReady.value = true;
|
|
107
|
+
mapInstance.resize();
|
|
108
|
+
emit("ready", exposed);
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
mapInstance?.remove();
|
|
112
|
+
const cause = error instanceof Error ? error : new Error("MapLibre map initialization failed");
|
|
113
|
+
initializationError.value = cause;
|
|
114
|
+
loadError.value = cause;
|
|
115
|
+
emit("error", cause);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
watch(() => props.mapStyle, (mapStyle) => {
|
|
120
|
+
map.value?.setStyle(toRaw(mapStyle));
|
|
121
|
+
}, { deep: 2 });
|
|
122
|
+
watch(() => props.center, (center) => {
|
|
123
|
+
if (!map.value || !maplibre.value)
|
|
124
|
+
return;
|
|
125
|
+
const current = map.value.getCenter();
|
|
126
|
+
const next = maplibre.value.LngLat.convert(toRaw(center));
|
|
127
|
+
if (current.lng !== next.lng || current.lat !== next.lat)
|
|
128
|
+
map.value.jumpTo({ center: next });
|
|
129
|
+
}, { deep: 1 });
|
|
130
|
+
watch(() => props.zoom, (zoom) => {
|
|
131
|
+
if (map.value && map.value.getZoom() !== zoom)
|
|
132
|
+
map.value.jumpTo({ zoom });
|
|
133
|
+
});
|
|
134
|
+
watch(() => props.bearing, (bearing) => {
|
|
135
|
+
if (map.value && map.value.getBearing() !== bearing)
|
|
136
|
+
map.value.jumpTo({ bearing });
|
|
137
|
+
});
|
|
138
|
+
watch(() => props.pitch, (pitch) => {
|
|
139
|
+
if (map.value && map.value.getPitch() !== pitch)
|
|
140
|
+
map.value.jumpTo({ pitch });
|
|
141
|
+
});
|
|
142
|
+
const DIGITS_ONLY_RE = /^\d+$/;
|
|
143
|
+
const DIGITS_PX_RE = /^\d+px$/i;
|
|
144
|
+
function toCssUnit(value) {
|
|
145
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
146
|
+
}
|
|
147
|
+
function isPixelValue(value) {
|
|
148
|
+
return typeof value === "number" || typeof value === "string" && (DIGITS_ONLY_RE.test(value) || DIGITS_PX_RE.test(value));
|
|
149
|
+
}
|
|
150
|
+
function pixelValue(value) {
|
|
151
|
+
return isPixelValue(value) ? Number.parseFloat(String(value)) : void 0;
|
|
152
|
+
}
|
|
153
|
+
const rootAttrs = computed(() => ({
|
|
154
|
+
...trigger instanceof Promise ? trigger.ssrAttrs || {} : {},
|
|
155
|
+
...props.rootAttrs,
|
|
156
|
+
"aria-busy": status.value === "loading" ? true : void 0,
|
|
157
|
+
"style": [
|
|
158
|
+
{
|
|
159
|
+
position: "relative",
|
|
160
|
+
maxWidth: "100%",
|
|
161
|
+
width: toCssUnit(props.width),
|
|
162
|
+
height: isPixelValue(props.width) && isPixelValue(props.height) ? "auto" : toCssUnit(props.height),
|
|
163
|
+
aspectRatio: isPixelValue(props.width) && isPixelValue(props.height) ? `${pixelValue(props.width)} / ${pixelValue(props.height)}` : void 0
|
|
164
|
+
},
|
|
165
|
+
props.rootAttrs?.style
|
|
166
|
+
]
|
|
167
|
+
}));
|
|
168
|
+
onBeforeUnmount(() => {
|
|
169
|
+
isUnmounted = true;
|
|
170
|
+
});
|
|
171
|
+
onUnmounted(() => {
|
|
172
|
+
map.value?.remove();
|
|
173
|
+
map.value = void 0;
|
|
174
|
+
});
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
<template>
|
|
178
|
+
<div ref="rootEl" v-bind="rootAttrs">
|
|
179
|
+
<div
|
|
180
|
+
ref="mapEl"
|
|
181
|
+
:aria-describedby="interactive && slots.description ? descriptionId : void 0"
|
|
182
|
+
:aria-hidden="interactive ? void 0 : 'true'"
|
|
183
|
+
:aria-label="interactive ? ariaLabel : void 0"
|
|
184
|
+
:inert="interactive ? void 0 : true"
|
|
185
|
+
:role="interactive ? 'region' : void 0"
|
|
186
|
+
:style="{
|
|
187
|
+
position: 'absolute',
|
|
188
|
+
inset: 0,
|
|
189
|
+
width: '100%',
|
|
190
|
+
height: '100%',
|
|
191
|
+
maxWidth: '100%',
|
|
192
|
+
visibility: isMapReady ? 'visible' : 'hidden'
|
|
193
|
+
}"
|
|
194
|
+
/>
|
|
195
|
+
<div v-if="interactive && slots.description" :id="descriptionId" class="maplibre-map-description">
|
|
196
|
+
<slot name="description" />
|
|
197
|
+
</div>
|
|
198
|
+
<slot v-if="!isMapReady && !hasError" name="placeholder" />
|
|
199
|
+
<slot v-if="hasError" name="error" :error="loadError">
|
|
200
|
+
<p role="alert">
|
|
201
|
+
The map could not be loaded.
|
|
202
|
+
</p>
|
|
203
|
+
</slot>
|
|
204
|
+
<slot v-else-if="status === 'loading'" name="loading">
|
|
205
|
+
<ScriptAriaLoadingIndicator />
|
|
206
|
+
</slot>
|
|
207
|
+
<slot v-else-if="status === 'awaitingLoad'" name="awaitingLoad" />
|
|
208
|
+
<slot />
|
|
209
|
+
</div>
|
|
210
|
+
</template>
|
|
211
|
+
|
|
212
|
+
<style scoped>
|
|
213
|
+
.maplibre-map-description{height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;clip:rect(0,0,0,0);border:0;clip-path:inset(50%);white-space:nowrap}
|
|
214
|
+
</style>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type * as MapLibre from 'maplibre-gl';
|
|
2
|
+
import type { HTMLAttributes, ReservedProps, ShallowRef } from 'vue';
|
|
3
|
+
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
4
|
+
export { MAPLIBRE_MAP_INJECTION_KEY } from './useMapLibreResource.js';
|
|
5
|
+
export interface ScriptMapLibreMapProps {
|
|
6
|
+
/**
|
|
7
|
+
* Defines when the MapLibre script loads.
|
|
8
|
+
* @default 'visible'
|
|
9
|
+
*/
|
|
10
|
+
trigger?: ElementScriptTrigger;
|
|
11
|
+
/** MapLibre style URL or inline style specification. */
|
|
12
|
+
mapStyle: string | MapLibre.StyleSpecification;
|
|
13
|
+
/** Initial and reactively controlled map center. */
|
|
14
|
+
center: MapLibre.LngLatLike;
|
|
15
|
+
/** Initial and reactively controlled zoom level. @default 12 */
|
|
16
|
+
zoom?: number;
|
|
17
|
+
/** Initial and reactively controlled bearing in degrees. @default 0 */
|
|
18
|
+
bearing?: number;
|
|
19
|
+
/** Initial and reactively controlled pitch in degrees. @default 0 */
|
|
20
|
+
pitch?: number;
|
|
21
|
+
/** Options passed to `new maplibregl.Map()`. Dedicated props take precedence. */
|
|
22
|
+
options?: Omit<MapLibre.MapOptions, 'container'>;
|
|
23
|
+
/** Inject MapLibre's stylesheet when the script begins loading. @default true */
|
|
24
|
+
injectStyles?: boolean;
|
|
25
|
+
/** Custom MapLibre stylesheet URL. */
|
|
26
|
+
stylesheetUrl?: string;
|
|
27
|
+
/** Worker URL used with MapLibre's CSP-compatible build. */
|
|
28
|
+
workerUrl?: string;
|
|
29
|
+
/** Width reserved before the map loads. @default 640 */
|
|
30
|
+
width?: number | string;
|
|
31
|
+
/** Height reserved before the map loads. @default 400 */
|
|
32
|
+
height?: number | string;
|
|
33
|
+
/** Accessible name for an interactive map. @default 'Interactive map' */
|
|
34
|
+
ariaLabel?: string;
|
|
35
|
+
/** Disable map input and remove it from the accessibility tree when decorative. @default true */
|
|
36
|
+
interactive?: boolean;
|
|
37
|
+
/** Attributes applied to the outer layout container. */
|
|
38
|
+
rootAttrs?: HTMLAttributes & ReservedProps & Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
export interface ScriptMapLibreMapExpose {
|
|
41
|
+
maplibre: ShallowRef<typeof MapLibre | undefined>;
|
|
42
|
+
map: ShallowRef<MapLibre.Map | undefined>;
|
|
43
|
+
load: () => Promise<unknown> | unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface ScriptMapLibreMapEmits {
|
|
46
|
+
'ready': [payload: ScriptMapLibreMapExpose];
|
|
47
|
+
'error': [error: Error];
|
|
48
|
+
'click': [event: MapLibre.MapEventType['click']];
|
|
49
|
+
'move': [event: MapLibre.MapEventType['move']];
|
|
50
|
+
'moveend': [event: MapLibre.MapEventType['moveend']];
|
|
51
|
+
'zoom': [event: MapLibre.MapEventType['zoom']];
|
|
52
|
+
'zoomend': [event: MapLibre.MapEventType['zoomend']];
|
|
53
|
+
'rotate': [event: MapLibre.MapEventType['rotate']];
|
|
54
|
+
'rotateend': [event: MapLibre.MapEventType['rotateend']];
|
|
55
|
+
'pitch': [event: MapLibre.MapEventType['pitch']];
|
|
56
|
+
'pitchend': [event: MapLibre.MapEventType['pitchend']];
|
|
57
|
+
'update:center': [center: MapLibre.LngLat];
|
|
58
|
+
'update:zoom': [zoom: number];
|
|
59
|
+
'update:bearing': [bearing: number];
|
|
60
|
+
'update:pitch': [pitch: number];
|
|
61
|
+
}
|
|
62
|
+
export interface ScriptMapLibreMapSlots {
|
|
63
|
+
default?: () => any;
|
|
64
|
+
loading?: () => any;
|
|
65
|
+
awaitingLoad?: () => any;
|
|
66
|
+
error?: (props: {
|
|
67
|
+
error: Error;
|
|
68
|
+
}) => any;
|
|
69
|
+
placeholder?: () => any;
|
|
70
|
+
/** Text or links that expose the canvas map's essential information to assistive technology. */
|
|
71
|
+
description?: () => any;
|
|
72
|
+
}
|
|
73
|
+
declare const _default: typeof __VLS_export;
|
|
74
|
+
export default _default;
|
|
75
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScriptMapLibreMapProps, ScriptMapLibreMapExpose, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
76
|
+
error: (error: Error) => any;
|
|
77
|
+
ready: (payload: ScriptMapLibreMapExpose) => any;
|
|
78
|
+
click: (event: MapLibre.MapMouseEvent) => any;
|
|
79
|
+
move: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any;
|
|
80
|
+
zoom: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any;
|
|
81
|
+
zoomend: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any;
|
|
82
|
+
moveend: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any;
|
|
83
|
+
"update:center": (center: MapLibre.LngLat) => any;
|
|
84
|
+
"update:zoom": (zoom: number) => any;
|
|
85
|
+
rotate: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any;
|
|
86
|
+
rotateend: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any;
|
|
87
|
+
pitch: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any;
|
|
88
|
+
pitchend: (event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any;
|
|
89
|
+
"update:bearing": (bearing: number) => any;
|
|
90
|
+
"update:pitch": (pitch: number) => any;
|
|
91
|
+
}, string, import("vue").PublicProps, Readonly<ScriptMapLibreMapProps> & Readonly<{
|
|
92
|
+
onError?: ((error: Error) => any) | undefined;
|
|
93
|
+
onReady?: ((payload: ScriptMapLibreMapExpose) => any) | undefined;
|
|
94
|
+
onClick?: ((event: MapLibre.MapMouseEvent) => any) | undefined;
|
|
95
|
+
onMove?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any) | undefined;
|
|
96
|
+
onZoom?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any) | undefined;
|
|
97
|
+
onZoomend?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any) | undefined;
|
|
98
|
+
onMoveend?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | WheelEvent | undefined>) => any) | undefined;
|
|
99
|
+
"onUpdate:center"?: ((center: MapLibre.LngLat) => any) | undefined;
|
|
100
|
+
"onUpdate:zoom"?: ((zoom: number) => any) | undefined;
|
|
101
|
+
onRotate?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any) | undefined;
|
|
102
|
+
onRotateend?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any) | undefined;
|
|
103
|
+
onPitch?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any) | undefined;
|
|
104
|
+
onPitchend?: ((event: MapLibre.MapLibreEvent<MouseEvent | TouchEvent | undefined>) => any) | undefined;
|
|
105
|
+
"onUpdate:bearing"?: ((bearing: number) => any) | undefined;
|
|
106
|
+
"onUpdate:pitch"?: ((pitch: number) => any) | undefined;
|
|
107
|
+
}>, {
|
|
108
|
+
injectStyles: boolean;
|
|
109
|
+
trigger: ElementScriptTrigger;
|
|
110
|
+
width: number | string;
|
|
111
|
+
height: number | string;
|
|
112
|
+
zoom: number;
|
|
113
|
+
ariaLabel: string;
|
|
114
|
+
interactive: boolean;
|
|
115
|
+
pitch: number;
|
|
116
|
+
bearing: number;
|
|
117
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScriptMapLibreMapSlots>;
|
|
118
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
119
|
+
new (): {
|
|
120
|
+
$slots: S;
|
|
121
|
+
};
|
|
122
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type * as MapLibre from 'maplibre-gl';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Reactive marker position in `[longitude, latitude]` order. */
|
|
4
|
+
position: MapLibre.LngLatLike;
|
|
5
|
+
/** Accessible name for the marker element. */
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
/** Tooltip text for the marker element. */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Options passed to `new maplibregl.Marker()`. Options with public setters also update reactively. */
|
|
10
|
+
options?: MapLibre.MarkerOptions;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_Slots = {
|
|
13
|
+
default?: () => any;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
16
|
+
marker: import("vue").ShallowRef<MapLibre.Marker | undefined>;
|
|
17
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
click: (event: MouseEvent) => any;
|
|
19
|
+
drag: (event: MapLibre.Event) => any;
|
|
20
|
+
dragend: (event: MapLibre.Event) => any;
|
|
21
|
+
dragstart: (event: MapLibre.Event) => any;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
24
|
+
onDrag?: ((event: MapLibre.Event) => any) | undefined;
|
|
25
|
+
onDragend?: ((event: MapLibre.Event) => any) | undefined;
|
|
26
|
+
onDragstart?: ((event: MapLibre.Event) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
32
|
+
new (): {
|
|
33
|
+
$slots: S;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { onMounted, provide, watch } from "vue";
|
|
3
|
+
import { MAPLIBRE_MARKER_INJECTION_KEY, useMapLibreResource } from "./useMapLibreResource";
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
position: { type: null, required: true },
|
|
6
|
+
ariaLabel: { type: String, required: false },
|
|
7
|
+
title: { type: String, required: false },
|
|
8
|
+
options: { type: null, required: false }
|
|
9
|
+
});
|
|
10
|
+
const emit = defineEmits(["click", "dragstart", "drag", "dragend"]);
|
|
11
|
+
defineSlots();
|
|
12
|
+
let clickHandler;
|
|
13
|
+
let markerClassNames = new Set((props.options?.className || "").split(/\s+/).filter(Boolean));
|
|
14
|
+
let fallbackAriaLabel = null;
|
|
15
|
+
const dragStartHandler = (event) => emit("dragstart", event);
|
|
16
|
+
const dragHandler = (event) => emit("drag", event);
|
|
17
|
+
const dragEndHandler = (event) => emit("dragend", event);
|
|
18
|
+
function syncMarkerElement(instance) {
|
|
19
|
+
const element = instance.getElement();
|
|
20
|
+
if (props.ariaLabel)
|
|
21
|
+
element.setAttribute("aria-label", props.ariaLabel);
|
|
22
|
+
else if (fallbackAriaLabel)
|
|
23
|
+
element.setAttribute("aria-label", fallbackAriaLabel);
|
|
24
|
+
else
|
|
25
|
+
element.removeAttribute("aria-label");
|
|
26
|
+
if (props.title)
|
|
27
|
+
element.setAttribute("title", props.title);
|
|
28
|
+
else
|
|
29
|
+
element.removeAttribute("title");
|
|
30
|
+
}
|
|
31
|
+
const marker = useMapLibreResource({
|
|
32
|
+
create({ maplibre, map }) {
|
|
33
|
+
const instance = new maplibre.Marker(props.options).setLngLat(props.position).addTo(map);
|
|
34
|
+
markerClassNames = new Set((props.options?.className || "").split(/\s+/).filter(Boolean));
|
|
35
|
+
fallbackAriaLabel = instance.getElement().getAttribute("aria-label");
|
|
36
|
+
instance.on("dragstart", dragStartHandler);
|
|
37
|
+
instance.on("drag", dragHandler);
|
|
38
|
+
instance.on("dragend", dragEndHandler);
|
|
39
|
+
clickHandler = (event) => emit("click", event);
|
|
40
|
+
instance.getElement().addEventListener("click", clickHandler);
|
|
41
|
+
syncMarkerElement(instance);
|
|
42
|
+
return instance;
|
|
43
|
+
},
|
|
44
|
+
cleanup(instance) {
|
|
45
|
+
if (clickHandler)
|
|
46
|
+
instance.getElement().removeEventListener("click", clickHandler);
|
|
47
|
+
clickHandler = void 0;
|
|
48
|
+
fallbackAriaLabel = null;
|
|
49
|
+
instance.off("dragstart", dragStartHandler);
|
|
50
|
+
instance.off("drag", dragHandler);
|
|
51
|
+
instance.off("dragend", dragEndHandler);
|
|
52
|
+
instance.remove();
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
provide(MAPLIBRE_MARKER_INJECTION_KEY, { marker });
|
|
56
|
+
defineExpose({ marker });
|
|
57
|
+
onMounted(() => {
|
|
58
|
+
if (import.meta.dev && !props.ariaLabel)
|
|
59
|
+
console.warn("[nuxt-scripts] <ScriptMapLibreMarker> should have a unique `aria-label` for screen reader users.");
|
|
60
|
+
});
|
|
61
|
+
watch(() => props.position, (position) => marker.value?.setLngLat(position), { deep: 1 });
|
|
62
|
+
watch(() => props.ariaLabel, () => marker.value && syncMarkerElement(marker.value));
|
|
63
|
+
watch(() => props.title, () => marker.value && syncMarkerElement(marker.value));
|
|
64
|
+
watch(() => props.options, (options) => {
|
|
65
|
+
if (!marker.value || !options)
|
|
66
|
+
return;
|
|
67
|
+
if (options.draggable !== void 0)
|
|
68
|
+
marker.value.setDraggable(options.draggable);
|
|
69
|
+
if (options.rotation !== void 0)
|
|
70
|
+
marker.value.setRotation(options.rotation);
|
|
71
|
+
if (options.rotationAlignment !== void 0)
|
|
72
|
+
marker.value.setRotationAlignment(options.rotationAlignment);
|
|
73
|
+
if (options.pitchAlignment !== void 0)
|
|
74
|
+
marker.value.setPitchAlignment(options.pitchAlignment);
|
|
75
|
+
if (options.offset !== void 0)
|
|
76
|
+
marker.value.setOffset(options.offset);
|
|
77
|
+
if (options.opacity !== void 0 || options.opacityWhenCovered !== void 0)
|
|
78
|
+
marker.value.setOpacity(options.opacity, options.opacityWhenCovered);
|
|
79
|
+
if (options.subpixelPositioning !== void 0)
|
|
80
|
+
marker.value.setSubpixelPositioning(options.subpixelPositioning);
|
|
81
|
+
if (options.className !== void 0) {
|
|
82
|
+
const nextClassNames = new Set(options.className.split(/\s+/).filter(Boolean));
|
|
83
|
+
for (const className of markerClassNames) {
|
|
84
|
+
if (!nextClassNames.has(className))
|
|
85
|
+
marker.value.removeClassName(className);
|
|
86
|
+
}
|
|
87
|
+
for (const className of nextClassNames) {
|
|
88
|
+
if (!markerClassNames.has(className))
|
|
89
|
+
marker.value.addClassName(className);
|
|
90
|
+
}
|
|
91
|
+
markerClassNames = nextClassNames;
|
|
92
|
+
}
|
|
93
|
+
}, { deep: 2 });
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<template>
|
|
97
|
+
<slot />
|
|
98
|
+
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type * as MapLibre from 'maplibre-gl';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Reactive marker position in `[longitude, latitude]` order. */
|
|
4
|
+
position: MapLibre.LngLatLike;
|
|
5
|
+
/** Accessible name for the marker element. */
|
|
6
|
+
ariaLabel?: string;
|
|
7
|
+
/** Tooltip text for the marker element. */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Options passed to `new maplibregl.Marker()`. Options with public setters also update reactively. */
|
|
10
|
+
options?: MapLibre.MarkerOptions;
|
|
11
|
+
};
|
|
12
|
+
type __VLS_Slots = {
|
|
13
|
+
default?: () => any;
|
|
14
|
+
};
|
|
15
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
16
|
+
marker: import("vue").ShallowRef<MapLibre.Marker | undefined>;
|
|
17
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
18
|
+
click: (event: MouseEvent) => any;
|
|
19
|
+
drag: (event: MapLibre.Event) => any;
|
|
20
|
+
dragend: (event: MapLibre.Event) => any;
|
|
21
|
+
dragstart: (event: MapLibre.Event) => any;
|
|
22
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
23
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
24
|
+
onDrag?: ((event: MapLibre.Event) => any) | undefined;
|
|
25
|
+
onDragend?: ((event: MapLibre.Event) => any) | undefined;
|
|
26
|
+
onDragstart?: ((event: MapLibre.Event) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
29
|
+
declare const _default: typeof __VLS_export;
|
|
30
|
+
export default _default;
|
|
31
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
32
|
+
new (): {
|
|
33
|
+
$slots: S;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as MapLibre from 'maplibre-gl';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Position of the navigation control. */
|
|
4
|
+
position?: MapLibre.ControlPosition;
|
|
5
|
+
/** Options passed to `new maplibregl.NavigationControl()`. */
|
|
6
|
+
options?: MapLibre.NavigationControlOptions;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
9
|
+
control: import("vue").ShallowRef<MapLibre.NavigationControl | undefined>;
|
|
10
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useMapLibreResource } from "./useMapLibreResource";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
position: { type: null, required: false },
|
|
5
|
+
options: { type: null, required: false }
|
|
6
|
+
});
|
|
7
|
+
const control = useMapLibreResource({
|
|
8
|
+
create({ maplibre, map }) {
|
|
9
|
+
const instance = new maplibre.NavigationControl(props.options);
|
|
10
|
+
map.addControl(instance, props.position);
|
|
11
|
+
return instance;
|
|
12
|
+
},
|
|
13
|
+
cleanup(instance, { map }) {
|
|
14
|
+
if (map.hasControl(instance))
|
|
15
|
+
map.removeControl(instance);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
defineExpose({ control });
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<!-- nuxt-scripts: MapLibre navigation control -->
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type * as MapLibre from 'maplibre-gl';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Position of the navigation control. */
|
|
4
|
+
position?: MapLibre.ControlPosition;
|
|
5
|
+
/** Options passed to `new maplibregl.NavigationControl()`. */
|
|
6
|
+
options?: MapLibre.NavigationControlOptions;
|
|
7
|
+
};
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
|
|
9
|
+
control: import("vue").ShallowRef<MapLibre.NavigationControl | undefined>;
|
|
10
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as MapLibre from 'maplibre-gl';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Position for a standalone popup. Omit when nested inside a marker. */
|
|
4
|
+
position?: MapLibre.LngLatLike;
|
|
5
|
+
/** Whether the popup is open. @default false */
|
|
6
|
+
open?: boolean;
|
|
7
|
+
/** Options passed to `new maplibregl.Popup()`. Options with public setters also update reactively. */
|
|
8
|
+
options?: MapLibre.PopupOptions;
|
|
9
|
+
};
|
|
10
|
+
type __VLS_Slots = {
|
|
11
|
+
default?: () => any;
|
|
12
|
+
};
|
|
13
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {
|
|
14
|
+
popup: import("vue").ShallowRef<MapLibre.Popup | undefined>;
|
|
15
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
close: (event: MapLibre.Event) => any;
|
|
17
|
+
open: (event: MapLibre.Event) => any;
|
|
18
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
19
|
+
onClose?: ((event: MapLibre.Event) => any) | undefined;
|
|
20
|
+
onOpen?: ((event: MapLibre.Event) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
open: boolean;
|
|
23
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|