@nuxt/scripts 1.0.0-beta.27 → 1.0.0-beta.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/client/200.html +1 -1
  2. package/dist/client/404.html +1 -1
  3. package/dist/client/_nuxt/{KCxg59bo.js → AwAKM0sG.js} +1 -1
  4. package/dist/client/_nuxt/{CwXQ1Eqw.js → Bl23o3st.js} +18 -18
  5. package/dist/client/_nuxt/{JXDRhrZp.js → CYlYSSNW.js} +1 -1
  6. package/dist/client/_nuxt/{viP3Pc9X.js → D5FIkDae.js} +1 -1
  7. package/dist/client/_nuxt/builds/latest.json +1 -1
  8. package/dist/client/_nuxt/builds/meta/3ca2fe82-918c-4528-826c-0bf9ff54a5fa.json +1 -0
  9. package/dist/client/_nuxt/error-404.1K8v8Su2.css +1 -0
  10. package/dist/client/_nuxt/error-500.B9qvKpQm.css +1 -0
  11. package/dist/client/index.html +1 -1
  12. package/dist/module.json +1 -1
  13. package/dist/module.mjs +12 -1
  14. package/dist/registry.mjs +4 -1
  15. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.d.vue.ts +13 -3
  16. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +12 -7
  17. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue.d.ts +13 -3
  18. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.d.vue.ts +4 -34
  19. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue +37 -36
  20. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsAdvancedMarkerElement.vue.d.ts +4 -34
  21. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsCircle.vue +5 -9
  22. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.d.vue.ts +35 -0
  23. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue +68 -0
  24. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsGeoJson.vue.d.ts +35 -0
  25. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.d.vue.ts +4 -4
  26. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue +2 -6
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsInfoWindow.vue.d.ts +4 -4
  28. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.d.vue.ts +6 -4
  29. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue +18 -10
  30. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsMarker.vue.d.ts +6 -4
  31. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.d.vue.ts +40 -0
  32. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue +168 -0
  33. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsOverlayView.vue.d.ts +40 -0
  34. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolygon.vue +4 -9
  35. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsPolyline.vue +4 -9
  36. package/dist/runtime/components/GoogleMaps/ScriptGoogleMapsRectangle.vue +5 -9
  37. package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.d.ts +13 -0
  38. package/dist/runtime/components/GoogleMaps/bindGoogleMapsEvents.js +8 -0
  39. package/dist/runtime/registry/gravatar.d.ts +1 -0
  40. package/dist/runtime/registry/gravatar.js +1 -0
  41. package/dist/stats.mjs +283 -227
  42. package/dist/types-source.mjs +1247 -67
  43. package/package.json +3 -3
  44. package/dist/client/_nuxt/builds/meta/d0d06e27-af53-4f1a-b7ae-18727423b3ed.json +0 -1
  45. package/dist/client/_nuxt/error-404.C_3_IG5y.css +0 -1
  46. package/dist/client/_nuxt/error-500.DSv6YikH.css +0 -1
