@heycar/heycars-map 0.5.0 → 0.5.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.
@@ -12,6 +12,7 @@ export interface AmapProps extends Omit<AMap.MapOptions, "vectorMapForeign"> {
12
12
  touchZoom?: boolean;
13
13
  keyboardEnable?: boolean;
14
14
  pitchEnable?: boolean;
15
+ touchZoomCenter?: 0 | 1;
15
16
  onDragStart?: MapEventHandler<AMap.Map>;
16
17
  onDragEnd?: MapEventHandler<AMap.Map>;
17
18
  onZoomEnd?: MapEventHandler<AMap.Map>;
@@ -7,9 +7,10 @@ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gma
7
7
  export declare const MapProvider: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<MapProviderProps>, 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<MapProviderProps, Required<MapProviderProps>>, "change", MapProviderProps, {}>;
8
8
  export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
9
9
  mapRef?: SetMap<AMap.Map> | SetMap<google.maps.Map>;
10
+ touchZoomCenter?: boolean;
11
+ touchEnable?: boolean;
10
12
  onDragEnd?: (value: [number, number]) => any;
11
13
  onZoomEnd?: (value: number) => any;
12
14
  onResize?: () => any;
13
- touchEnable?: boolean;
14
15
  }
15
16
  export declare const HeycarMap: import("vue").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<HeycarMapProps>, 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<HeycarMapProps, Required<HeycarMapProps>>, "resize" | "dragEnd" | "zoomEnd", HeycarMapProps, {}>;
@@ -7,6 +7,7 @@ export interface UseMapPlaceOnChangeCityProps {
7
7
  }
8
8
  export interface UseMapPlaceProps {
9
9
  pointRef: Ref<Point>;
10
+ emptyPlaceName: string;
10
11
  onChange?: (value: Place) => any;
11
12
  onChangeCity?: (value: UseMapPlaceOnChangeCityProps) => any;
12
13
  }
@@ -4,6 +4,7 @@ import { UseMapPlaceProps } from "./useMapPlace";
4
4
  export interface UseMapRecomendPlaceProps<C = Record<string, any>> {
5
5
  pointRef: Ref<Point>;
6
6
  context?: C;
7
+ emptyPlaceName: string;
7
8
  getLimit: (context?: C) => number;
8
9
  getRecomendPlace: (place: Place, context?: C) => Promise<Place[] | undefined>;
9
10
  onChangeCity?: UseMapPlaceProps["onChangeCity"];
@@ -0,0 +1,8 @@
1
+ /// <reference types="google.maps" />
2
+ import { Ref, ShallowRef } from "vue-demi";
3
+ interface UseWheelZoomCenterProps<M = AMap.Map | google.maps.Map> {
4
+ mapRef: ShallowRef<M | undefined>;
5
+ enableRef?: Ref<boolean>;
6
+ }
7
+ export declare const useAmapWheelZoomCenter: (props: UseWheelZoomCenterProps<AMap.Map>) => void;
8
+ export {};
package/dist/index.cjs CHANGED
@@ -1859,6 +1859,35 @@ const useMapLoader = (props) => {
1859
1859
  onChange
1860
1860
  });
1861
1861
  };
1862
+ const ZOOM_WHEEL_RATIO = -135e-5;
1863
+ const useAmapWheelZoomCenter = (props) => {
1864
+ const { mapRef, enableRef } = props;
1865
+ const handleWheel = (e) => {
1866
+ var _a, _b, _c;
1867
+ const { deltaY } = e;
1868
+ const prevZoom = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : 0;
1869
+ const zoom = prevZoom + ZOOM_WHEEL_RATIO * deltaY;
1870
+ console.log("handleWheel zoom = ", zoom);
1871
+ (_c = mapRef.value) == null ? void 0 : _c.setZoom(zoom);
1872
+ };
1873
+ Vue.watch(
1874
+ () => enableRef == null ? void 0 : enableRef.value,
1875
+ (enable, _, onCleanup) => {
1876
+ if (enable) {
1877
+ console.log("addEventListener wheel");
1878
+ addEventListener("wheel", handleWheel);
1879
+ } else {
1880
+ console.log("removeEventListener wheel");
1881
+ removeEventListener("wheel", handleWheel);
1882
+ }
1883
+ onCleanup(() => {
1884
+ console.log("onClean removeEventListener wheel");
1885
+ removeEventListener("wheel", handleWheel);
1886
+ });
1887
+ },
1888
+ { immediate: true }
1889
+ );
1890
+ };
1862
1891
  const Amap_css_ts_vanilla = "";
