@heycar/heycars-map 0.5.0 → 0.5.1

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.
@@ -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"];
package/dist/index.cjs CHANGED
@@ -3086,6 +3086,7 @@ const useAmapDrag = (props) => {
3086
3086
  var _a;
3087
3087
  isDragging.value = false;
3088
3088
  const { lng, lat } = target.getCenter();
3089
+ spaceLog("dragEnd", "[lng, lat] = ", [lng, lat]);
3089
3090
  centerRef.value = [lng, lat];
3090
3091
  (_a = pipeAsync(onChange)) == null ? void 0 : _a([lng, lat]);
3091
3092
  };
@@ -3135,7 +3136,7 @@ const useUpdate = () => {
3135
3136
  return { idx, update };
3136
3137
  };
3137
3138
  const useAmapPlace = (props) => {
3138
- const { onChange, onChangeCity } = props;
3139
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3139
3140
  const defaultPoint = [...props.pointRef.value];
3140
3141
  const pointRef = Vue.ref(defaultPoint);
3141
3142
  const { readyPromise } = useMapSupplier();
@@ -3175,9 +3176,11 @@ const useAmapPlace = (props) => {
3175
3176
  geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3176
3177
  switch (status) {
3177
3178
  case "complete": {
3178
- const { formattedAddress: name, addressComponent } = result.regeocode;
3179
+ const { formattedAddress, addressComponent } = result.regeocode;
3179
3180
  const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3180
3181
  const cityParentName = addressComponent.province;
3182
+ const name = formattedAddress ? formattedAddress : emptyPlaceName;
3183
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, name, lng, lat);
3181
3184
  place.name = name;
3182
3185
  place.lng = lng;
3183
3186
  place.lat = lat;
@@ -3186,9 +3189,10 @@ const useAmapPlace = (props) => {
3186
3189
  return;
3187
3190
  }
3188
3191
  case "no_data":
3189
- place.name = "";
3192
+ place.name = emptyPlaceName;
3190
3193
  place.lng = lng;
3191
3194
  place.lat = lat;
3195
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, "", lng, lat);
3192
3196
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3193
3197
  return;
3194
3198
  case "error":
@@ -3200,7 +3204,7 @@ const useAmapPlace = (props) => {
3200
3204
  return { place, updatePlace, setPlace, updateCity };
3201
3205
  };
3202
3206
  const useGmapPlace = (props) => {
3203
- const { onChange, onChangeCity } = props;
3207
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3204
3208
  const defaultPoint = [...props.pointRef.value];
3205
3209
  const pointRef = Vue.ref(defaultPoint);
3206
3210
  const { readyPromise } = useMapSupplier();
@@ -3235,7 +3239,7 @@ const useGmapPlace = (props) => {
3235
3239
  const geocoder = new google.maps.Geocoder();
3236
3240
  const [lng, lat] = pointRef.value;
3237
3241
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3238
- const name = results[0].formatted_address;
3242
+ const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3239
3243
  const cityName = geocoderResult2cityName(results[0]);
3240
3244
  const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3241
3245
  const countryName = results.slice(-1)[0].address_components[0].long_name;
@@ -3277,12 +3281,22 @@ const findGmapNearestPlace = (place, candidates) => {
3277
3281
  return { shortestPlace, shortestDistance };
3278
3282
  };
3279
3283
  const useAmapRecomendPlace = (props) => {
3280
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3284
+ const {
3285
+ pointRef,
3286
+ getRecomendPlace,
3287
+ getLimit,
3288
+ context: context2,
3289
+ emptyPlaceName,
3290
+ onChange,
3291
+ onChangePlace,
3292
+ onChangeCity
3293
+ } = props;
3281
3294
  const availableRef = Vue.ref(true);
3282
3295
  const placeCandidatesRef = Vue.ref([]);
3283
3296
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3284
3297
  const { readyPromise } = useMapSupplier();
3285
3298
  const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
3299
+ emptyPlaceName,
3286
3300
  pointRef,
3287
3301
  onChange: onChangePlace,
3288
3302
  onChangeCity
@@ -3333,12 +3347,22 @@ const useAmapRecomendPlace = (props) => {
3333
3347
  };
3334
3348
  };
3335
3349
  const useGmapRecomendPlace = (props) => {
3336
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3350
+ const {
3351
+ pointRef,
3352
+ getRecomendPlace,
3353
+ getLimit,
3354
+ context: context2,
3355
+ emptyPlaceName,
3356
+ onChange,
3357
+ onChangePlace,
3358
+ onChangeCity
3359
+ } = props;
3337
3360
  const availableRef = Vue.ref(true);
3338
3361
  const placeCandidatesRef = Vue.ref([]);
3339
3362
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3340
3363
  const { readyPromise } = useMapSupplier();
3341
3364
  const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
3365
+ emptyPlaceName,
3342
3366
  pointRef,
3343
3367
  onChange: onChangePlace,
3344
3368
  onChangeCity
@@ -3805,7 +3829,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3805
3829
  const pipedGetRecomendPlace = pipeOnlyLastEffect(getRecomendPlace);
3806
3830
  const {
3807
3831
  mapRef,
3808
- setMap
3832
+ setMap,
3833
+ panTo
3809
3834
  } = useHeycarMap();
3810
3835
  const {
3811
3836
  readyPromise
@@ -3916,6 +3941,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3916
3941
  isElectedRef
3917
3942
  } = useMapRecomendPlace({
3918
3943
  pointRef: centerPoint,
3944
+ emptyPlaceName: DEFAULT_PLACE_NAME,
3919
3945
  context: centerSource,
3920
3946
  getRecomendPlace: pipedGetRecomendPlace,
3921
3947
  getLimit: (context2) => {
@@ -3943,6 +3969,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3943
3969
  Object.assign(centerPlace, {
3944
3970
  ...place
3945
3971
  });
3972
+ panTo(place2point(place));
3946
3973
  emit("changeRecomandPlace", place);
3947
3974
  if (isFirstWorkflowRecomendLoadingRef.value)
3948
3975
  await pipeDefer(setZoom)(READY_ZOOM);
@@ -3961,13 +3988,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3961
3988
  mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
3962
3989
  });
3963
3990
  return () => {
3964
- var _a2;
3965
3991
  const {
3966
3992
  geoLoadingTitle,
3967
3993
  recomendDescription,
3968
3994
  unavailableTitle
3969
3995
  } = props;
3970
- const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : (_a2 = centerPlace.name) != null ? _a2 : DEFAULT_PLACE_NAME;
3996
+ const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : centerPlace.name;
3971
3997
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
3972
3998
  return Vue.h(HeycarMap, {
3973
3999
  "attrs": {
@@ -4864,7 +4890,7 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
4864
4890
  } = useMapFitView({
4865
4891
  mapRef,
4866
4892
  autoFitTimeout: 5e3,
4867
- padding: [25, 20, 15, 15]
4893
+ padding: [19, 36, 19, 26]
4868
4894
  });
4869
4895
  const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
4870
4896
  return () => {
@@ -5247,7 +5273,7 @@ const useBusinessTaxiServiceMap = () => {
5247
5273
  const { registerFitVeiw, setFitView } = useMapFitView({
5248
5274
  mapRef,
5249
5275
  autoFitTimeout: 5e3,
5250
- padding: [19, 26, 19, 26]
5276
+ padding: [19, 36, 19, 26]
5251
5277
  });
5252
5278
  return { setMap, registerFitVeiw, setFitView };
5253
5279
  };
package/dist/index.js CHANGED
@@ -3084,6 +3084,7 @@ const useAmapDrag = (props) => {
3084
3084
  var _a;
3085
3085
  isDragging.value = false;
3086
3086
  const { lng, lat } = target.getCenter();
3087
+ spaceLog("dragEnd", "[lng, lat] = ", [lng, lat]);
3087
3088
  centerRef.value = [lng, lat];
3088
3089
  (_a = pipeAsync(onChange)) == null ? void 0 : _a([lng, lat]);
3089
3090
  };
@@ -3133,7 +3134,7 @@ const useUpdate = () => {
3133
3134
  return { idx, update };
3134
3135
  };
3135
3136
  const useAmapPlace = (props) => {
3136
- const { onChange, onChangeCity } = props;
3137
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3137
3138
  const defaultPoint = [...props.pointRef.value];
3138
3139
  const pointRef = ref(defaultPoint);
3139
3140
  const { readyPromise } = useMapSupplier();
@@ -3173,9 +3174,11 @@ const useAmapPlace = (props) => {
3173
3174
  geocoder.getAddress(new AMap.LngLat(lng, lat), (status, result) => {
3174
3175
  switch (status) {
3175
3176
  case "complete": {
3176
- const { formattedAddress: name, addressComponent } = result.regeocode;
3177
+ const { formattedAddress, addressComponent } = result.regeocode;
3177
3178
  const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3178
3179
  const cityParentName = addressComponent.province;
3180
+ const name = formattedAddress ? formattedAddress : emptyPlaceName;
3181
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, name, lng, lat);
3179
3182
  place.name = name;
3180
3183
  place.lng = lng;
3181
3184
  place.lat = lat;
@@ -3184,9 +3187,10 @@ const useAmapPlace = (props) => {
3184
3187
  return;
3185
3188
  }
3186
3189
  case "no_data":
3187
- place.name = "";
3190
+ place.name = emptyPlaceName;
3188
3191
  place.lng = lng;
3189
3192
  place.lat = lat;
3193
+ console.log("geocoder.getAddress status, name, lng, lat = ", status, "", lng, lat);
3190
3194
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3191
3195
  return;
3192
3196
  case "error":
@@ -3198,7 +3202,7 @@ const useAmapPlace = (props) => {
3198
3202
  return { place, updatePlace, setPlace, updateCity };
3199
3203
  };
3200
3204
  const useGmapPlace = (props) => {
3201
- const { onChange, onChangeCity } = props;
3205
+ const { onChange, onChangeCity, emptyPlaceName } = props;
3202
3206
  const defaultPoint = [...props.pointRef.value];
3203
3207
  const pointRef = ref(defaultPoint);
3204
3208
  const { readyPromise } = useMapSupplier();
@@ -3233,7 +3237,7 @@ const useGmapPlace = (props) => {
3233
3237
  const geocoder = new google.maps.Geocoder();
3234
3238
  const [lng, lat] = pointRef.value;
3235
3239
  const { results } = await geocoder.geocode({ language: LANGUAGE, location: { lng, lat } });
3236
- const name = results[0].formatted_address;
3240
+ const name = results[0].formatted_address ? results[0].formatted_address : emptyPlaceName;
3237
3241
  const cityName = geocoderResult2cityName(results[0]);
3238
3242
  const cityParentName = results.slice(-2)[0].address_components[0].long_name;
3239
3243
  const countryName = results.slice(-1)[0].address_components[0].long_name;
@@ -3275,12 +3279,22 @@ const findGmapNearestPlace = (place, candidates) => {
3275
3279
  return { shortestPlace, shortestDistance };
3276
3280
  };
3277
3281
  const useAmapRecomendPlace = (props) => {
3278
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3282
+ const {
3283
+ pointRef,
3284
+ getRecomendPlace,
3285
+ getLimit,
3286
+ context: context2,
3287
+ emptyPlaceName,
3288
+ onChange,
3289
+ onChangePlace,
3290
+ onChangeCity
3291
+ } = props;
3279
3292
  const availableRef = ref(true);
3280
3293
  const placeCandidatesRef = ref([]);
3281
3294
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3282
3295
  const { readyPromise } = useMapSupplier();
3283
3296
  const { place, updatePlace, setPlace, updateCity } = useAmapPlace({
3297
+ emptyPlaceName,
3284
3298
  pointRef,
3285
3299
  onChange: onChangePlace,
3286
3300
  onChangeCity
@@ -3331,12 +3345,22 @@ const useAmapRecomendPlace = (props) => {
3331
3345
  };
3332
3346
  };
3333
3347
  const useGmapRecomendPlace = (props) => {
3334
- const { pointRef, getRecomendPlace, getLimit, context: context2, onChange, onChangePlace, onChangeCity } = props;
3348
+ const {
3349
+ pointRef,
3350
+ getRecomendPlace,
3351
+ getLimit,
3352
+ context: context2,
3353
+ emptyPlaceName,
3354
+ onChange,
3355
+ onChangePlace,
3356
+ onChangeCity
3357
+ } = props;
3335
3358
  const availableRef = ref(true);
3336
3359
  const placeCandidatesRef = ref([]);
3337
3360
  const { idx: recomendPlaceKey, update: updateRecomandPlace } = useUpdate();
3338
3361
  const { readyPromise } = useMapSupplier();
3339
3362
  const { place, updatePlace, setPlace, updateCity } = useGmapPlace({
3363
+ emptyPlaceName,
3340
3364
  pointRef,
3341
3365
  onChange: onChangePlace,
3342
3366
  onChangeCity
@@ -3803,7 +3827,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3803
3827
  const pipedGetRecomendPlace = pipeOnlyLastEffect(getRecomendPlace);
3804
3828
  const {
3805
3829
  mapRef,
3806
- setMap
3830
+ setMap,
3831
+ panTo
3807
3832
  } = useHeycarMap();
3808
3833
  const {
3809
3834
  readyPromise
@@ -3914,6 +3939,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3914
3939
  isElectedRef
3915
3940
  } = useMapRecomendPlace({
3916
3941
  pointRef: centerPoint,
3942
+ emptyPlaceName: DEFAULT_PLACE_NAME,
3917
3943
  context: centerSource,
3918
3944
  getRecomendPlace: pipedGetRecomendPlace,
3919
3945
  getLimit: (context2) => {
@@ -3941,6 +3967,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3941
3967
  Object.assign(centerPlace, {
3942
3968
  ...place
3943
3969
  });
3970
+ panTo(place2point(place));
3944
3971
  emit("changeRecomandPlace", place);
3945
3972
  if (isFirstWorkflowRecomendLoadingRef.value)
3946
3973
  await pipeDefer(setZoom)(READY_ZOOM);
@@ -3959,13 +3986,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
3959
3986
  mapContext.onChangeRecomendPlaces([...placeCandidates.value]);
3960
3987
  });
3961
3988
  return () => {
3962
- var _a2;
3963
3989
  const {
3964
3990
  geoLoadingTitle,
3965
3991
  recomendDescription,
3966
3992
  unavailableTitle
3967
3993
  } = props;
3968
- const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : (_a2 = centerPlace.name) != null ? _a2 : DEFAULT_PLACE_NAME;
3994
+ const title = geoLoading.value ? geoLoadingTitle : !availableRef.value ? unavailableTitle : centerPlace.name;
3969
3995
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
3970
3996
  return h(HeycarMap, {
3971
3997
  "attrs": {
@@ -4862,7 +4888,7 @@ const BusinessTaxiEndMap = defineSetup(function BusinessTaxiEndMap2(props) {
4862
4888
  } = useMapFitView({
4863
4889
  mapRef,
4864
4890
  autoFitTimeout: 5e3,
4865
- padding: [25, 20, 15, 15]
4891
+ padding: [19, 36, 19, 26]
4866
4892
  });
4867
4893
  const deferedSetFitView = pipeDefer(registerFitVeiw.setFitView);
4868
4894
  return () => {
@@ -5245,7 +5271,7 @@ const useBusinessTaxiServiceMap = () => {
5245
5271
  const { registerFitVeiw, setFitView } = useMapFitView({
5246
5272
  mapRef,
5247
5273
  autoFitTimeout: 5e3,
5248
- padding: [19, 26, 19, 26]
5274
+ padding: [19, 36, 19, 26]
5249
5275
  });
5250
5276
  return { setMap, registerFitVeiw, setFitView };
5251
5277
  };
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.1",
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