@@ -0,0 +1,35 @@
1
+ type __VLS_Props = {
2
+ src: string | object;
3
+ style?: google.maps.Data.StylingFunction | google.maps.Data.StyleOptions;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ contextmenu: (payload: google.maps.Data.MouseEvent) => any;
7
+ click: (payload: google.maps.Data.MouseEvent) => any;
8
+ dblclick: (payload: google.maps.Data.MouseEvent) => any;
9
+ mousedown: (payload: google.maps.Data.MouseEvent) => any;
10
+ mousemove: (payload: google.maps.Data.MouseEvent) => any;
11
+ mouseout: (payload: google.maps.Data.MouseEvent) => any;
12
+ mouseover: (payload: google.maps.Data.MouseEvent) => any;
13
+ mouseup: (payload: google.maps.Data.MouseEvent) => any;
14
+ addfeature: (payload: google.maps.Data.AddFeatureEvent) => any;
15
+ removefeature: (payload: google.maps.Data.RemoveFeatureEvent) => any;
16
+ setgeometry: (payload: google.maps.Data.SetGeometryEvent) => any;
17
+ setproperty: (payload: google.maps.Data.SetPropertyEvent) => any;
18
+ removeproperty: (payload: google.maps.Data.RemovePropertyEvent) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
+ onContextmenu?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
21
+ onClick?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
22
+ onDblclick?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
23
+ onMousedown?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
24
+ onMousemove?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
25
+ onMouseout?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
26
+ onMouseover?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
27
+ onMouseup?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
28
+ onAddfeature?: ((payload: google.maps.Data.AddFeatureEvent) => any) | undefined;
29
+ onRemovefeature?: ((payload: google.maps.Data.RemoveFeatureEvent) => any) | undefined;
30
+ onSetgeometry?: ((payload: google.maps.Data.SetGeometryEvent) => any) | undefined;
31
+ onSetproperty?: ((payload: google.maps.Data.SetPropertyEvent) => any) | undefined;
32
+ onRemoveproperty?: ((payload: google.maps.Data.RemovePropertyEvent) => any) | undefined;
33
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
@@ -0,0 +1,68 @@
1
+ <script setup>
2
+ import { watch } from "vue";
3
+ import { useGoogleMapsResource } from "./useGoogleMapsResource";
4
+ const props = defineProps({
5
+ src: { type: [String, Object], required: true },
6
+ style: { type: null, required: false }
7
+ });
8
+ const emit = defineEmits(["addfeature", "removefeature", "setgeometry", "setproperty", "removeproperty"]);
9
+ const dataEvents = [
10
+ "click",
11
+ "contextmenu",
12
+ "dblclick",
13
+ "mousedown",
14
+ "mousemove",
15
+ "mouseout",
16
+ "mouseover",
17
+ "mouseup"
18
+ ];
19
+ const featureEvents = [
20
+ "addfeature",
21
+ "removefeature",
22
+ "setgeometry",
23
+ "setproperty",
24
+ "removeproperty"
25
+ ];
26
+ function loadGeoJson(src, layer) {
27
+ if (typeof src === "string")
28
+ layer.loadGeoJson(src);
29
+ else
30
+ layer.addGeoJson(src);
31
+ }
32
+ const dataLayer = useGoogleMapsResource({
33
+ create({ mapsApi, map }) {
34
+ const layer = new mapsApi.Data({ map });
35
+ if (props.style)
36
+ layer.setStyle(props.style);
37
+ loadGeoJson(props.src, layer);
38
+ setupEventListeners(layer);
39
+ return layer;
40
+ },
41
+ cleanup(layer, { mapsApi }) {
42
+ mapsApi.event.clearInstanceListeners(layer);
43
+ layer.setMap(null);
44
+ }
45
+ });
46
+ watch(() => props.src, (src) => {
47
+ if (!dataLayer.value)
48
+ return;
49
+ dataLayer.value.forEach((feature) => dataLayer.value.remove(feature));
50
+ loadGeoJson(src, dataLayer.value);
51
+ });
52
+ watch(() => props.style, (style) => {
53
+ if (dataLayer.value)
54
+ dataLayer.value.setStyle(style ?? {});
55
+ }, { deep: true });
56
+ function setupEventListeners(layer) {
57
+ dataEvents.forEach((event) => {
58
+ layer.addListener(event, (payload) => emit(event, payload));
59
+ });
60
+ featureEvents.forEach((event) => {
61
+ layer.addListener(event, (payload) => emit(event, payload));
62
+ });
63
+ }
64
+ </script>
65
+
66
+ <template>
67
+
68
+ </template>
@@ -0,0 +1,35 @@
1
+ type __VLS_Props = {
2
+ src: string | object;
3
+ style?: google.maps.Data.StylingFunction | google.maps.Data.StyleOptions;
4
+ };
5
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
+ contextmenu: (payload: google.maps.Data.MouseEvent) => any;
7
+ click: (payload: google.maps.Data.MouseEvent) => any;
8
+ dblclick: (payload: google.maps.Data.MouseEvent) => any;
9
+ mousedown: (payload: google.maps.Data.MouseEvent) => any;
10
+ mousemove: (payload: google.maps.Data.MouseEvent) => any;
11
+ mouseout: (payload: google.maps.Data.MouseEvent) => any;
12
+ mouseover: (payload: google.maps.Data.MouseEvent) => any;
13
+ mouseup: (payload: google.maps.Data.MouseEvent) => any;
14
+ addfeature: (payload: google.maps.Data.AddFeatureEvent) => any;
15
+ removefeature: (payload: google.maps.Data.RemoveFeatureEvent) => any;
16
+ setgeometry: (payload: google.maps.Data.SetGeometryEvent) => any;
17
+ setproperty: (payload: google.maps.Data.SetPropertyEvent) => any;
18
+ removeproperty: (payload: google.maps.Data.RemovePropertyEvent) => any;
19
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
+ onContextmenu?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
21
+ onClick?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
22
+ onDblclick?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
23
+ onMousedown?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
24
+ onMousemove?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
25
+ onMouseout?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
26
+ onMouseover?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
27
+ onMouseup?: ((payload: google.maps.Data.MouseEvent) => any) | undefined;
28
+ onAddfeature?: ((payload: google.maps.Data.AddFeatureEvent) => any) | undefined;
29
+ onRemovefeature?: ((payload: google.maps.Data.RemoveFeatureEvent) => any) | undefined;
30
+ onSetgeometry?: ((payload: google.maps.Data.SetGeometryEvent) => any) | undefined;
31
+ onSetproperty?: ((payload: google.maps.Data.SetPropertyEvent) => any) | undefined;
32
+ onRemoveproperty?: ((payload: google.maps.Data.RemovePropertyEvent) => any) | undefined;
33
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
@@ -8,23 +8,23 @@ type __VLS_Slots = {} & {
8
8
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
9
  close: () => any;
10
10
  visible: () => any;
11
- position_changed: () => any;
12
- zindex_changed: () => any;
13
11
  closeclick: () => any;
14
12
  content_changed: () => any;
15
13
  domready: () => any;
16
14
  headercontent_changed: () => any;
17
15
  headerdisabled_changed: () => any;
16
+ position_changed: () => any;
17
+ zindex_changed: () => any;
18
18
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
19
  onClose?: (() => any) | undefined;
20
20
  onVisible?: (() => any) | undefined;
21
- onPosition_changed?: (() => any) | undefined;
22
- onZindex_changed?: (() => any) | undefined;
23
21
  onCloseclick?: (() => any) | undefined;
24
22
  onContent_changed?: (() => any) | undefined;
25
23
  onDomready?: (() => any) | undefined;
26
24
  onHeadercontent_changed?: (() => any) | undefined;
27
25
  onHeaderdisabled_changed?: (() => any) | undefined;
26
+ onPosition_changed?: (() => any) | undefined;
27
+ onZindex_changed?: (() => any) | undefined;
28
28
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
29
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
30
30
  declare const _default: typeof __VLS_export;
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { inject, useTemplateRef, watch } from "vue";
3
+ import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
3
4
  import { ADVANCED_MARKER_ELEMENT_INJECTION_KEY, MARKER_INJECTION_KEY } from "./injectionKeys";
4
5
  import { useGoogleMapsResource } from "./useGoogleMapsResource";
5
6
  const props = defineProps({
@@ -28,7 +29,7 @@ const infoWindow = useGoogleMapsResource({
28
29
  content: infoWindowContainer.value,
29
30
  ...props.options
30
31
  });
31
- setupEventListeners(iw);
32
+ bindGoogleMapsEvents(iw, emit, { noPayload: infoWindowEvents });
32
33
  if (markerContext?.marker.value) {
33
34
  markerClickListener = markerContext.marker.value.addListener("click", () => {
34
35
  iw.open({
@@ -61,11 +62,6 @@ watch(() => props.options, (options) => {
61
62
  infoWindow.value.setOptions(options);
62
63
  }
63
64
  }, { deep: true });
64
- function setupEventListeners(iw) {
65
- infoWindowEvents.forEach((event) => {
66
- iw.addListener(event, () => emit(event));
67
- });
68
- }
69
65
  </script>
70
66
 
71
67
  <template>
@@ -8,23 +8,23 @@ type __VLS_Slots = {} & {
8
8
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
9
9
  close: () => any;
10
10
  visible: () => any;
11
- position_changed: () => any;
12
- zindex_changed: () => any;
13
11
  closeclick: () => any;
14
12
  content_changed: () => any;
15
13
  domready: () => any;
16
14
  headercontent_changed: () => any;
17
15
  headerdisabled_changed: () => any;
16
+ position_changed: () => any;
17
+ zindex_changed: () => any;
18
18
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
19
19
  onClose?: (() => any) | undefined;
20
20
  onVisible?: (() => any) | undefined;
21
- onPosition_changed?: (() => any) | undefined;
22
- onZindex_changed?: (() => any) | undefined;
23
21
  onCloseclick?: (() => any) | undefined;
24
22
  onContent_changed?: (() => any) | undefined;
25
23
  onDomready?: (() => any) | undefined;
26
24
  onHeadercontent_changed?: (() => any) | undefined;
27
25
  onHeaderdisabled_changed?: (() => any) | undefined;
26
+ onPosition_changed?: (() => any) | undefined;
27
+ onZindex_changed?: (() => any) | undefined;
28
28
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
29
29
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
30
30
  declare const _default: typeof __VLS_export;
@@ -2,6 +2,7 @@ export { MARKER_INJECTION_KEY } from './injectionKeys.js';
2
2
  declare const _default: typeof __VLS_export;
3
3
  export default _default;
4
4
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
5
+ position?: google.maps.LatLngLiteral | google.maps.LatLng;
5
6
  options?: Omit<google.maps.MarkerOptions, "map">;
6
7
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
8
  contextmenu: (payload: google.maps.MapMouseEvent) => any;
@@ -14,18 +15,19 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
14
15
  mouseout: (payload: google.maps.MapMouseEvent) => any;
15
16
  mouseover: (payload: google.maps.MapMouseEvent) => any;
16
17
  mouseup: (payload: google.maps.MapMouseEvent) => any;
18
+ position_changed: () => any;
19
+ zindex_changed: () => any;
17
20
  animation_changed: () => any;
18
21
  clickable_changed: () => any;
19
22
  cursor_changed: () => any;
20
23
  draggable_changed: () => any;
21
24
  flat_changed: () => any;
22
25
  icon_changed: () => any;
23
- position_changed: () => any;
24
26
  shape_changed: () => any;
25
27
  title_changed: () => any;
26
28
  visible_changed: () => any;
27
- zindex_changed: () => any;
28
29
  }, string, import("vue").PublicProps, Readonly<{
30
+ position?: google.maps.LatLngLiteral | google.maps.LatLng;
29
31
  options?: Omit<google.maps.MarkerOptions, "map">;
30
32
  }> & Readonly<{
31
33
  onContextmenu?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
@@ -38,17 +40,17 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
38
40
  onMouseout?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
39
41
  onMouseover?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
40
42
  onMouseup?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
43
+ onPosition_changed?: (() => any) | undefined;
44
+ onZindex_changed?: (() => any) | undefined;
41
45
  onAnimation_changed?: (() => any) | undefined;
42
46
  onClickable_changed?: (() => any) | undefined;
43
47
  onCursor_changed?: (() => any) | undefined;
44
48
  onDraggable_changed?: (() => any) | undefined;
45
49
  onFlat_changed?: (() => any) | undefined;
46
50
  onIcon_changed?: (() => any) | undefined;
47
- onPosition_changed?: (() => any) | undefined;
48
51
  onShape_changed?: (() => any) | undefined;
49
52
  onTitle_changed?: (() => any) | undefined;
50
53
  onVisible_changed?: (() => any) | undefined;
51
- onZindex_changed?: (() => any) | undefined;
52
54
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
53
55
  default?: (props: {}) => any;
54
56
  }>;
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import { inject, provide, watch } from "vue";
3
+ import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
3
4
  import { MARKER_INJECTION_KEY } from "./injectionKeys";
4
5
  import { MARKER_CLUSTERER_INJECTION_KEY } from "./ScriptGoogleMapsMarkerClusterer.vue";
5
6
  import { useGoogleMapsResource } from "./useGoogleMapsResource";
@@ -8,9 +9,13 @@ export { MARKER_INJECTION_KEY } from "./injectionKeys";
8
9
 
9
10
  <script setup>
10
11
  const props = defineProps({
12
+ position: { type: null, required: false },
11
13
  options: { type: Object, required: false }
12
14
  });
13
15
  const emit = defineEmits([]);
16
+ if (import.meta.dev) {
17
+ console.warn("[nuxt-scripts] ScriptGoogleMapsMarker uses the deprecated google.maps.Marker class. Use ScriptGoogleMapsAdvancedMarkerElement instead.");
18
+ }
14
19
  const eventsWithoutPayload = [
15
20
  "animation_changed",
16
21
  "clickable_changed",
@@ -39,8 +44,14 @@ const eventsWithMapMouseEventPayload = [
39
44
  const markerClustererContext = inject(MARKER_CLUSTERER_INJECTION_KEY, void 0);
40
45
  const marker = useGoogleMapsResource({
41
46
  create({ mapsApi, map }) {
42
- const m = new mapsApi.Marker(props.options);
43
- setupEventListeners(m);
47
+ const m = new mapsApi.Marker({
48
+ ...props.options,
49
+ ...props.position ? { position: props.position } : {}
50
+ });
51
+ bindGoogleMapsEvents(m, emit, {
52
+ noPayload: eventsWithoutPayload,
53
+ withPayload: eventsWithMapMouseEventPayload
54
+ });
44
55
  if (markerClustererContext?.markerClusterer.value) {
45
56
  markerClustererContext.markerClusterer.value.addMarker(m, true);
46
57
  markerClustererContext.requestRerender();
@@ -59,20 +70,17 @@ const marker = useGoogleMapsResource({
59
70
  }
60
71
  }
61
72
  });
73
+ watch(() => props.position, (position) => {
74
+ if (marker.value && position) {
75
+ marker.value.setPosition(position);
76
+ }
77
+ });
62
78
  watch(() => props.options, (options) => {
63
79
  if (marker.value && options) {
64
80
  marker.value.setOptions(options);
65
81
  }
66
82
  }, { deep: true });
67
83
  provide(MARKER_INJECTION_KEY, { marker });
68
- function setupEventListeners(m) {
69
- eventsWithoutPayload.forEach((event) => {
70
- m.addListener(event, () => emit(event));
71
- });
72
- eventsWithMapMouseEventPayload.forEach((event) => {
73
- m.addListener(event, (payload) => emit(event, payload));
74
- });
75
- }
76
84
  </script>
77
85
 
78
86
  <template>
@@ -2,6 +2,7 @@ export { MARKER_INJECTION_KEY } from './injectionKeys.js';
2
2
  declare const _default: typeof __VLS_export;
3
3
  export default _default;
4
4
  declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
5
+ position?: google.maps.LatLngLiteral | google.maps.LatLng;
5
6
  options?: Omit<google.maps.MarkerOptions, "map">;
6
7
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
7
8
  contextmenu: (payload: google.maps.MapMouseEvent) => any;
@@ -14,18 +15,19 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
14
15
  mouseout: (payload: google.maps.MapMouseEvent) => any;
15
16
  mouseover: (payload: google.maps.MapMouseEvent) => any;
16
17
  mouseup: (payload: google.maps.MapMouseEvent) => any;
18
+ position_changed: () => any;
19
+ zindex_changed: () => any;
17
20
  animation_changed: () => any;
18
21
  clickable_changed: () => any;
19
22
  cursor_changed: () => any;
20
23
  draggable_changed: () => any;
21
24
  flat_changed: () => any;
22
25
  icon_changed: () => any;
23
- position_changed: () => any;
24
26
  shape_changed: () => any;
25
27
  title_changed: () => any;
26
28
  visible_changed: () => any;
27
- zindex_changed: () => any;
28
29
  }, string, import("vue").PublicProps, Readonly<{
30
+ position?: google.maps.LatLngLiteral | google.maps.LatLng;
29
31
  options?: Omit<google.maps.MarkerOptions, "map">;
30
32
  }> & Readonly<{
31
33
  onContextmenu?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
@@ -38,17 +40,17 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
38
40
  onMouseout?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
39
41
  onMouseover?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
40
42
  onMouseup?: ((payload: google.maps.MapMouseEvent) => any) | undefined;
43
+ onPosition_changed?: (() => any) | undefined;
44
+ onZindex_changed?: (() => any) | undefined;
41
45
  onAnimation_changed?: (() => any) | undefined;
42
46
  onClickable_changed?: (() => any) | undefined;
43
47
  onCursor_changed?: (() => any) | undefined;
44
48
  onDraggable_changed?: (() => any) | undefined;
45
49
  onFlat_changed?: (() => any) | undefined;
46
50
  onIcon_changed?: (() => any) | undefined;
47
- onPosition_changed?: (() => any) | undefined;
48
51
  onShape_changed?: (() => any) | undefined;
49
52
  onTitle_changed?: (() => any) | undefined;
50
53
  onVisible_changed?: (() => any) | undefined;
51
- onZindex_changed?: (() => any) | undefined;
52
54
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
53
55
  default?: (props: {}) => any;
54
56
  }>;
@@ -0,0 +1,40 @@
1
+ type OverlayAnchor = 'center' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left-center' | 'right-center';
2
+ type OverlayPane = 'mapPane' | 'overlayLayer' | 'markerLayer' | 'overlayMouseTarget' | 'floatPane';
3
+ type __VLS_Props = {
4
+ position?: google.maps.LatLngLiteral;
5
+ anchor?: OverlayAnchor;
6
+ offset?: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ pane?: OverlayPane;
11
+ zIndex?: number;
12
+ blockMapInteraction?: boolean;
13
+ };
14
+ type __VLS_ModelProps = {
15
+ 'open'?: boolean;
16
+ };
17
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
18
+ declare var __VLS_1: {};
19
+ type __VLS_Slots = {} & {
20
+ default?: (props: typeof __VLS_1) => any;
21
+ };
22
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
23
+ overlay: import("vue").ShallowRef<google.maps.OverlayView | undefined>;
24
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ "update:open": (value: boolean | undefined) => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
27
+ "onUpdate:open"?: ((value: boolean | undefined) => any) | undefined;
28
+ }>, {
29
+ anchor: OverlayAnchor;
30
+ pane: OverlayPane;
31
+ blockMapInteraction: boolean;
32
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
36
+ type __VLS_WithSlots<T, S> = T & {
37
+ new (): {
38
+ $slots: S;
39
+ };
40
+ };
@@ -0,0 +1,168 @@
1
+ <script setup>
2
+ import { inject, useTemplateRef, watch } from "vue";
3
+ import { ADVANCED_MARKER_ELEMENT_INJECTION_KEY, MARKER_INJECTION_KEY } from "./injectionKeys";
4
+ import { useGoogleMapsResource } from "./useGoogleMapsResource";
5
+ const props = defineProps({
6
+ position: { type: null, required: false },
7
+ anchor: { type: String, required: false, default: "bottom-center" },
8
+ offset: { type: Object, required: false },
9
+ pane: { type: String, required: false, default: "floatPane" },
10
+ zIndex: { type: Number, required: false },
11
+ blockMapInteraction: { type: Boolean, required: false, default: true }
12
+ });
13
+ const open = defineModel("open", { type: Boolean });
14
+ const markerContext = inject(MARKER_INJECTION_KEY, void 0);
15
+ const advancedMarkerElementContext = inject(ADVANCED_MARKER_ELEMENT_INJECTION_KEY, void 0);
16
+ function getResolvedPosition() {
17
+ if (props.position)
18
+ return props.position;
19
+ if (markerContext?.marker.value) {
20
+ const pos = markerContext.marker.value.getPosition();
21
+ if (pos)
22
+ return { lat: pos.lat(), lng: pos.lng() };
23
+ }
24
+ if (advancedMarkerElementContext?.advancedMarkerElement.value) {
25
+ const pos = advancedMarkerElementContext.advancedMarkerElement.value.position;
26
+ if (pos) {
27
+ if ("lat" in pos && typeof pos.lat === "function")
28
+ return { lat: pos.lat(), lng: pos.lng() };
29
+ return pos;
30
+ }
31
+ }
32
+ return void 0;
33
+ }
34
+ const ANCHOR_TRANSFORMS = {
35
+ "center": "translate(-50%, -50%)",
36
+ "top-left": "translate(0, 0)",
37
+ "top-center": "translate(-50%, 0)",
38
+ "top-right": "translate(-100%, 0)",
39
+ "bottom-left": "translate(0, -100%)",
40
+ "bottom-center": "translate(-50%, -100%)",
41
+ "bottom-right": "translate(-100%, -100%)",
42
+ "left-center": "translate(0, -50%)",
43
+ "right-center": "translate(-100%, -50%)"
44
+ };
45
+ const overlayContent = useTemplateRef("overlay-content");
46
+ const listeners = [];
47
+ const overlay = useGoogleMapsResource({
48
+ // ready condition accesses .value on ShallowRefs — tracked by whenever() in useGoogleMapsResource
49
+ ready: () => !!overlayContent.value && !!(props.position || markerContext?.marker.value || advancedMarkerElementContext?.advancedMarkerElement.value),
50
+ create({ mapsApi, map }) {
51
+ const el = overlayContent.value;
52
+ class CustomOverlay extends mapsApi.OverlayView {
53
+ onAdd() {
54
+ const panes = this.getPanes();
55
+ if (panes) {
56
+ panes[props.pane].appendChild(el);
57
+ if (props.blockMapInteraction)
58
+ mapsApi.OverlayView.preventMapHitsAndGesturesFrom(el);
59
+ }
60
+ }
61
+ draw() {
62
+ if (open.value === false) {
63
+ el.style.visibility = "hidden";
64
+ return;
65
+ }
66
+ const position = getResolvedPosition();
67
+ if (!position) {
68
+ el.style.visibility = "hidden";
69
+ return;
70
+ }
71
+ const projection = this.getProjection();
72
+ if (!projection) {
73
+ el.style.visibility = "hidden";
74
+ return;
75
+ }
76
+ const pos = projection.fromLatLngToDivPixel(
77
+ new mapsApi.LatLng(position.lat, position.lng)
78
+ );
79
+ if (!pos) {
80
+ el.style.visibility = "hidden";
81
+ return;
82
+ }
83
+ el.style.position = "absolute";
84
+ el.style.left = `${pos.x + (props.offset?.x ?? 0)}px`;
85
+ el.style.top = `${pos.y + (props.offset?.y ?? 0)}px`;
86
+ el.style.transform = ANCHOR_TRANSFORMS[props.anchor];
87
+ if (props.zIndex !== void 0)
88
+ el.style.zIndex = String(props.zIndex);
89
+ el.style.visibility = "visible";
90
+ }
91
+ onRemove() {
92
+ el.parentNode?.removeChild(el);
93
+ }
94
+ }
95
+ el.style.visibility = "hidden";
96
+ const ov = new CustomOverlay();
97
+ ov.setMap(map);
98
+ if (markerContext?.marker.value) {
99
+ listeners.push(
100
+ markerContext.marker.value.addListener("position_changed", () => ov.draw())
101
+ );
102
+ } else if (advancedMarkerElementContext?.advancedMarkerElement.value) {
103
+ const ame = advancedMarkerElementContext.advancedMarkerElement.value;
104
+ listeners.push(
105
+ ame.addListener("drag", () => ov.draw()),
106
+ ame.addListener("dragend", () => ov.draw())
107
+ );
108
+ }
109
+ return ov;
110
+ },
111
+ cleanup(ov) {
112
+ listeners.forEach((l) => l.remove());
113
+ listeners.length = 0;
114
+ ov.setMap(null);
115
+ }
116
+ });
117
+ if (advancedMarkerElementContext) {
118
+ watch(
119
+ () => {
120
+ const pos = advancedMarkerElementContext.advancedMarkerElement.value?.position;
121
+ if (!pos)
122
+ return void 0;
123
+ if ("lat" in pos && typeof pos.lat === "function")
124
+ return { lat: pos.lat(), lng: pos.lng() };
125
+ return pos;
126
+ },
127
+ () => {
128
+ overlay.value?.draw();
129
+ }
130
+ );
131
+ }
132
+ watch(
133
+ () => [props.position?.lat, props.position?.lng, props.offset?.x, props.offset?.y, props.zIndex, props.anchor],
134
+ () => {
135
+ overlay.value?.draw();
136
+ }
137
+ );
138
+ watch(() => open.value, () => {
139
+ if (!overlay.value)
140
+ return;
141
+ overlay.value.draw();
142
+ });
143
+ watch(() => props.pane, () => {
144
+ if (overlay.value) {
145
+ const map = overlay.value.getMap();
146
+ overlay.value.setMap(null);
147
+ if (map)
148
+ overlay.value.setMap(map);
149
+ }
150
+ });
151
+ watch(() => props.blockMapInteraction, () => {
152
+ if (overlay.value) {
153
+ const map = overlay.value.getMap();
154
+ overlay.value.setMap(null);
155
+ if (map)
156
+ overlay.value.setMap(map);
157
+ }
158
+ });
159
+ defineExpose({ overlay });
160
+ </script>
161
+
162
+ <template>
163
+ <div style="display: none;">
164
+ <div ref="overlay-content">
165
+ <slot />
166
+ </div>
167
+ </div>
168
+ </template>
@@ -0,0 +1,40 @@
1
+ type OverlayAnchor = 'center' | 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right' | 'left-center' | 'right-center';
2
+ type OverlayPane = 'mapPane' | 'overlayLayer' | 'markerLayer' | 'overlayMouseTarget' | 'floatPane';
3
+ type __VLS_Props = {
4
+ position?: google.maps.LatLngLiteral;
5
+ anchor?: OverlayAnchor;
6
+ offset?: {
7
+ x: number;
8
+ y: number;
9
+ };
10
+ pane?: OverlayPane;
11
+ zIndex?: number;
12
+ blockMapInteraction?: boolean;
13
+ };
14
+ type __VLS_ModelProps = {
15
+ 'open'?: boolean;
16
+ };
17
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
18
+ declare var __VLS_1: {};
19
+ type __VLS_Slots = {} & {
20
+ default?: (props: typeof __VLS_1) => any;
21
+ };
22
+ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {
23
+ overlay: import("vue").ShallowRef<google.maps.OverlayView | undefined>;
24
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ "update:open": (value: boolean | undefined) => any;
26
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
27
+ "onUpdate:open"?: ((value: boolean | undefined) => any) | undefined;
28
+ }>, {
29
+ anchor: OverlayAnchor;
30
+ pane: OverlayPane;
31
+ blockMapInteraction: boolean;
32
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
33
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
34
+ declare const _default: typeof __VLS_export;
35
+ export default _default;
36
+ type __VLS_WithSlots<T, S> = T & {
37
+ new (): {
38
+ $slots: S;
39
+ };
40
+ };
@@ -1,5 +1,6 @@
1
1
  <script setup>
2
2
  import { watch } from "vue";
3
+ import { bindGoogleMapsEvents } from "./bindGoogleMapsEvents";
3
4
  import { useGoogleMapsResource } from "./useGoogleMapsResource";
4
5
  const props = defineProps({
5
6
  options: { type: Object, required: false }
@@ -23,7 +24,9 @@ const eventsWithMapMouseEventPayload = [
23
24
  const polygon = useGoogleMapsResource({
24
25
  create({ mapsApi, map }) {
25
26
  const p = new mapsApi.Polygon({ map, ...props.options });
26
- setupEventListeners(p);
27
+ bindGoogleMapsEvents(p, emit, {
28
+ withPayload: [...eventsWithPolyMouseEventPayload, ...eventsWithMapMouseEventPayload]
29
+ });
27
30
  return p;
28
31
  },
29
32
  cleanup(p, { mapsApi }) {
@@ -36,14 +39,6 @@ watch(() => props.options, (options) => {
36
39
  polygon.value.setOptions(options);
37
40
  }
38
41
  }, { deep: true });
39
- function setupEventListeners(p) {
40
- eventsWithPolyMouseEventPayload.forEach((event) => {
41
- p.addListener(event, (payload) => emit(event, payload));
42
- });
43
- eventsWithMapMouseEventPayload.forEach((event) => {
44
- p.addListener(event, (payload) => emit(event, payload));
45
- });
46
- }
47
42
  </script>
48
43
 
49
44
  <template>