1863
1892
  var amap = "_1d8ur7t0";
1864
1893
  const Amap = defineSetup(function Amap2(props, { slots, emit }) {
@@ -1881,9 +1910,10 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
1881
1910
  animateEnable = true,
1882
1911
  keyboardEnable = true,
1883
1912
  doubleClickZoom = true,
1884
- scrollWheel = true,
1885
- touchZoom = true
1913
+ touchZoom = true,
1914
+ touchZoomCenter = 0
1886
1915
  } = props;
1916
+ const scrollWheel = touchZoomCenter ? false : props.scrollWheel;
1887
1917
  return {
1888
1918
  dragEnable,
1889
1919
  zoomEnable,
@@ -1894,17 +1924,20 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
1894
1924
  keyboardEnable,
1895
1925
  doubleClickZoom,
1896
1926
  scrollWheel,
1897
- touchZoom
1927
+ touchZoom,
1928
+ touchZoomCenter
1898
1929
  };
1899
1930
  });
1900
1931
  const elementRef = Vue.shallowRef();
1901
1932
  const mapRef = Vue.shallowRef();
1902
1933
  provideAmap(mapRef);
1934
+ useAmapWheelZoomCenter({ mapRef, enableRef: Vue.computed(() => !!props.touchZoomCenter) });
1903
1935
  Vue.watchPostEffect(() => {
1904
1936
  if (mapRef.value || !elementRef.value)
1905
1937
  return;
1906
1938
  const map = new AMap.Map(elementRef.value, {
1907
1939
  ...defaultOptions,
1940
+ scrollWheel: defaultOptions.touchZoomCenter ? false : defaultOptions.scrollWheel,
1908
1941
  vectorMapForeign,
1909
1942
  mapStyle: "amap://styles/95498a904992a4c0b866a3e4d7729682"
1910
1943
  });
@@ -2063,7 +2096,8 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2063
2096
  mapRef: setMap,
2064
2097
  center,
2065
2098
  zoom,
2066
- touchEnable = true
2099
+ touchEnable = true,
2100
+ touchZoomCenter
2067
2101
  } = props;
2068
2102
  if (status === Status.LOADING)
2069
2103
  return (_a = slots.loading) == null ? void 0 : _a.call(slots);
@@ -2104,6 +2138,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2104
2138
  "doubleClickZoom": touchEnable,
2105
2139
  "scrollWheel": touchEnable,
2106
2140
  "touchZoom": touchEnable,
2141
+ "touchZoomCenter": touchZoomCenter ? 1 : 0,
2107
2142
  "keyboardEnable": touchEnable,
2108
2143
  "pitchEnable": touchEnable
2109
2144
  },
@@ -2114,7 +2149,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2114
2149
  }, [children]);
2115
2150
  }
2116
2151
  };
