@heycar/heycars-map 0.6.1 → 0.6.2

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,14 @@ 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,
2101
2121
  "disableDoubleClickZoom": touchEnable,
2102
2122
  "gestureHandling": touchEnable ? "auto" : "none",
2103
- "keyboardShortcuts": touchEnable,
2104
- "rotateControl": false,
2105
- "zoomControl": touchEnable,
2106
- "scaleControl": touchEnable,
2107
- "panControl": touchEnable
2123
+ "keyboardShortcuts": touchEnable
2108
2124
  },
2109
2125
  "on": {
2110
- "dragEnd": gmapHandleDargEnd
2126
+ "dragEnd": gmapHandleDargEnd,
2127
+ "resize": handleResize
2111
2128
  }
2112
2129
  }, [children]);
2113
2130
  default:
@@ -2252,11 +2269,11 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2252
2269
  const pathRef = Vue.computed(() => props.path.map(vec2lnglat));
2253
2270
  return () => {
2254
2271
  const vw = window.innerWidth * 0.01;
2255
- 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;
2272
+ const repeat = 5 * vw;
2273
+ const strokeWidth = 1.25 * vw;
2274
+ const borderWidth = 0.175 * vw;
2275
+ const dirStrokeWeight = 0.375 * vw;
2276
+ const outlineWidth = 0.4 * vw;
2260
2277
  const strokeColorInner = props.done ? "#96B2CA" : "#487BF4";
2261
2278
  const strokeColorOuter = props.done ? "#7693AF" : "#4175F1";
2262
2279
  const strokeColorBorder = props.done ? "#7693AF" : "#6C95F5";
@@ -2293,7 +2310,7 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2293
2310
  path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
2294
2311
  strokeColor: "white",
2295
2312
  strokeWeight: dirStrokeWeight,
2296
- scale: 3
2313
+ scale: 1
2297
2314
  },
2298
2315
  repeat: `${repeat}px`
2299
2316
  }]
@@ -2608,6 +2625,7 @@ const useGmapFitView = (props) => {
2608
2625
  return;
2609
2626
  const vw = window.innerWidth / 100;
2610
2627
  const [top, right, bottom, left] = (_a = props.padding) != null ? _a : [0, 0, 0, 0];
2628
+ spaceLog("setFitView", "overlayGroup = ", overlayGroup);
2611
2629
  executeMapApi(
2612
2630
  () => map.fitBounds(overlayGroup.getBound(), {
2613
2631
  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,14 @@ 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,
2099
2119
  "disableDoubleClickZoom": touchEnable,
2100
2120
  "gestureHandling": touchEnable ? "auto" : "none",
2101
- "keyboardShortcuts": touchEnable,
2102
- "rotateControl": false,
2103
- "zoomControl": touchEnable,
2104
- "scaleControl": touchEnable,
2105
- "panControl": touchEnable
2121
+ "keyboardShortcuts": touchEnable
2106
2122
  },
2107
2123
  "on": {
2108
- "dragEnd": gmapHandleDargEnd
2124
+ "dragEnd": gmapHandleDargEnd,
2125
+ "resize": handleResize
2109
2126
  }
2110
2127
  }, [children]);
2111
2128
  default:
@@ -2250,11 +2267,11 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2250
2267
  const pathRef = computed(() => props.path.map(vec2lnglat));
2251
2268
  return () => {
2252
2269
  const vw = window.innerWidth * 0.01;
2253
- 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;
2270
+ const repeat = 5 * vw;
2271
+ const strokeWidth = 1.25 * vw;
2272
+ const borderWidth = 0.175 * vw;
2273
+ const dirStrokeWeight = 0.375 * vw;
2274
+ const outlineWidth = 0.4 * vw;
2258
2275
  const strokeColorInner = props.done ? "#96B2CA" : "#487BF4";
2259
2276
  const strokeColorOuter = props.done ? "#7693AF" : "#4175F1";
2260
2277
  const strokeColorBorder = props.done ? "#7693AF" : "#6C95F5";
@@ -2291,7 +2308,7 @@ const GDrivingLine = defineSetup(function GDrivingLine2(props) {
2291
2308
  path: google.maps.SymbolPath.FORWARD_OPEN_ARROW,
2292
2309
  strokeColor: "white",
2293
2310
  strokeWeight: dirStrokeWeight,
2294
- scale: 3
2311
+ scale: 1
2295
2312
  },
2296
2313
  repeat: `${repeat}px`
2297
2314
  }]
@@ -2606,6 +2623,7 @@ const useGmapFitView = (props) => {
2606
2623
  return;
2607
2624
  const vw = window.innerWidth / 100;
2608
2625
  const [top, right, bottom, left] = (_a = props.padding) != null ? _a : [0, 0, 0, 0];
2626
+ spaceLog("setFitView", "overlayGroup = ", overlayGroup);
2609
2627
  executeMapApi(
2610
2628
  () => map.fitBounds(overlayGroup.getBound(), {
2611
2629
  top: top * vw,
package/dist/style.css CHANGED
@@ -117,6 +117,9 @@
117
117
  }
118
118
  ._7anfuo1 {
119
119
  position: relative;
120
+ }
121
+ a[title*="Google"]>div>img[alt="Google"], .gmnoprint {
122
+ display: none;
120
123
  }._4a4ovk0 {
121
124
  margin-bottom: -0.4vw;
122
125
  display: flex;
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.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",