@nuxt/scripts 1.0.0-beta.3 → 1.0.0-beta.31
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.md +3 -3
- package/dist/client/200.html +1 -1
- package/dist/client/404.html +1 -1
- package/dist/client/_nuxt/{DdVDSbUA.js → 6CwTUC2b.js} +1 -1
- package/dist/client/_nuxt/{CD5B-xvT.js → B71AlSZ1.js} +1 -1
- package/dist/client/_nuxt/{Ds2G8aQM.js → BYGJV5dd.js} +1 -1
- package/dist/client/_nuxt/V4W-T8W6.js +162 -0
- package/dist/client/_nuxt/builds/latest.json +1 -1
- package/dist/client/_nuxt/builds/meta/70b59a3e-a025-4a77-a25a-dfadf5b1749d.json +1 -0
- package/dist/client/_nuxt/entry.C5SUNdim.css +1 -0
- package/dist/client/_nuxt/error-404.1K8v8Su2.css +1 -0
- package/dist/client/_nuxt/error-500.B9qvKpQm.css +1 -0
- package/dist/client/index.html +1 -1
- package/dist/module.d.mts +6 -18
- package/dist/module.d.ts +164 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +908 -645
- package/dist/registry.d.ts +6 -0
- package/dist/registry.mjs +244 -78
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +16 -9
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +57 -30
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +16 -9
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +22 -39
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +69 -72
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +22 -39
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.d.vue.ts +5 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +25 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue.d.ts +5 -1
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.d.vue.ts +43 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue +61 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue.d.ts +43 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.d.vue.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue +22 -26
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsHeatmapLayer.vue.d.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +9 -5
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +62 -53
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +9 -5
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +26 -11
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +48 -45
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +26 -11
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.d.vue.ts +15 -4
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue +47 -37
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarkerClusterer.vue.d.ts +15 -4
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +77 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +209 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +77 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.d.vue.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue +23 -32
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPinElement.vue.d.ts +4 -0
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +24 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +24 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.d.vue.ts +7 -3
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +25 -38
- package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue.d.ts +7 -3
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.d.ts +13 -0
- package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.js +8 -0
- package/dist/runtime/components/GoogleMaps/injectionKeys.d.ts +13 -0
- package/dist/runtime/components/GoogleMaps/injectionKeys.js +3 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +26 -0
- package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +42 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.d.vue.ts +87 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue +85 -0
- package/dist/runtime/components/ScriptBlueskyEmbed.vue.d.ts +87 -0
- package/dist/runtime/components/ScriptCrisp.vue +1 -1
- package/dist/runtime/components/ScriptGoogleAdsense.vue +1 -1
- package/dist/runtime/components/ScriptGravatar.d.vue.ts +22 -0
- package/dist/runtime/components/ScriptGravatar.vue +46 -0
- package/dist/runtime/components/ScriptGravatar.vue.d.ts +22 -0
- package/dist/runtime/components/ScriptInstagramEmbed.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptInstagramEmbed.vue +5 -2
- package/dist/runtime/components/ScriptInstagramEmbed.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptIntercom.vue +4 -3
- package/dist/runtime/components/ScriptPayPalButtons.d.vue.ts +43 -32
- package/dist/runtime/components/ScriptPayPalButtons.vue +48 -79
- package/dist/runtime/components/ScriptPayPalButtons.vue.d.ts +43 -32
- package/dist/runtime/components/ScriptPayPalMessages.d.vue.ts +37 -23
- package/dist/runtime/components/ScriptPayPalMessages.vue +46 -50
- package/dist/runtime/components/ScriptPayPalMessages.vue.d.ts +37 -23
- package/dist/runtime/components/ScriptStripePricingTable.vue +2 -2
- package/dist/runtime/components/ScriptVimeoPlayer.d.vue.ts +9 -0
- package/dist/runtime/components/ScriptVimeoPlayer.vue +13 -10
- package/dist/runtime/components/ScriptVimeoPlayer.vue.d.ts +9 -0
- package/dist/runtime/components/ScriptXEmbed.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptXEmbed.vue +6 -3
- package/dist/runtime/components/ScriptXEmbed.vue.d.ts +2 -2
- package/dist/runtime/components/ScriptYouTubePlayer.d.vue.ts +2 -2
- package/dist/runtime/components/ScriptYouTubePlayer.vue +11 -5
- package/dist/runtime/components/ScriptYouTubePlayer.vue.d.ts +2 -2
- package/dist/runtime/composables/useScript.js +13 -6
- package/dist/runtime/composables/useScriptEventPage.js +2 -2
- package/dist/runtime/composables/useScriptTriggerConsent.d.ts +10 -0
- package/dist/runtime/composables/useScriptTriggerConsent.js +33 -20
- package/dist/runtime/composables/useScriptTriggerElement.js +1 -1
- package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +1 -1
- package/dist/runtime/registry/bing-uet.d.ts +20 -0
- package/dist/runtime/registry/bing-uet.js +29 -0
- package/dist/runtime/registry/bluesky-embed.d.ts +116 -0
- package/dist/runtime/registry/bluesky-embed.js +72 -0
- package/dist/runtime/registry/clarity.d.ts +10 -15
- package/dist/runtime/registry/clarity.js +22 -31
- package/dist/runtime/registry/cloudflare-web-analytics.d.ts +2 -13
- package/dist/runtime/registry/cloudflare-web-analytics.js +2 -14
- package/dist/runtime/registry/crisp.d.ts +10 -40
- package/dist/runtime/registry/crisp.js +2 -33
- package/dist/runtime/registry/databuddy-analytics.d.ts +2 -35
- package/dist/runtime/registry/databuddy-analytics.js +20 -45
- package/dist/runtime/registry/fathom-analytics.d.ts +7 -26
- package/dist/runtime/registry/fathom-analytics.js +2 -24
- package/dist/runtime/registry/google-adsense.d.ts +3 -11
- package/dist/runtime/registry/google-adsense.js +2 -11
- package/dist/runtime/registry/google-analytics.d.ts +3 -5
- package/dist/runtime/registry/google-analytics.js +3 -8
- package/dist/runtime/registry/google-maps.d.ts +3 -9
- package/dist/runtime/registry/google-maps.js +2 -8
- package/dist/runtime/registry/google-recaptcha.d.ts +2 -6
- package/dist/runtime/registry/google-recaptcha.js +4 -12
- package/dist/runtime/registry/google-sign-in.d.ts +2 -13
- package/dist/runtime/registry/google-sign-in.js +2 -22
- package/dist/runtime/registry/google-tag-manager.d.ts +3 -28
- package/dist/runtime/registry/google-tag-manager.js +4 -27
- package/dist/runtime/registry/gravatar.d.ts +26 -0
- package/dist/runtime/registry/gravatar.js +33 -0
- package/dist/runtime/registry/hotjar.d.ts +4 -6
- package/dist/runtime/registry/hotjar.js +2 -5
- package/dist/runtime/registry/instagram-embed.d.ts +3 -18
- package/dist/runtime/registry/instagram-embed.js +4 -19
- package/dist/runtime/registry/intercom.d.ts +4 -12
- package/dist/runtime/registry/intercom.js +2 -12
- package/dist/runtime/registry/matomo-analytics.d.ts +3 -12
- package/dist/runtime/registry/matomo-analytics.js +3 -12
- package/dist/runtime/registry/meta-pixel.d.ts +4 -6
- package/dist/runtime/registry/meta-pixel.js +2 -4
- package/dist/runtime/registry/mixpanel-analytics.d.ts +22 -0
- package/dist/runtime/registry/mixpanel-analytics.js +46 -0
- package/dist/runtime/registry/npm.d.ts +3 -7
- package/dist/runtime/registry/npm.js +2 -9
- package/dist/runtime/registry/paypal.d.ts +4 -25
- package/dist/runtime/registry/paypal.js +3 -66
- package/dist/runtime/registry/plausible-analytics.js +18 -13
- package/dist/runtime/registry/posthog.d.ts +10 -12
- package/dist/runtime/registry/posthog.js +7 -14
- package/dist/runtime/registry/reddit-pixel.d.ts +5 -6
- package/dist/runtime/registry/reddit-pixel.js +2 -4
- package/dist/runtime/registry/rybbit-analytics.d.ts +2 -14
- package/dist/runtime/registry/rybbit-analytics.js +10 -20
- package/dist/runtime/registry/schemas.d.ts +982 -0
- package/dist/runtime/registry/schemas.js +937 -0
- package/dist/runtime/registry/segment.d.ts +2 -5
- package/dist/runtime/registry/segment.js +2 -5
- package/dist/runtime/registry/snapchat-pixel.d.ts +4 -33
- package/dist/runtime/registry/snapchat-pixel.js +2 -20
- package/dist/runtime/registry/stripe.d.ts +3 -4
- package/dist/runtime/registry/stripe.js +2 -4
- package/dist/runtime/registry/tiktok-pixel.d.ts +4 -7
- package/dist/runtime/registry/tiktok-pixel.js +2 -6
- package/dist/runtime/registry/umami-analytics.d.ts +2 -31
- package/dist/runtime/registry/umami-analytics.js +2 -36
- package/dist/runtime/registry/vercel-analytics.d.ts +29 -0
- package/dist/runtime/registry/vercel-analytics.js +84 -0
- package/dist/runtime/registry/vimeo-player.d.ts +2 -2
- package/dist/runtime/registry/vimeo-player.js +1 -1
- package/dist/runtime/registry/x-embed.d.ts +3 -17
- package/dist/runtime/registry/x-embed.js +3 -18
- package/dist/runtime/registry/x-pixel.d.ts +4 -7
- package/dist/runtime/registry/x-pixel.js +2 -5
- package/dist/runtime/registry/youtube-player.d.ts +7 -7
- package/dist/runtime/registry/youtube-player.js +1 -1
- package/dist/runtime/server/{sw-handler.d.ts → bluesky-embed-image.d.ts} +1 -1
- package/dist/runtime/server/bluesky-embed-image.js +7 -0
- package/dist/runtime/server/bluesky-embed.d.ts +16 -0
- package/dist/runtime/server/bluesky-embed.js +59 -0
- package/dist/runtime/server/google-maps-geocode-proxy.d.ts +2 -0
- package/dist/runtime/server/google-maps-geocode-proxy.js +34 -0
- package/dist/runtime/server/google-static-maps-proxy.js +2 -13
- package/dist/runtime/server/gravatar-proxy.d.ts +2 -0
- package/dist/runtime/server/gravatar-proxy.js +46 -0
- package/dist/runtime/server/instagram-embed-asset.js +8 -41
- package/dist/runtime/server/instagram-embed-image.js +6 -53
- package/dist/runtime/server/instagram-embed.d.ts +16 -0
- package/dist/runtime/server/instagram-embed.js +173 -35
- package/dist/runtime/server/proxy-handler.js +144 -113
- package/dist/runtime/server/utils/image-proxy.d.ts +12 -0
- package/dist/runtime/server/utils/image-proxy.js +70 -0
- package/dist/runtime/server/utils/privacy.d.ts +1 -2
- package/dist/runtime/server/utils/privacy.js +54 -34
- package/dist/runtime/server/x-embed-image.js +5 -49
- package/dist/runtime/server/x-embed.js +3 -2
- package/dist/runtime/types.d.ts +74 -40
- package/dist/runtime/utils/pure.d.ts +1 -5
- package/dist/runtime/utils/pure.js +0 -67
- package/dist/runtime/utils.d.ts +4 -3
- package/dist/runtime/utils.js +24 -10
- package/dist/shared/scripts.D7e2ENu6.mjs +211 -0
- package/dist/stats.d.mts +202 -0
- package/dist/stats.d.ts +202 -0
- package/dist/stats.mjs +3860 -0
- package/dist/types-source.d.mts +17 -0
- package/dist/types-source.d.ts +17 -0
- package/dist/types-source.mjs +3614 -0
- package/package.json +52 -38
- package/dist/client/_nuxt/D-kOnTuH.js +0 -162
- package/dist/client/_nuxt/builds/meta/f1474569-6922-450d-bc3f-4fd5f3e1391a.json +0 -1
- package/dist/client/_nuxt/entry.D45OuV0w.css +0 -1
- package/dist/client/_nuxt/error-404.B57D-jUQ.css +0 -1
- package/dist/client/_nuxt/error-500.DTHUW7BI.css +0 -1
- package/dist/runtime/components/ScriptPayPalMarks.d.vue.ts +0 -52
- package/dist/runtime/components/ScriptPayPalMarks.vue +0 -69
- package/dist/runtime/components/ScriptPayPalMarks.vue.d.ts +0 -52
- package/dist/runtime/plugins/sw-register.client.d.ts +0 -2
- package/dist/runtime/plugins/sw-register.client.js +0 -12
- package/dist/runtime/server/sw-handler.js +0 -25
- package/dist/runtime/sw/proxy-sw.template.d.ts +0 -1
- package/dist/runtime/sw/proxy-sw.template.js +0 -54
|
@@ -17,12 +17,9 @@ export interface PlaceholderOptions {
|
|
|
17
17
|
key?: string;
|
|
18
18
|
signature?: string;
|
|
19
19
|
}
|
|
20
|
-
import type { HTMLAttributes, ImgHTMLAttributes, InjectionKey, Ref, ReservedProps, ShallowRef } from 'vue';
|
|
21
20
|
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
mapsApi: Ref<typeof google.maps | undefined>;
|
|
25
|
-
}>;
|
|
21
|
+
import type { HTMLAttributes, ImgHTMLAttributes, Ref, ReservedProps, ShallowRef } from 'vue';
|
|
22
|
+
export { MAP_INJECTION_KEY } from './injectionKeys.js';
|
|
26
23
|
declare const _default: typeof __VLS_export;
|
|
27
24
|
export default _default;
|
|
28
25
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -43,6 +40,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
43
40
|
* A latitude / longitude of where to focus the map.
|
|
44
41
|
*/
|
|
45
42
|
center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
|
|
43
|
+
/**
|
|
44
|
+
* Zoom level for the map (0-21). Reactive: changing this will update the map.
|
|
45
|
+
* Takes precedence over mapOptions.zoom when provided.
|
|
46
|
+
*/
|
|
47
|
+
zoom?: number;
|
|
46
48
|
/**
|
|
47
49
|
* Should a marker be displayed on the map where the centre is.
|
|
48
50
|
*/
|
|
@@ -107,7 +109,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
107
109
|
readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
108
110
|
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
109
111
|
readonly createAdvancedMapMarker: (_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) => Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
110
|
-
readonly
|
|
112
|
+
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
111
113
|
readonly importLibrary: {
|
|
112
114
|
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
113
115
|
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
@@ -122,7 +124,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
122
124
|
readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
123
125
|
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
124
126
|
readonly createAdvancedMapMarker: (_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) => Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
125
|
-
readonly
|
|
127
|
+
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
126
128
|
readonly importLibrary: {
|
|
127
129
|
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
128
130
|
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
@@ -150,6 +152,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
150
152
|
* A latitude / longitude of where to focus the map.
|
|
151
153
|
*/
|
|
152
154
|
center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
|
|
155
|
+
/**
|
|
156
|
+
* Zoom level for the map (0-21). Reactive: changing this will update the map.
|
|
157
|
+
* Takes precedence over mapOptions.zoom when provided.
|
|
158
|
+
*/
|
|
159
|
+
zoom?: number;
|
|
153
160
|
/**
|
|
154
161
|
* Should a marker be displayed on the map where the centre is.
|
|
155
162
|
*/
|
|
@@ -216,7 +223,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
216
223
|
readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
217
224
|
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
218
225
|
readonly createAdvancedMapMarker: (_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) => Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
219
|
-
readonly
|
|
226
|
+
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
220
227
|
readonly importLibrary: {
|
|
221
228
|
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
222
229
|
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
@@ -228,9 +235,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
228
235
|
}) => any) | undefined;
|
|
229
236
|
}>, {
|
|
230
237
|
trigger: ElementScriptTrigger;
|
|
231
|
-
centerMarker: boolean;
|
|
232
238
|
width: number | string;
|
|
233
239
|
height: number | string;
|
|
240
|
+
centerMarker: boolean;
|
|
234
241
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
235
242
|
placeholder?: (props: {
|
|
236
243
|
placeholder: string;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import { computed, onBeforeUnmount, onMounted, ref, watch, toRaw, provide, shallowRef } from "vue";
|
|
3
|
-
import { withQuery } from "ufo";
|
|
4
|
-
import { defu } from "defu";
|
|
5
|
-
import { hash } from "ohash";
|
|
6
|
-
import { tryUseNuxtApp, useHead, useRuntimeConfig } from "nuxt/app";
|
|
7
|
-
import { scriptRuntimeConfig } from "#nuxt-scripts/utils";
|
|
8
2
|
import { useScriptTriggerElement } from "#nuxt-scripts/composables/useScriptTriggerElement";
|
|
9
3
|
import { useScriptGoogleMaps } from "#nuxt-scripts/registry/google-maps";
|
|
4
|
+
import { scriptRuntimeConfig } from "#nuxt-scripts/utils";
|
|
5
|
+
import { defu } from "defu";
|
|
6
|
+
import { tryUseNuxtApp, useHead, useRuntimeConfig } from "nuxt/app";
|
|
7
|
+
import { hash } from "ohash";
|
|
8
|
+
import { withQuery } from "ufo";
|
|
9
|
+
import { computed, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRaw, watch } from "vue";
|
|
10
10
|
import ScriptAriaLoadingIndicator from "../ScriptAriaLoadingIndicator.vue";
|
|
11
|
-
|
|
11
|
+
import { MAP_INJECTION_KEY } from "./injectionKeys";
|
|
12
|
+
export { MAP_INJECTION_KEY } from "./injectionKeys";
|
|
12
13
|
</script>
|
|
13
14
|
|
|
14
15
|
<script setup>
|
|
@@ -17,6 +18,7 @@ const props = defineProps({
|
|
|
17
18
|
aboveTheFold: { type: Boolean, required: false },
|
|
18
19
|
apiKey: { type: String, required: false },
|
|
19
20
|
center: { type: null, required: false },
|
|
21
|
+
zoom: { type: Number, required: false },
|
|
20
22
|
centerMarker: { type: Boolean, required: false, default: true },
|
|
21
23
|
mapOptions: { type: null, required: false },
|
|
22
24
|
region: { type: String, required: false },
|
|
@@ -50,8 +52,12 @@ const currentMapId = computed(() => {
|
|
|
50
52
|
return props.mapIds[currentColorMode.value] || props.mapIds.light || props.mapOptions?.mapId;
|
|
51
53
|
});
|
|
52
54
|
const mapsApi = ref();
|
|
53
|
-
if (import.meta.dev
|
|
54
|
-
|
|
55
|
+
if (import.meta.dev) {
|
|
56
|
+
if (!apiKey)
|
|
57
|
+
throw new Error("GoogleMaps requires an API key. Enable it in your nuxt.config:\n\n scripts: {\n registry: {\n googleMaps: true\n }\n }\n\nThen set NUXT_PUBLIC_SCRIPTS_GOOGLE_MAPS_API_KEY in your .env file.\n\nAlternatively, pass `api-key` directly on the <ScriptGoogleMaps> component (note: this exposes the key client-side).");
|
|
58
|
+
if (!proxyConfig?.enabled && !props.apiKey)
|
|
59
|
+
console.warn("[nuxt-scripts] Google Maps proxy is not enabled. Enable `googleMaps` in your nuxt.config registry to keep your API key server-side. See: https://scripts.nuxt.com/scripts/google-maps#setup");
|
|
60
|
+
}
|
|
55
61
|
const rootEl = ref();
|
|
56
62
|
const mapEl = ref();
|
|
57
63
|
const centerOverride = ref();
|
|
@@ -67,7 +73,7 @@ const { load, status, onLoaded } = useScriptGoogleMaps({
|
|
|
67
73
|
});
|
|
68
74
|
const options = computed(() => {
|
|
69
75
|
const mapId = props.mapOptions?.styles ? void 0 : currentMapId.value || "map";
|
|
70
|
-
return defu({ center: centerOverride.value, mapId }, props.mapOptions, {
|
|
76
|
+
return defu({ center: centerOverride.value, mapId, zoom: props.zoom }, props.mapOptions, {
|
|
71
77
|
center: props.center,
|
|
72
78
|
zoom: 15
|
|
73
79
|
});
|
|
@@ -78,14 +84,11 @@ const mapMarkers = ref(/* @__PURE__ */ new Map());
|
|
|
78
84
|
function isLocationQuery(s) {
|
|
79
85
|
return typeof s === "string" && (s.split(",").length > 2 || s.includes("+"));
|
|
80
86
|
}
|
|
81
|
-
function resetMapMarkerMap(_marker) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
resolve();
|
|
88
|
-
});
|
|
87
|
+
async function resetMapMarkerMap(_marker) {
|
|
88
|
+
const marker = _marker instanceof Promise ? await _marker : _marker;
|
|
89
|
+
if (marker) {
|
|
90
|
+
marker.setMap(null);
|
|
91
|
+
}
|
|
89
92
|
}
|
|
90
93
|
function normalizeAdvancedMapMarkerOptions(_options) {
|
|
91
94
|
const opts = typeof _options === "string" ? {
|
|
@@ -109,24 +112,36 @@ async function createAdvancedMapMarker(_options) {
|
|
|
109
112
|
const key = hash({ position: normalizedOptions.position });
|
|
110
113
|
if (mapMarkers.value.has(key))
|
|
111
114
|
return mapMarkers.value.get(key);
|
|
112
|
-
const p =
|
|
113
|
-
const lib = await importLibrary("marker");
|
|
115
|
+
const p = importLibrary("marker").then((lib) => {
|
|
114
116
|
const mapMarkerOptions = {
|
|
115
117
|
...toRaw(normalizedOptions),
|
|
116
118
|
map: toRaw(map.value)
|
|
117
119
|
};
|
|
118
|
-
|
|
120
|
+
return new lib.AdvancedMarkerElement(mapMarkerOptions);
|
|
119
121
|
});
|
|
120
122
|
mapMarkers.value.set(key, p);
|
|
121
123
|
return p;
|
|
122
124
|
}
|
|
123
125
|
const queryToLatLngCache = /* @__PURE__ */ new Map();
|
|
124
|
-
async function
|
|
126
|
+
async function resolveQueryToLatLng(query) {
|
|
125
127
|
if (query && typeof query === "object")
|
|
126
128
|
return Promise.resolve(query);
|
|
127
129
|
if (queryToLatLngCache.has(query)) {
|
|
128
130
|
return Promise.resolve(queryToLatLngCache.get(query));
|
|
129
131
|
}
|
|
132
|
+
const endpoints = runtimeConfig.public["nuxt-scripts"]?.endpoints;
|
|
133
|
+
if (endpoints?.googleMaps) {
|
|
134
|
+
const data = await $fetch("/_scripts/proxy/google-maps-geocode", {
|
|
135
|
+
params: { address: query }
|
|
136
|
+
});
|
|
137
|
+
if (data.status === "OK" && data.results?.[0]?.geometry?.location) {
|
|
138
|
+
const loc = data.results[0].geometry.location;
|
|
139
|
+
const latLng = { lat: loc.lat, lng: loc.lng };
|
|
140
|
+
queryToLatLngCache.set(query, latLng);
|
|
141
|
+
return latLng;
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`No location found for ${query}`);
|
|
144
|
+
}
|
|
130
145
|
return new Promise(async (resolve, reject) => {
|
|
131
146
|
if (!mapsApi.value) {
|
|
132
147
|
await load();
|
|
@@ -175,11 +190,21 @@ const googleMaps = {
|
|
|
175
190
|
googleMaps: mapsApi,
|
|
176
191
|
map,
|
|
177
192
|
createAdvancedMapMarker,
|
|
178
|
-
|
|
193
|
+
resolveQueryToLatLng,
|
|
179
194
|
importLibrary
|
|
180
195
|
};
|
|
181
196
|
defineExpose(googleMaps);
|
|
182
|
-
|
|
197
|
+
let activeInfoWindow;
|
|
198
|
+
provide(MAP_INJECTION_KEY, {
|
|
199
|
+
map,
|
|
200
|
+
mapsApi,
|
|
201
|
+
activateInfoWindow(iw) {
|
|
202
|
+
if (activeInfoWindow && activeInfoWindow !== iw) {
|
|
203
|
+
activeInfoWindow.close();
|
|
204
|
+
}
|
|
205
|
+
activeInfoWindow = iw;
|
|
206
|
+
}
|
|
207
|
+
});
|
|
183
208
|
onMounted(() => {
|
|
184
209
|
watch(ready, (v) => {
|
|
185
210
|
if (v) {
|
|
@@ -229,7 +254,7 @@ onMounted(() => {
|
|
|
229
254
|
let center = toRaw(next[0]);
|
|
230
255
|
if (center) {
|
|
231
256
|
if (isLocationQuery(center) && ready.value) {
|
|
232
|
-
center = await
|
|
257
|
+
center = await resolveQueryToLatLng(center);
|
|
233
258
|
}
|
|
234
259
|
map.value.setCenter(center);
|
|
235
260
|
if (props.centerMarker) {
|
|
@@ -260,7 +285,7 @@ onMounted(() => {
|
|
|
260
285
|
};
|
|
261
286
|
map.value = new mapsApi.value.Map(mapEl.value, _options);
|
|
262
287
|
if (center && isLocationQuery(center)) {
|
|
263
|
-
centerOverride.value = await
|
|
288
|
+
centerOverride.value = await resolveQueryToLatLng(center);
|
|
264
289
|
map.value?.setCenter(centerOverride.value);
|
|
265
290
|
}
|
|
266
291
|
ready.value = true;
|
|
@@ -321,7 +346,7 @@ const placeholder = computed(() => {
|
|
|
321
346
|
return m;
|
|
322
347
|
}).join("|")
|
|
323
348
|
});
|
|
324
|
-
const baseUrl = proxyConfig?.enabled ? "/_scripts/google-static-maps
|
|
349
|
+
const baseUrl = proxyConfig?.enabled ? "/_scripts/proxy/google-static-maps" : "https://maps.googleapis.com/maps/api/staticmap";
|
|
325
350
|
return withQuery(baseUrl, placeholderOptions);
|
|
326
351
|
});
|
|
327
352
|
const placeholderAttrs = computed(() => {
|
|
@@ -354,12 +379,14 @@ const rootAttrs = computed(() => {
|
|
|
354
379
|
...trigger instanceof Promise ? trigger.ssrAttrs || {} : {}
|
|
355
380
|
});
|
|
356
381
|
});
|
|
357
|
-
onBeforeUnmount(
|
|
358
|
-
await Promise.all([...mapMarkers.value.entries()].map(([, marker]) => resetMapMarkerMap(marker)));
|
|
359
|
-
mapMarkers.value.clear();
|
|
382
|
+
onBeforeUnmount(() => {
|
|
360
383
|
map.value?.unbindAll();
|
|
361
384
|
map.value = void 0;
|
|
362
385
|
mapEl.value?.firstChild?.remove();
|
|
386
|
+
libraries.clear();
|
|
387
|
+
queryToLatLngCache.clear();
|
|
388
|
+
Promise.all(Array.from(mapMarkers.value.entries(), ([, marker]) => resetMapMarkerMap(marker)));
|
|
389
|
+
mapMarkers.value.clear();
|
|
363
390
|
});
|
|
364
391
|
</script>
|
|
365
392
|
|
|
@@ -17,12 +17,9 @@ export interface PlaceholderOptions {
|
|
|
17
17
|
key?: string;
|
|
18
18
|
signature?: string;
|
|
19
19
|
}
|
|
20
|
-
import type { HTMLAttributes, ImgHTMLAttributes, InjectionKey, Ref, ReservedProps, ShallowRef } from 'vue';
|
|
21
20
|
import type { ElementScriptTrigger } from '#nuxt-scripts/types';
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
mapsApi: Ref<typeof google.maps | undefined>;
|
|
25
|
-
}>;
|
|
21
|
+
import type { HTMLAttributes, ImgHTMLAttributes, Ref, ReservedProps, ShallowRef } from 'vue';
|
|
22
|
+
export { MAP_INJECTION_KEY } from './injectionKeys.js';
|
|
26
23
|
declare const _default: typeof __VLS_export;
|
|
27
24
|
export default _default;
|
|
28
25
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
@@ -43,6 +40,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
43
40
|
* A latitude / longitude of where to focus the map.
|
|
44
41
|
*/
|
|
45
42
|
center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
|
|
43
|
+
/**
|
|
44
|
+
* Zoom level for the map (0-21). Reactive: changing this will update the map.
|
|
45
|
+
* Takes precedence over mapOptions.zoom when provided.
|
|
46
|
+
*/
|
|
47
|
+
zoom?: number;
|
|
46
48
|
/**
|
|
47
49
|
* Should a marker be displayed on the map where the centre is.
|
|
48
50
|
*/
|
|
@@ -107,7 +109,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
107
109
|
readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
108
110
|
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
109
111
|
readonly createAdvancedMapMarker: (_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) => Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
110
|
-
readonly
|
|
112
|
+
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
111
113
|
readonly importLibrary: {
|
|
112
114
|
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
113
115
|
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
@@ -122,7 +124,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
122
124
|
readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
123
125
|
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
124
126
|
readonly createAdvancedMapMarker: (_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) => Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
125
|
-
readonly
|
|
127
|
+
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
126
128
|
readonly importLibrary: {
|
|
127
129
|
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
128
130
|
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
@@ -150,6 +152,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
150
152
|
* A latitude / longitude of where to focus the map.
|
|
151
153
|
*/
|
|
152
154
|
center?: google.maps.LatLng | google.maps.LatLngLiteral | `${string},${string}`;
|
|
155
|
+
/**
|
|
156
|
+
* Zoom level for the map (0-21). Reactive: changing this will update the map.
|
|
157
|
+
* Takes precedence over mapOptions.zoom when provided.
|
|
158
|
+
*/
|
|
159
|
+
zoom?: number;
|
|
153
160
|
/**
|
|
154
161
|
* Should a marker be displayed on the map where the centre is.
|
|
155
162
|
*/
|
|
@@ -216,7 +223,7 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
216
223
|
readonly googleMaps: Ref<typeof google.maps | undefined, typeof google.maps | undefined>;
|
|
217
224
|
readonly map: ShallowRef<google.maps.Map | undefined>;
|
|
218
225
|
readonly createAdvancedMapMarker: (_options?: google.maps.marker.AdvancedMarkerElementOptions | `${string},${string}`) => Promise<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
219
|
-
readonly
|
|
226
|
+
readonly resolveQueryToLatLng: (query: string) => Promise<google.maps.LatLng | google.maps.LatLngLiteral | undefined>;
|
|
220
227
|
readonly importLibrary: {
|
|
221
228
|
(key: "marker"): Promise<google.maps.MarkerLibrary>;
|
|
222
229
|
(key: "places"): Promise<google.maps.PlacesLibrary>;
|
|
@@ -228,9 +235,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
228
235
|
}) => any) | undefined;
|
|
229
236
|
}>, {
|
|
230
237
|
trigger: ElementScriptTrigger;
|
|
231
|
-
centerMarker: boolean;
|
|
232
238
|
width: number | string;
|
|
233
239
|
height: number | string;
|
|
240
|
+
centerMarker: boolean;
|
|
234
241
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
235
242
|
placeholder?: (props: {
|
|
236
243
|
placeholder: string;
|
|
@@ -1,58 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ADVANCED_MARKER_ELEMENT_INJECTION_KEY: InjectionKey<{
|
|
3
|
-
advancedMarkerElement: ShallowRef<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
4
|
-
}>;
|
|
1
|
+
export { ADVANCED_MARKER_ELEMENT_INJECTION_KEY } from './injectionKeys.js';
|
|
5
2
|
declare const _default: typeof __VLS_export;
|
|
6
3
|
export default _default;
|
|
7
4
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
5
|
+
/**
|
|
6
|
+
* The position of the marker on the map.
|
|
7
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions.position
|
|
8
|
+
*/
|
|
9
|
+
position?: google.maps.LatLngLiteral | google.maps.LatLng;
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for the advanced marker.
|
|
12
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions
|
|
13
|
+
*/
|
|
8
14
|
options?: Omit<google.maps.marker.AdvancedMarkerElementOptions, "map">;
|
|
9
|
-
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
16
|
click: (payload: google.maps.MapMouseEvent) => any;
|
|
11
|
-
contextmenu: (payload: google.maps.MapMouseEvent) => any;
|
|
12
|
-
dblclick: (payload: google.maps.MapMouseEvent) => any;
|
|
13
17
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
14
18
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
15
19
|
dragstart: (payload: google.maps.MapMouseEvent) => any;
|
|
16
|
-
mousedown: (payload: google.maps.MapMouseEvent) => any;
|
|
17
|
-
mouseout: (payload: google.maps.MapMouseEvent) => any;
|
|
18
|
-
mouseover: (payload: google.maps.MapMouseEvent) => any;
|
|
19
|
-
mouseup: (payload: google.maps.MapMouseEvent) => any;
|
|
20
|
-
animation_changed: () => any;
|
|
21
|
-
clickable_changed: () => any;
|
|
22
|
-
cursor_changed: () => any;
|
|
23
|
-
draggable_changed: () => any;
|
|
24
|
-
flat_changed: () => any;
|
|
25
|
-
icon_changed: () => any;
|
|
26
|
-
position_changed: () => any;
|
|
27
|
-
shape_changed: () => any;
|
|
28
|
-
title_changed: () => any;
|
|
29
|
-
visible_changed: () => any;
|
|
30
|
-
zindex_changed: () => any;
|
|
31
20
|
}, string, import("vue").PublicProps, Readonly<{
|
|
21
|
+
/**
|
|
22
|
+
* The position of the marker on the map.
|
|
23
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions.position
|
|
24
|
+
*/
|
|
25
|
+
position?: google.maps.LatLngLiteral | google.maps.LatLng;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for the advanced marker.
|
|
28
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions
|
|
29
|
+
*/
|
|
32
30
|
options?: Omit<google.maps.marker.AdvancedMarkerElementOptions, "map">;
|
|
33
31
|
}> & Readonly<{
|
|
34
32
|
onClick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
35
|
-
onContextmenu?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
36
|
-
onDblclick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
37
33
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
38
34
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
39
35
|
onDragstart?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
40
|
-
onMousedown?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
41
|
-
onMouseout?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
42
|
-
onMouseover?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
43
|
-
onMouseup?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
44
|
-
onAnimation_changed?: (() => any) | undefined;
|
|
45
|
-
onClickable_changed?: (() => any) | undefined;
|
|
46
|
-
onCursor_changed?: (() => any) | undefined;
|
|
47
|
-
onDraggable_changed?: (() => any) | undefined;
|
|
48
|
-
onFlat_changed?: (() => any) | undefined;
|
|
49
|
-
onIcon_changed?: (() => any) | undefined;
|
|
50
|
-
onPosition_changed?: (() => any) | undefined;
|
|
51
|
-
onShape_changed?: (() => any) | undefined;
|
|
52
|
-
onTitle_changed?: (() => any) | undefined;
|
|
53
|
-
onVisible_changed?: (() => any) | undefined;
|
|
54
|
-
onZindex_changed?: (() => any) | undefined;
|
|
55
36
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
37
|
+
content?: (props: {}) => any;
|
|
38
|
+
} & {
|
|
56
39
|
default?: (props: {}) => any;
|
|
57
40
|
}>;
|
|
58
41
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,86 +1,83 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot v-if="advancedMarkerElement" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
1
|
<script>
|
|
6
|
-
import { inject,
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { inject, provide, useSlots, useTemplateRef, watch } from "vue";
|
|
3
|
+
import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
|
|
4
|
+
import { ADVANCED_MARKER_ELEMENT_INJECTION_KEY } from "./injectionKeys";
|
|
9
5
|
import { MARKER_CLUSTERER_INJECTION_KEY } from "./ScriptGoogleMapsMarkerClusterer.vue";
|
|
10
|
-
|
|
6
|
+
import { useGoogleMapsResource } from "./useGoogleMapsResource";
|
|
7
|
+
export { ADVANCED_MARKER_ELEMENT_INJECTION_KEY } from "./injectionKeys";
|
|
11
8
|
</script>
|
|
12
9
|
|
|
13
10
|
<script setup>
|
|
14
11
|
const props = defineProps({
|
|
12
|
+
position: { type: null, required: false },
|
|
15
13
|
options: { type: Object, required: false }
|
|
16
14
|
});
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"draggable_changed",
|
|
22
|
-
"flat_changed",
|
|
23
|
-
"icon_changed",
|
|
24
|
-
"position_changed",
|
|
25
|
-
"shape_changed",
|
|
26
|
-
"title_changed",
|
|
27
|
-
"visible_changed",
|
|
28
|
-
"zindex_changed"
|
|
29
|
-
];
|
|
30
|
-
const eventsWithMapMouseEventPayload = [
|
|
31
|
-
"click",
|
|
32
|
-
"contextmenu",
|
|
33
|
-
"dblclick",
|
|
34
|
-
"drag",
|
|
35
|
-
"dragend",
|
|
36
|
-
"dragstart",
|
|
37
|
-
"mousedown",
|
|
38
|
-
"mouseout",
|
|
39
|
-
"mouseover",
|
|
40
|
-
"mouseup"
|
|
41
|
-
];
|
|
42
|
-
const emit = defineEmits([]);
|
|
43
|
-
const mapContext = inject(MAP_INJECTION_KEY, void 0);
|
|
15
|
+
const emit = defineEmits(["click", "drag", "dragend", "dragstart"]);
|
|
16
|
+
const dragEvents = ["drag", "dragend", "dragstart"];
|
|
17
|
+
const slots = useSlots();
|
|
18
|
+
const markerContent = useTemplateRef("marker-content");
|
|
44
19
|
const markerClustererContext = inject(MARKER_CLUSTERER_INJECTION_KEY, void 0);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
20
|
+
let gmpClickHandler;
|
|
21
|
+
const advancedMarkerElement = useGoogleMapsResource({
|
|
22
|
+
ready: () => !slots.content || !!markerContent.value,
|
|
23
|
+
async create({ mapsApi, map }) {
|
|
24
|
+
await mapsApi.importLibrary("marker");
|
|
25
|
+
const marker = new mapsApi.marker.AdvancedMarkerElement({
|
|
26
|
+
...props.options,
|
|
27
|
+
gmpClickable: true,
|
|
28
|
+
...props.position ? { position: props.position } : {}
|
|
29
|
+
});
|
|
30
|
+
if (markerContent.value) {
|
|
31
|
+
marker.content = markerContent.value;
|
|
32
|
+
}
|
|
33
|
+
if (markerClustererContext?.markerClusterer.value) {
|
|
34
|
+
markerClustererContext.markerClusterer.value.addMarker(marker, true);
|
|
35
|
+
markerClustererContext.requestRerender();
|
|
36
|
+
} else {
|
|
37
|
+
marker.map = map;
|
|
38
|
+
}
|
|
39
|
+
gmpClickHandler = (e) => emit("click", e);
|
|
40
|
+
marker.addEventListener("gmp-click", gmpClickHandler);
|
|
41
|
+
bindGoogleMapsEvents(marker, emit, {
|
|
42
|
+
withPayload: dragEvents
|
|
43
|
+
});
|
|
44
|
+
return marker;
|
|
45
|
+
},
|
|
46
|
+
cleanup(marker, { mapsApi }) {
|
|
47
|
+
if (gmpClickHandler) {
|
|
48
|
+
marker.removeEventListener("gmp-click", gmpClickHandler);
|
|
49
|
+
gmpClickHandler = void 0;
|
|
50
|
+
}
|
|
51
|
+
mapsApi.event.clearInstanceListeners(marker);
|
|
52
|
+
if (markerClustererContext?.markerClusterer.value) {
|
|
53
|
+
markerClustererContext.markerClusterer.value.removeMarker(marker, true);
|
|
54
|
+
markerClustererContext.requestRerender();
|
|
55
|
+
} else {
|
|
56
|
+
marker.map = null;
|
|
58
57
|
}
|
|
59
|
-
}, {
|
|
60
|
-
deep: true
|
|
61
|
-
});
|
|
62
|
-
}, {
|
|
63
|
-
immediate: true,
|
|
64
|
-
once: true
|
|
65
|
-
});
|
|
66
|
-
onUnmounted(() => {
|
|
67
|
-
if (!advancedMarkerElement.value || !mapContext?.mapsApi.value) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
mapContext.mapsApi.value.event.clearInstanceListeners(advancedMarkerElement.value);
|
|
71
|
-
if (markerClustererContext) {
|
|
72
|
-
markerClustererContext.markerClusterer.value?.removeMarker(advancedMarkerElement.value);
|
|
73
|
-
} else {
|
|
74
|
-
advancedMarkerElement.value.map = null;
|
|
75
58
|
}
|
|
76
59
|
});
|
|
60
|
+
watch(
|
|
61
|
+
() => [props.position, props.options],
|
|
62
|
+
() => {
|
|
63
|
+
if (!advancedMarkerElement.value)
|
|
64
|
+
return;
|
|
65
|
+
if (props.options)
|
|
66
|
+
Object.assign(advancedMarkerElement.value, props.options);
|
|
67
|
+
advancedMarkerElement.value.position = props.position ?? props.options?.position;
|
|
68
|
+
},
|
|
69
|
+
{ deep: true }
|
|
70
|
+
);
|
|
77
71
|
provide(ADVANCED_MARKER_ELEMENT_INJECTION_KEY, { advancedMarkerElement });
|
|
78
|
-
function setupAdvancedMarkerElementEventListeners(advancedMarkerElement2) {
|
|
79
|
-
eventsWithoutPayload.forEach((event) => {
|
|
80
|
-
advancedMarkerElement2.addListener(event, () => emit(event));
|
|
81
|
-
});
|
|
82
|
-
eventsWithMapMouseEventPayload.forEach((event) => {
|
|
83
|
-
advancedMarkerElement2.addListener(event, (payload) => emit(event, payload));
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
72
|
</script>
|
|
73
|
+
|
|
74
|
+
<template>
|
|
75
|
+
<!-- Hidden container for #content slot — becomes the marker visual -->
|
|
76
|
+
<div v-if="$slots.content" style="display: none;">
|
|
77
|
+
<div ref="marker-content">
|
|
78
|
+
<slot name="content" />
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
<!-- Default slot for child components (InfoWindow, OverlayView, etc.) -->
|
|
82
|
+
<slot v-if="advancedMarkerElement" />
|
|
83
|
+
</template>
|
|
@@ -1,58 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ADVANCED_MARKER_ELEMENT_INJECTION_KEY: InjectionKey<{
|
|
3
|
-
advancedMarkerElement: ShallowRef<google.maps.marker.AdvancedMarkerElement | undefined>;
|
|
4
|
-
}>;
|
|
1
|
+
export { ADVANCED_MARKER_ELEMENT_INJECTION_KEY } from './injectionKeys.js';
|
|
5
2
|
declare const _default: typeof __VLS_export;
|
|
6
3
|
export default _default;
|
|
7
4
|
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
5
|
+
/**
|
|
6
|
+
* The position of the marker on the map.
|
|
7
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions.position
|
|
8
|
+
*/
|
|
9
|
+
position?: google.maps.LatLngLiteral | google.maps.LatLng;
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for the advanced marker.
|
|
12
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions
|
|
13
|
+
*/
|
|
8
14
|
options?: Omit<google.maps.marker.AdvancedMarkerElementOptions, "map">;
|
|
9
|
-
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
16
|
click: (payload: google.maps.MapMouseEvent) => any;
|
|
11
|
-
contextmenu: (payload: google.maps.MapMouseEvent) => any;
|
|
12
|
-
dblclick: (payload: google.maps.MapMouseEvent) => any;
|
|
13
17
|
drag: (payload: google.maps.MapMouseEvent) => any;
|
|
14
18
|
dragend: (payload: google.maps.MapMouseEvent) => any;
|
|
15
19
|
dragstart: (payload: google.maps.MapMouseEvent) => any;
|
|
16
|
-
mousedown: (payload: google.maps.MapMouseEvent) => any;
|
|
17
|
-
mouseout: (payload: google.maps.MapMouseEvent) => any;
|
|
18
|
-
mouseover: (payload: google.maps.MapMouseEvent) => any;
|
|
19
|
-
mouseup: (payload: google.maps.MapMouseEvent) => any;
|
|
20
|
-
animation_changed: () => any;
|
|
21
|
-
clickable_changed: () => any;
|
|
22
|
-
cursor_changed: () => any;
|
|
23
|
-
draggable_changed: () => any;
|
|
24
|
-
flat_changed: () => any;
|
|
25
|
-
icon_changed: () => any;
|
|
26
|
-
position_changed: () => any;
|
|
27
|
-
shape_changed: () => any;
|
|
28
|
-
title_changed: () => any;
|
|
29
|
-
visible_changed: () => any;
|
|
30
|
-
zindex_changed: () => any;
|
|
31
20
|
}, string, import("vue").PublicProps, Readonly<{
|
|
21
|
+
/**
|
|
22
|
+
* The position of the marker on the map.
|
|
23
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions.position
|
|
24
|
+
*/
|
|
25
|
+
position?: google.maps.LatLngLiteral | google.maps.LatLng;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for the advanced marker.
|
|
28
|
+
* @see https://developers.google.com/maps/documentation/javascript/reference/advanced-markers#AdvancedMarkerElementOptions
|
|
29
|
+
*/
|
|
32
30
|
options?: Omit<google.maps.marker.AdvancedMarkerElementOptions, "map">;
|
|
33
31
|
}> & Readonly<{
|
|
34
32
|
onClick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
35
|
-
onContextmenu?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
36
|
-
onDblclick?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
37
33
|
onDrag?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
38
34
|
onDragend?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
39
35
|
onDragstart?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
40
|
-
onMousedown?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
41
|
-
onMouseout?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
42
|
-
onMouseover?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
43
|
-
onMouseup?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
|
|
44
|
-
onAnimation_changed?: (() => any) | undefined;
|
|
45
|
-
onClickable_changed?: (() => any) | undefined;
|
|
46
|
-
onCursor_changed?: (() => any) | undefined;
|
|
47
|
-
onDraggable_changed?: (() => any) | undefined;
|
|
48
|
-
onFlat_changed?: (() => any) | undefined;
|
|
49
|
-
onIcon_changed?: (() => any) | undefined;
|
|
50
|
-
onPosition_changed?: (() => any) | undefined;
|
|
51
|
-
onShape_changed?: (() => any) | undefined;
|
|
52
|
-
onTitle_changed?: (() => any) | undefined;
|
|
53
|
-
onVisible_changed?: (() => any) | undefined;
|
|
54
|
-
onZindex_changed?: (() => any) | undefined;
|
|
55
36
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
37
|
+
content?: (props: {}) => any;
|
|
38
|
+
} & {
|
|
56
39
|
default?: (props: {}) => any;
|
|
57
40
|
}>;
|
|
58
41
|
type __VLS_WithSlots<T, S> = T & {
|