2117
- }).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable"]);
2152
+ }).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable", "touchZoomCenter"]);
2118
2153
  const AmapPolyline = defineSetup(function AmapPolyline2(props) {
2119
2154
  const polylineRef = Vue.shallowRef();
2120
2155
  const mapRef = useAmap();
@@ -3086,6 +3121,7 @@ const useAmapDrag = (props) => {
3086
3121
  var _a;
3087
3122
  isDragging.value = false;
3088
3123
  const { lng, lat } = target.getCenter();
3124
+ spaceLog("dragEnd", "[lng, lat] = ", [lng, lat]);
3089
3125
  centerRef.value = [lng, lat];
3090
3126
  (_a = pipeAsync(onChange)) == null ? void 0 : _a([lng, lat]);
3091
3127
  };
@@ -3135,7 +3171,7 @@ const useUpdate = () => {
3135
3171
  return { idx, update };
3136
3172
  };
3137
3173
  const useAmapPlace = (props) => {
3138
- const { onChange, onChangeCity } = props;
3174
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3139
3175
  const defaultPoint = [...props.pointRef.value];
3140
3176
  const pointRef = Vue.ref(defaultPoint);
3141
3177
  const { readyPromise } = useMapSupplier();
@@ -3175,9 +3211,11 @@ const useAmapPlace = (props) => {
3175
3211
  geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3176
3212
  switch (status) {
3177
3213
  case "complete": {
3178
- const { formattedAddress: name, addressComponent } = result.regeocode;
3214
+ const { formattedAddress, addressComponent } = result.regeocode;
3179
3215
  const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3180
3216
  const cityParentName = addressComponent.province;
3217
+ const name = formattedAddress ? formattedAddress : emptyPlaceName;
3218
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, name, lng, lat);
3181
3219
  place.name = name;
3182
3220
  place.lng = lng;
3183
3221
  place.lat = lat;
@@ -3186,9 +3224,10 @@ const useAmapPlace = (props) => {
3186
3224
  return;
3187
3225
  }
3188
3226
  case "no_data":
3189
- place.name = "";
3227
+ place.name = emptyPlaceName;
3190
3228
  place.lng = lng;
3191
3229
  place.lat = lat;
3230
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, "", lng, lat);
3192
3231
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3193
3232
  return;
3194
3233
  case "error":
@@ -3200,7 +3239,7 @@ const useAmapPlace = (props) => {
3200
3239
  return { place, updatePlace, setPlace, updateCity };
3201
3240
  };
3202
3241
  const useGmapPlace = (props) => {
3203
- const { onChange, onChangeCity } = props;
3242
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3204
3243
  const defaultPoint = [...props.pointRef.value];
3205
3244
  const pointRef = Vue.ref(defaultPoint);
3206
3245
  const { readyPromise } = useMapSupplier();
@@ -3235,7 +3274,7 @@ const useGmapPlace = (props) => {
3235
3274
  const geocoder = new google.maps.Geocoder();
3236
3275
  const [lng, lat] = pointRef.value;
3237
3276
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3238
- const name = results[0].formatted_address;
3277
+ const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3239
3278
  const cityName = geocoderResult2cityName(results[0]);
3240
3279
  const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3241
3280
  const countryName = results.slice(-1)[0].address_components[0].long_name;
@@ -3277,12 +3316,22 @@ const findGmapNearestPlace = (place, candidates) => {
3277
3316
  return { shortestPlace, shortestDistance };
3278
3317
  };
3279
3318
  const useAmapRecomendPlace = (props) => {
3280
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3319
+ const {
3320
+ pointRef,
3321
+ getRecomendPlace,
3322
+ getLimit,
3323
+ context: context2,
3324
+ emptyPlaceName,
3325
+ onChange,
3326
+ onChangePlace,
3327
+ onChangeCity
3328
+ } = props;
3281
3329
  const availableRef = Vue.ref(true);
3282
3330
  const placeCandidatesRef = Vue.ref([]);
3283
3331
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3284
3332
  const { readyPromise } = useMapSupplier();
3285
3333
  const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
3334
+ emptyPlaceName,
3286
3335
  pointRef,
3287
3336
  onChange: onChangePlace,
3288
3337
  onChangeCity
@@ -3333,12 +3382,22 @@ const useAmapRecomendPlace = (props) => {
3333
3382
  };
3334
3383
  };
3335
3384
  const useGmapRecomendPlace = (props) => {
3336
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3385
+ const {
3386
+ pointRef,
3387
+ getRecomendPlace,
3388
+ getLimit,
3389
+ context: context2,
3390
+ emptyPlaceName,
3391
+ onChange,
3392
+ onChangePlace,
3393
+ onChangeCity
3394
+ } = props;
3337
3395
  const availableRef = Vue.ref(true);
3338
3396
  const placeCandidatesRef = Vue.ref([]);
3339
3397
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3340
3398
  const { readyPromise } = useMapSupplier();
3341
3399
  const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
3400
+ emptyPlaceName,
3342
3401
  pointRef,
3343
3402
  onChange: onChangePlace,
3344
3403
  onChangeCity
@@ -3805,7 +3864,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3805
3864
  const pipedGetRecomendPlace = pipeOnlyLastEffect(getRecomendPlace);
3806
3865
  const {
3807
3866
  mapRef,
3808
- setMap
3867
+ setMap,
3868
+ panTo
3809
3869
  } = useHeycarMap();
3810
3870
  const {
3811
3871
  readyPromise
@@ -3916,6 +3976,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3916
3976
  isElectedRef
3917
3977
  } = useMapRecomendPlace({
3918
3978
  pointRef: centerPoint,
3979
+ emptyPlaceName: DEFAULT_PLACE_NAME,
3919
3980
  context: centerSource,
3920
3981
  getRecomendPlace: pipedGetRecomendPlace,
3921
3982
  getLimit: (context2) => {
@@ -3943,6 +4004,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3943
4004
  Object.assign(centerPlace, {
3944
4005
  ...place
3945
4006
  });
4007
+ panTo(place2point(place));
3946
4008
  emit("changeRecomandPlace", place);
3947
4009
  if (isFirstWorkflowRecomendLoadingRef.value)
3948
4010
  await pipeDefer(setZoom)(READY_ZOOM);
@@ -3961,18 +4023,18 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3961
4023
  mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
3962
4024
  });
3963
4025
  return () => {
3964
- var _a2;
3965
4026
  const {
3966
4027
  geoLoadingTitle,
3967
4028
  recomendDescription,
3968
4029
  unavailableTitle
3969
4030
  } = props;
3970
- const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : (_a2 = centerPlace.name) != null ? _a2 : DEFAULT_PLACE_NAME;
4031
+ const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : centerPlace.name;
3971
4032
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
3972
4033
  return Vue.h(HeycarMap, {
3973
4034
  "attrs": {
3974
4035
  "center": centerPoint.value,
3975
4036
  "zoom": zoomRef.value,
4037
+ "touchZoomCenter": true,
3976
4038
  "mapRef": setMap
3977
4039
  }
3978
4040
  }, [!geoLoading.value && !geoError.value && Vue.h(PassengerCircle, {
@@ -4864,7 +4926,7 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
4864
4926
  } = useMapFitView({
4865
4927
  mapRef,
4866
4928
  autoFitTimeout: 5e3,
4867
- padding: [25, 20, 15, 15]
4929
+ padding: [19, 36, 19, 26]
4868
4930
  });
4869
4931
  const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
4870
4932
  return () => {
@@ -5247,7 +5309,7 @@ const useBusinessTaxiServiceMap = () => {
5247
5309
  const { registerFitVeiw, setFitView } = useMapFitView({
5248
5310
  mapRef,
5249
5311
  autoFitTimeout: 5e3,
5250
- padding: [19, 26, 19, 26]
5312
+ padding: [19, 36, 19, 26]
5251
5313
  });
5252
5314
  return { setMap, registerFitVeiw, setFitView };
5253
5315
  };
package/dist/index.js CHANGED
@@ -1857,6 +1857,35 @@ const useMapLoader = (props) => {
1857
1857
  onChange
1858
1858
  });
1859
1859
  };
1860
+ const ZOOM_WHEEL_RATIO = -135e-5;
1861
+ const useAmapWheelZoomCenter = (props) => {
1862
+ const { mapRef, enableRef } = props;
1863
+ const handleWheel = (e) => {
1864
+ var _a, _b, _c;
1865
+ const { deltaY } = e;
1866
+ const prevZoom = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : 0;
1867
+ const zoom = prevZoom + ZOOM_WHEEL_RATIO * deltaY;
1868
+ console.log("handleWheel zoom = ", zoom);
1869
+ (_c = mapRef.value) == null ? void 0 : _c.setZoom(zoom);
1870
+ };
1871
+ watch(
1872
+ () => enableRef == null ? void 0 : enableRef.value,
1873
+ (enable, _, onCleanup) => {
1874
+ if (enable) {
1875
+ console.log("addEventListener wheel");
1876
+ addEventListener("wheel", handleWheel);
1877
+ } else {
1878
+ console.log("removeEventListener wheel");
1879
+ removeEventListener("wheel", handleWheel);
1880
+ }
1881
+ onCleanup(() => {
1882
+ console.log("onClean removeEventListener wheel");
1883
+ removeEventListener("wheel", handleWheel);
1884
+ });
1885
+ },
1886
+ { immediate: true }
1887
+ );
1888
+ };
1860
1889
  const Amap_css_ts_vanilla = "";
1861
1890
  var amap = "_1d8ur7t0";
1862
1891
  const Amap = defineSetup(function Amap2(props, { slots, emit }) {
@@ -1879,9 +1908,10 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
1879
1908
  animateEnable = true,
1880
1909
  keyboardEnable = true,
1881
1910
  doubleClickZoom = true,
1882
- scrollWheel = true,
1883
- touchZoom = true
1911
+ touchZoom = true,
1912
+ touchZoomCenter = 0
1884
1913
  } = props;
1914
+ const scrollWheel = touchZoomCenter ? false : props.scrollWheel;
1885
1915
  return {
1886
1916
  dragEnable,
1887
1917
  zoomEnable,
@@ -1892,17 +1922,20 @@ const Amap = defineSetup(function Amap2(props, { slots, emit }) {
1892
1922
  keyboardEnable,
1893
1923
  doubleClickZoom,
1894
1924
  scrollWheel,
1895
- touchZoom
1925
+ touchZoom,
1926
+ touchZoomCenter
1896
1927
  };
1897
1928
  });
1898
1929
  const elementRef = shallowRef();
1899
1930
  const mapRef = shallowRef();
1900
1931
  provideAmap(mapRef);
1932
+ useAmapWheelZoomCenter({ mapRef, enableRef: computed(() => !!props.touchZoomCenter) });
1901
1933
  watchPostEffect(() => {
1902
1934
  if (mapRef.value || !elementRef.value)
1903
1935
  return;
1904
1936
  const map = new AMap.Map(elementRef.value, {
1905
1937
  ...defaultOptions,
1938
+ scrollWheel: defaultOptions.touchZoomCenter ? false : defaultOptions.scrollWheel,
1906
1939
  vectorMapForeign,
1907
1940
  mapStyle: "amap://styles/95498a904992a4c0b866a3e4d7729682"
1908
1941
  });
@@ -2061,7 +2094,8 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2061
2094
  mapRef: setMap,
2062
2095
  center,
2063
2096
  zoom,
2064
- touchEnable = true
2097
+ touchEnable = true,
2098
+ touchZoomCenter
2065
2099
  } = props;
2066
2100
  if (status === Status.LOADING)
2067
2101
  return (_a = slots.loading) == null ? void 0 : _a.call(slots);
@@ -2102,6 +2136,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2102
2136
  "doubleClickZoom": touchEnable,
2103
2137
  "scrollWheel": touchEnable,
2104
2138
  "touchZoom": touchEnable,
2139
+ "touchZoomCenter": touchZoomCenter ? 1 : 0,
2105
2140
  "keyboardEnable": touchEnable,
2106
2141
  "pitchEnable": touchEnable
2107
2142
  },
@@ -2112,7 +2147,7 @@ const HeycarMap = defineLagecySetup(function HeycarMap2(props, {
2112
2147
  }, [children]);
2113
2148
  }
2114
2149
  };
2115
- }).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable"]);
2150
+ }).props(["center", "fallback", "loading", "mapRef", "zoom", "touchEnable", "touchZoomCenter"]);
2116
2151
  const AmapPolyline = defineSetup(function AmapPolyline2(props) {
2117
2152
  const polylineRef = shallowRef();
2118
2153
  const mapRef = useAmap();
@@ -3084,6 +3119,7 @@ const useAmapDrag = (props) => {
3084
3119
  var _a;
3085
3120
  isDragging.value = false;
3086
3121
  const { lng, lat } = target.getCenter();
3122
+ spaceLog("dragEnd", "[lng, lat] = ", [lng, lat]);
3087
3123
  centerRef.value = [lng, lat];
3088
3124
  (_a = pipeAsync(onChange)) == null ? void 0 : _a([lng, lat]);
3089
3125
  };
@@ -3133,7 +3169,7 @@ const useUpdate = () => {
3133
3169
  return { idx, update };
3134
3170
  };
3135
3171
  const useAmapPlace = (props) => {
3136
- const { onChange, onChangeCity } = props;
3172
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3137
3173
  const defaultPoint = [...props.pointRef.value];
3138
3174
  const pointRef = ref(defaultPoint);
3139
3175
  const { readyPromise } = useMapSupplier();
@@ -3173,9 +3209,11 @@ const useAmapPlace = (props) => {
3173
3209
  geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3174
3210
  switch (status) {
3175
3211
  case "complete": {
3176
- const { formattedAddress: name, addressComponent } = result.regeocode;
3212
+ const { formattedAddress, addressComponent } = result.regeocode;
3177
3213
  const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3178
3214
  const cityParentName = addressComponent.province;
3215
+ const name = formattedAddress ? formattedAddress : emptyPlaceName;
3216
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, name, lng, lat);
3179
3217
  place.name = name;
3180
3218
  place.lng = lng;
3181
3219
  place.lat = lat;
@@ -3184,9 +3222,10 @@ const useAmapPlace = (props) => {
3184
3222
  return;
3185
3223
  }
3186
3224
  case "no_data":
3187
- place.name = "";
3225
+ place.name = emptyPlaceName;
3188
3226
  place.lng = lng;
3189
3227
  place.lat = lat;
3228
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, "", lng, lat);
3190
3229
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3191
3230
  return;
3192
3231
  case "error":
@@ -3198,7 +3237,7 @@ const useAmapPlace = (props) => {
3198
3237
  return { place, updatePlace, setPlace, updateCity };
3199
3238
  };
3200
3239
  const useGmapPlace = (props) => {
3201
- const { onChange, onChangeCity } = props;
3240
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3202
3241
  const defaultPoint = [...props.pointRef.value];
3203
3242
  const pointRef = ref(defaultPoint);
3204
3243
  const { readyPromise } = useMapSupplier();
@@ -3233,7 +3272,7 @@ const useGmapPlace = (props) => {
3233
3272
  const geocoder = new google.maps.Geocoder();
3234
3273
  const [lng, lat] = pointRef.value;
3235
3274
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3236
- const name = results[0].formatted_address;
3275
+ const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3237
3276
  const cityName = geocoderResult2cityName(results[0]);
3238
3277
  const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3239
3278
  const countryName = results.slice(-1)[0].address_components[0].long_name;
@@ -3275,12 +3314,22 @@ const findGmapNearestPlace = (place, candidates) => {
3275
3314
  return { shortestPlace, shortestDistance };
3276
3315
  };
3277
3316
  const useAmapRecomendPlace = (props) => {
3278
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3317
+ const {
3318
+ pointRef,
3319
+ getRecomendPlace,
3320
+ getLimit,
3321
+ context: context2,
3322
+ emptyPlaceName,
3323
+ onChange,
3324
+ onChangePlace,
3325
+ onChangeCity
3326
+ } = props;
3279
3327
  const availableRef = ref(true);
3280
3328
  const placeCandidatesRef = ref([]);
3281
3329
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3282
3330
  const { readyPromise } = useMapSupplier();
3283
3331
  const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
3332
+ emptyPlaceName,
3284
3333
  pointRef,
3285
3334
  onChange: onChangePlace,
3286
3335
  onChangeCity
@@ -3331,12 +3380,22 @@ const useAmapRecomendPlace = (props) => {
3331
3380
  };
3332
3381
  };
3333
3382
  const useGmapRecomendPlace = (props) => {
3334
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3383
+ const {
3384
+ pointRef,
3385
+ getRecomendPlace,
3386
+ getLimit,
3387
+ context: context2,
3388
+ emptyPlaceName,
3389
+ onChange,
3390
+ onChangePlace,
3391
+ onChangeCity
3392
+ } = props;
3335
3393
  const availableRef = ref(true);
3336
3394
  const placeCandidatesRef = ref([]);
3337
3395
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3338
3396
  const { readyPromise } = useMapSupplier();
3339
3397
  const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
3398
+ emptyPlaceName,
3340
3399
  pointRef,
3341
3400
  onChange: onChangePlace,
3342
3401
  onChangeCity
@@ -3803,7 +3862,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3803
3862
  const pipedGetRecomendPlace = pipeOnlyLastEffect(getRecomendPlace);
3804
3863
  const {
3805
3864
  mapRef,
3806
- setMap
3865
+ setMap,
3866
+ panTo
3807
3867
  } = useHeycarMap();
3808
3868
  const {
3809
3869
  readyPromise
@@ -3914,6 +3974,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3914
3974
  isElectedRef
3915
3975
  } = useMapRecomendPlace({
3916
3976
  pointRef: centerPoint,
3977
+ emptyPlaceName: DEFAULT_PLACE_NAME,
3917
3978
  context: centerSource,
3918
3979
  getRecomendPlace: pipedGetRecomendPlace,
3919
3980
  getLimit: (context2) => {
@@ -3941,6 +4002,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3941
4002
  Object.assign(centerPlace, {
3942
4003
  ...place
3943
4004
  });
4005
+ panTo(place2point(place));
3944
4006
  emit("changeRecomandPlace", place);
3945
4007
  if (isFirstWorkflowRecomendLoadingRef.value)
3946
4008
  await pipeDefer(setZoom)(READY_ZOOM);
@@ -3959,18 +4021,18 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3959
4021
  mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
3960
4022
  });
3961
4023
  return () => {
3962
- var _a2;
3963
4024
  const {
3964
4025
  geoLoadingTitle,
3965
4026
  recomendDescription,
3966
4027
  unavailableTitle
3967
4028
  } = props;
3968
- const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : (_a2 = centerPlace.name) != null ? _a2 : DEFAULT_PLACE_NAME;
4029
+ const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : centerPlace.name;
3969
4030
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
3970
4031
  return h(HeycarMap, {
3971
4032
  "attrs": {
3972
4033
  "center": centerPoint.value,
3973
4034
  "zoom": zoomRef.value,
4035
+ "touchZoomCenter": true,
3974
4036
  "mapRef": setMap
3975
4037
  }
3976
4038
  }, [!geoLoading.value && !geoError.value && h(PassengerCircle, {
@@ -4862,7 +4924,7 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
4862
4924
  } = useMapFitView({
4863
4925
  mapRef,
4864
4926
  autoFitTimeout: 5e3,
4865
- padding: [25, 20, 15, 15]
4927
+ padding: [19, 36, 19, 26]
4866
4928
  });
4867
4929
  const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
4868
4930
  return () => {
@@ -5245,7 +5307,7 @@ const useBusinessTaxiServiceMap = () => {
5245
5307
  const { registerFitVeiw, setFitView } = useMapFitView({
5246
5308
  mapRef,
5247
5309
  autoFitTimeout: 5e3,
5248
- padding: [19, 26, 19, 26]
5310
+ padding: [19, 36, 19, 26]
5249
5311
  });
5250
5312
  return { setMap, registerFitVeiw, setFitView };
5251
5313
  };
package/dist/style.css CHANGED
@@ -140,7 +140,7 @@
140
140
  font-family: PingFangSC-Medium, PingFang SC;
141
141
  font-weight: 500;
142
142
  color: #1E1E1E;
143
- line-height: 3.9vw;
143
+ line-height: 4vw;
144
144
  -webkit-line-clamp: 2;
145
145
  -webkit-box-orient: vertical;
146
146
  overflow: hidden;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/todo.md CHANGED
@@ -3,39 +3,26 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
3
3
  2. Google 地址名称太长
4
4
  3. 高德地图加载期间出现大量的请求
5
5
  4. 做完其他事情进入首页,变成了获取定位失败,但其实 gps 是 ok 的,因为刷新页面是有点位的
6
+ 5. map 的两个 slot loading 和 error slot 没有生效
7
+ 6. 企业微信如果关闭定位,会不停的跳 geoError 事件
6
8
 
7
- 特殊
9
+ 缩放问题
8
10
 
9
- - 5173
10
- - 5244 新开一个窗口,打开网址
11
-
12
- caught (in promise) Error: Invalid Object: LngLat(NaN, NaN)
11
+ - 4867
12
+ - 4920
13
13
 
14
14
  章新华
15
15
 
16
16
  - 5238
17
17
 
18
- 郝瑞
19
-
20
- - 5033 是否可以关闭
21
- - 5177 不太明白
22
- - 5168 需要在 获取推荐点的接口调用那里增加 地图供应商参数
23
-
24
18
  不明白的
25
19
 
26
- - 4843
27
- - 4986
28
- - 5024
29
20
  - 5294
30
21
 
31
22
  需要复现
32
23
 
33
- - 4769
34
- - 4867
35
24
  - 5044
36
25
  - 5113
37
- - 5173
38
- - 5303 需要 nearAddress 发送的经纬度
39
26
  - 5291
40
27
  - 5257 我的 safari 没有问题
41
28
 
@@ -81,3 +68,14 @@ caught (in promise) Error: Invalid Object: LngLat(NaN, NaN)
81
68
  - 5198
82
69
  - 5173
83
70
  - 5168
71
+
72
+ 0.5.1
73
+
74
+ - 5303
75
+ - 5329
76
+ - 4769
77
+ - 5044 (跟章新华说下)
78
+ - 5314
79
+ - 5347
80
+ - 5348
81
+ - 5057