@heycar/heycars-map 0.6.1 → 0.6.3

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.
@@ -1,10 +1,12 @@
1
1
  /// <reference types="google.maps" />
2
2
  import type { SetMap } from "../../hooks/useHeycarMap";
3
+ import { UseResizeObserverProps } from "../../hooks/useResizeObserver";
3
4
  import type { MapEventHandler } from "../../types/mapHelper";
4
5
  export interface GmapProps extends google.maps.MapOptions {
5
6
  mapRef?: SetMap<google.maps.Map>;
6
7
  onDragStart?: MapEventHandler<google.maps.Map>;
7
8
  onDragEnd?: MapEventHandler<google.maps.Map>;
8
9
  onZoom_change?: MapEventHandler<google.maps.Map>;
10
+ onResize?: UseResizeObserverProps["onChange"];
9
11
  }
10
- export declare const Gmap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<GmapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<GmapProps, Required<GmapProps>>, "dragStart" | "dragEnd" | "zoom_change", GmapProps, {}>;
12
+ export declare const Gmap: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<GmapProps>, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").Empty, import("../../types/helper").EmitByProps<GmapProps, Required<GmapProps>>, "resize" | "dragStart" | "dragEnd" | "zoom_change", GmapProps, {}>;
@@ -0,0 +1,9 @@
1
+ import { ShallowRef } from "vue-demi";
2
+ export interface UseResizeObserverProps {
3
+ elementRef: ShallowRef<HTMLDivElement>;
4
+ onChange?: (props: {
5
+ width: number;
6
+ height: number;
7
+ }) => any;
8
+ }
9
+ export declare const useResizeObserver: (props: UseResizeObserverProps) => void;
package/dist/index.cjs CHANGED
@@ -1095,17 +1095,16 @@ const GmapAdvancedMarkerView = defineSetup(function GmapAdvancedMarkerView2(prop
1095
1095
  const markerRef = Vue.shallowRef();
1096
1096
  const mapRef = useGmap();
1097
1097
  const handleClick = (name) => emit(name, { target: markerRef.value });
1098
- useMapOverlay({ registerOverlay, overlayRef: markerRef });
1099
1098
  Vue.onMounted(() => {
1100
1099
  const { registerOverlay: registerOverlay2, ...markerViewProps } = props;
1101
1100
  markerRef.value = new google.maps.marker.AdvancedMarkerView({ ...markerViewProps });
1102
- markerRef.value.addListener;
1103
1101
  });
1104
1102
  Vue.onUnmounted(() => {
1105
1103
  if (!markerRef.value)
1106
1104
  return;
1107
1105
  markerRef.value.map = null;
1108
1106
  });
1107
+ useMapOverlay({ registerOverlay, overlayRef: markerRef });
1109
1108
  Vue.watchPostEffect(() => {
1110
1109
  const map = mapRef == null ? void 0 : mapRef.value;
1111
1110
  if (!map || !markerRef.value)
@@ -1978,10 +1977,30 @@ const useMapEventSource = () => {
1978
1977
  };
1979
1978
  return { executeMapApi };
1980
1979
  };
1980
+ const useResizeObserver = (props) => {
1981
+ const { elementRef, onChange } = props;
1982
+ const resizeObserver = new ResizeObserver(([entry]) => {
1983
+ var _a, _b;
1984
+ const { contentBoxSize, contentRect } = entry;
1985
+ const width = (_a = contentBoxSize == null ? void 0 : contentBoxSize[0].inlineSize) != null ? _a : contentRect.width;
1986
+ const height = (_b = contentBoxSize == null ? void 0 : contentBoxSize[0].blockSize) != null ? _b : contentRect.height;
1987
+ onChange == null ? void 0 : onChange({ width, height });
1988
+ });
1989
+ Vue.watchPostEffect((onCleanup) => {
1990
+ const element = elementRef.value;
1991
+ if (element)
1992
+ resizeObserver.observe(element);
1993
+ onCleanup(() => {
1994
+ if (element)
1995
+ resizeObserver.unobserve(element);
1996
+ });
1997
+ });
1998
+ };
1981
1999
  const Gmap_css_ts_vanilla = "";
1982
2000
  var gmap = "_7anfuo0";
1983
2001
  const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
1984
2002
  const setMap = props.mapRef;
2003
+ const { onResize } = props;
1985
2004
  const options = Vue.computed(() => {
1986
2005
  const { mapRef: mapRef2, onDragStart, onDragEnd, onZoom_change, ...options2 } = props;
1987
2006
  return options2;
@@ -1992,6 +2011,7 @@ const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
1992
2011
  const { executeMapApi } = useMapEventSource();
1993
2012
  const handleDrag = (name) => emit(name, { target: mapRef.value });
1994
2013
  provideGmap(mapRef);
2014
+ useResizeObserver({ elementRef, onChange: onResize });
1995
2015
  Vue.watchPostEffect(() => {
1996
2016
  if (mapRef.value || !elementRef.value)
1997
2017
  return;
@@ -2097,17 +2117,15 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2097
2117
  "mapId": gmapId,
2098
2118
  "center": center ? vec2lnglat(center) : void 0,
2099
2119
  "zoom": zoom,
2100
- "disableDefaultUI": touchEnable,
2120
+ "disableDefaultUI": true,
2121
+ "clickableIcons": false,
2101
2122
  "disableDoubleClickZoom": touchEnable,
2102
2123
  "gestureHandling": touchEnable ? "auto" : "none",
2103
- "keyboardShortcuts": touchEnable,
2104
- "rotateControl": false,
2105
- "zoomControl": touchEnable,
2106
- "scaleControl": touchEnable,
2107
- "panControl": touchEnable
2124
+ "keyboardShortcuts": touchEnable
2108
2125
  },
2109
2126
  "on": {
2110
- "dragEnd": gmapHandleDargEnd
2127
+ "dragEnd": gmapHandleDargEnd,
2128
+ "resize": handleResize
2111
2129
  }
2112
2130
  }, [children]);
2113
2131
  default:
@@ -2253,10 +2271,10 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2253
2271
  return () => {
2254
2272
  const vw = window.innerWidth * 0.01;
2255
2273
  const repeat = 10 * vw;
2256
- const strokeWidth = 2.5 * vw;
2257
- const borderWidth = 0.35 * vw;
2258
- const dirStrokeWeight = 0.75 * vw;
2259
- const outlineWidth = 1 * vw;
2274
+ const strokeWidth = 1.25 * vw * 0.65;
2275
+ const borderWidth = 0.175 * vw * 0.65;
2276
+ const dirStrokeWeight = 0.375 * vw * 0.65;
2277
+ const outlineWidth = 0.45 * vw * 0.65;
2260
2278
  const strokeColorInner = props.done ? "#96B2CA" : "#487BF4";
2261
2279
  const strokeColorOuter = props.done ? "#7693AF" : "#4175F1";
2262
2280
  const strokeColorBorder = props.done ? "#7693AF" : "#6C95F5";
@@ -2293,7 +2311,7 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2293
2311
  path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
2294
2312
  strokeColor: "white",
2295
2313
  strokeWeight: dirStrokeWeight,
2296
- scale: 3
2314
+ scale: 0.7
2297
2315
  },
2298
2316
  repeat: `${repeat}px`
2299
2317
  }]
@@ -2608,6 +2626,7 @@ const useGmapFitView = (props) => {
2608
2626
  return;
2609
2627
  const vw = window.innerWidth / 100;
2610
2628
  const [top, right, bottom, left] = (_a = props.padding) != null ? _a : [0, 0, 0, 0];
2629
+ spaceLog("setFitView", "overlayGroup = ", overlayGroup);
2611
2630
  executeMapApi(
2612
2631
  () => map.fitBounds(overlayGroup.getBound(), {
2613
2632
  top: top * vw,
package/dist/index.js CHANGED
@@ -1093,17 +1093,16 @@ const GmapAdvancedMarkerView = defineSetup(function GmapAdvancedMarkerView2(prop
1093
1093
  const markerRef = shallowRef();
1094
1094
  const mapRef = useGmap();
1095
1095
  const handleClick = (name) => emit(name, { target: markerRef.value });
1096
- useMapOverlay({ registerOverlay, overlayRef: markerRef });
1097
1096
  onMounted(() => {
1098
1097
  const { registerOverlay: registerOverlay2, ...markerViewProps } = props;
1099
1098
  markerRef.value = new google.maps.marker.AdvancedMarkerView({ ...markerViewProps });
1100
- markerRef.value.addListener;
1101
1099
  });
1102
1100
  onUnmounted(() => {
1103
1101
  if (!markerRef.value)
1104
1102
  return;
1105
1103
  markerRef.value.map = null;
1106
1104
  });
1105
+ useMapOverlay({ registerOverlay, overlayRef: markerRef });
1107
1106
  watchPostEffect(() => {
1108
1107
  const map = mapRef == null ? void 0 : mapRef.value;
1109
1108
  if (!map || !markerRef.value)
@@ -1976,10 +1975,30 @@ const useMapEventSource = () => {
1976
1975
  };
1977
1976
  return { executeMapApi };
1978
1977
  };
1978
+ const useResizeObserver = (props) => {
1979
+ const { elementRef, onChange } = props;
1980
+ const resizeObserver = new ResizeObserver(([entry]) => {
1981
+ var _a, _b;
1982
+ const { contentBoxSize, contentRect } = entry;
1983
+ const width = (_a = contentBoxSize == null ? void 0 : contentBoxSize[0].inlineSize) != null ? _a : contentRect.width;
1984
+ const height = (_b = contentBoxSize == null ? void 0 : contentBoxSize[0].blockSize) != null ? _b : contentRect.height;
1985
+ onChange == null ? void 0 : onChange({ width, height });
1986
+ });
1987
+ watchPostEffect((onCleanup) => {
1988
+ const element = elementRef.value;
1989
+ if (element)
1990
+ resizeObserver.observe(element);
1991
+ onCleanup(() => {
1992
+ if (element)
1993
+ resizeObserver.unobserve(element);
1994
+ });
1995
+ });
1996
+ };
1979
1997
  const Gmap_css_ts_vanilla = "";
1980
1998
  var gmap = "_7anfuo0";
1981
1999
  const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
1982
2000
  const setMap = props.mapRef;
2001
+ const { onResize } = props;
1983
2002
  const options = computed(() => {
1984
2003
  const { mapRef: mapRef2, onDragStart, onDragEnd, onZoom_change, ...options2 } = props;
1985
2004
  return options2;
@@ -1990,6 +2009,7 @@ const Gmap = defineSetup(function Gmap2(props, { slots, emit }) {
1990
2009
  const { executeMapApi } = useMapEventSource();
1991
2010
  const handleDrag = (name) => emit(name, { target: mapRef.value });
1992
2011
  provideGmap(mapRef);
2012
+ useResizeObserver({ elementRef, onChange: onResize });
1993
2013
  watchPostEffect(() => {
1994
2014
  if (mapRef.value || !elementRef.value)
1995
2015
  return;
@@ -2095,17 +2115,15 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2095
2115
  "mapId": gmapId,
2096
2116
  "center": center ? vec2lnglat(center) : void 0,
2097
2117
  "zoom": zoom,
2098
- "disableDefaultUI": touchEnable,
2118
+ "disableDefaultUI": true,
2119
+ "clickableIcons": false,
2099
2120
  "disableDoubleClickZoom": touchEnable,
2100
2121
  "gestureHandling": touchEnable ? "auto" : "none",
2101
- "keyboardShortcuts": touchEnable,
2102
- "rotateControl": false,
2103
- "zoomControl": touchEnable,
2104
- "scaleControl": touchEnable,
2105
- "panControl": touchEnable
2122
+ "keyboardShortcuts": touchEnable
2106
2123
  },
2107
2124
  "on": {
2108
- "dragEnd": gmapHandleDargEnd
2125
+ "dragEnd": gmapHandleDargEnd,
2126
+ "resize": handleResize
2109
2127
  }
2110
2128
  }, [children]);
2111
2129
  default:
@@ -2251,10 +2269,10 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2251
2269
  return () => {
2252
2270
  const vw = window.innerWidth * 0.01;
2253
2271
  const repeat = 10 * vw;
2254
- const strokeWidth = 2.5 * vw;
2255
- const borderWidth = 0.35 * vw;
2256
- const dirStrokeWeight = 0.75 * vw;
2257
- const outlineWidth = 1 * vw;
2272
+ const strokeWidth = 1.25 * vw * 0.65;
2273
+ const borderWidth = 0.175 * vw * 0.65;
2274
+ const dirStrokeWeight = 0.375 * vw * 0.65;
2275
+ const outlineWidth = 0.45 * vw * 0.65;
2258
2276
  const strokeColorInner = props.done ? "#96B2CA" : "#487BF4";
2259
2277
  const strokeColorOuter = props.done ? "#7693AF" : "#4175F1";
2260
2278
  const strokeColorBorder = props.done ? "#7693AF" : "#6C95F5";
@@ -2291,7 +2309,7 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2291
2309
  path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
2292
2310
  strokeColor: "white",
2293
2311
  strokeWeight: dirStrokeWeight,
2294
- scale: 3
2312
+ scale: 0.7
2295
2313
  },
2296
2314
  repeat: `${repeat}px`
2297
2315
  }]
@@ -2606,6 +2624,7 @@ const useGmapFitView = (props) => {
2606
2624
  return;
2607
2625
  const vw = window.innerWidth / 100;
2608
2626
  const [top, right, bottom, left] = (_a = props.padding) != null ? _a : [0, 0, 0, 0];
2627
+ spaceLog("setFitView", "overlayGroup = ", overlayGroup);
2609
2628
  executeMapApi(
2610
2629
  () => map.fitBounds(overlayGroup.getBound(), {
2611
2630
  top: top * vw,
package/dist/style.css CHANGED
@@ -117,6 +117,12 @@
117
117
  }
118
118
  ._7anfuo1 {
119
119
  position: relative;
120
+ }
121
+ a[title*="Google"]>div>img[alt="Google"], .gmnoprint {
122
+ display: none;
123
+ }
124
+ ._7anfuo0 [class*="marker-view"] {
125
+ will-change: unset !important;
120
126
  }._4a4ovk0 {
121
127
  margin-bottom: -0.4vw;
122
128
  display: flex;
@@ -198,6 +204,7 @@
198
204
  }
199
205
  .fhyw85 {
200
206
  margin-bottom: -2.265vw;
207
+ width: max-content;
201
208
  }
202
209
  .fhyw86 {
203
210
  margin-right: calc(50% - 2.265vw);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/todo.md CHANGED
@@ -106,3 +106,12 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
106
106
 
107
107
  - 5500
108
108
  - 5524
109
+
110
+ 0.6.3
111
+
112
+ - 5623
113
+ - 5625
114
+ - 5550
115
+ - 5546
116
+ - 5541
117
+ - 5540