@heycar/heycars-map 0.8.9 → 0.9.0

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.
package/dist/index.cjs CHANGED
@@ -9,7 +9,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
9
9
  const Vue = require("vue");
10
10
  const style = "";
11
11
  const name = "@heycar/heycars-map";
12
- const version = "0.8.9";
12
+ const version = "0.9.0";
13
13
  const type = "module";
14
14
  const scripts = {
15
15
  dev: "vite -c vite.config.dev.ts",
@@ -3473,12 +3473,13 @@ const patchMiniprogramRedirectTo = (wx2) => {
3473
3473
  };
3474
3474
  return patchedRedirectTo;
3475
3475
  };
3476
- const DEVICE_ORIENTATION_INTERVAL = 1e3;
3476
+ const DEVICE_ORIENTATION_INTERVAL = 200;
3477
3477
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3478
3478
  const useDeviceOrientation = (props) => {
3479
3479
  const { onChange, elementRef } = props;
3480
3480
  const orientation = Vue.reactive({ cssRotationVariableName: void 0 });
3481
3481
  const cssVarName = `${CSS_DEVICE_ORIENTATION_VAR_PREFIX}${Date.now()}`;
3482
+ const toTransitionAngle = createToTransitionAngle();
3482
3483
  Vue.watch(
3483
3484
  () => elementRef.value,
3484
3485
  (element, _, onCleanup) => {
@@ -3488,7 +3489,7 @@ const useDeviceOrientation = (props) => {
3488
3489
  const alpha = webkitCompassHeading !== void 0 ? 360 - webkitCompassHeading : (_b = event.alpha) != null ? _b : void 0;
3489
3490
  const beta = (_c = event.beta) != null ? _c : void 0;
3490
3491
  const gamma = (_d = event.gamma) != null ? _d : void 0;
3491
- const cssRotationVariableValue = `${360 - (alpha != null ? alpha : 0)}deg`;
3492
+ const cssRotationVariableValue = `${toTransitionAngle(360 - (alpha != null ? alpha : 0))}deg`;
3492
3493
  const cssRotationVariableName = alpha === void 0 ? void 0 : cssVarName;
3493
3494
  Object.assign(orientation, { alpha, beta, gamma });
3494
3495
  if (orientation.cssRotationVariableName !== cssRotationVariableName) {
@@ -3560,6 +3561,32 @@ function waitMiniProgramWebviewClose(duration) {
3560
3561
  }, duration);
3561
3562
  });
3562
3563
  }
3564
+ function createToTransitionAngle() {
3565
+ let prev = void 0;
3566
+ const mod = (x, m) => {
3567
+ const negatabbleValue = x % m;
3568
+ return negatabbleValue < 0 ? m + negatabbleValue : negatabbleValue;
3569
+ };
3570
+ return function toTransitionAngle(angle) {
3571
+ if (prev === void 0) {
3572
+ prev = angle;
3573
+ console.log("toTransitionAngle angle = ", angle);
3574
+ return angle;
3575
+ }
3576
+ const prevRemainder = mod(prev, 360);
3577
+ const cycles = (prev - prevRemainder) / 360;
3578
+ if (Math.abs(angle - prevRemainder) <= 180) {
3579
+ const result = angle + cycles * 360;
3580
+ prev = result;
3581
+ return result;
3582
+ } else {
3583
+ const deltaCycles = angle > prevRemainder ? -1 : 1;
3584
+ const result = angle + (cycles + deltaCycles) * 360;
3585
+ prev = result;
3586
+ return result;
3587
+ }
3588
+ };
3589
+ }
3563
3590
  const watchVisibilityState = () => {
3564
3591
  const visibilityStateRef = Vue.ref(document.visibilityState);
3565
3592
  const handleVisibilityChange = () => {
@@ -3574,6 +3601,7 @@ const watchVisibilityState = () => {
3574
3601
  const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3575
3602
  const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3576
3603
  const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
3604
+ const ANDROID_GET_LOCATION_INTERVAL = 1 * 1e3;
3577
3605
  const takeIsForceBrowserGeo = () => {
3578
3606
  const searchParam = new URLSearchParams(location.search);
3579
3607
  return searchParam.has(`force-browser-geo`);
@@ -3582,14 +3610,6 @@ const wxReady = () => new Promise((resolve, reject) => {
3582
3610
  wx.ready(resolve);
3583
3611
  wx.error(reject);
3584
3612
  });
3585
- const detectPlatform = () => {
3586
- const useragent = navigator.userAgent.toLowerCase();
3587
- if (useragent.includes("micromessenger"))
3588
- return "wechat";
3589
- if (useragent.includes("alipay"))
3590
- return "alipay";
3591
- return "other";
3592
- };
3593
3613
  function wechatWatchPosition(onSuccess, onError, option) {
3594
3614
  const { timeout } = option;
3595
3615
  let enable = true;
@@ -3651,20 +3671,67 @@ function wechatWatchPosition(onSuccess, onError, option) {
3651
3671
  unwatchVisibilityState();
3652
3672
  };
3653
3673
  }
3674
+ function androidWatchPosition(onSuccess, onError, option) {
3675
+ let enable = true;
3676
+ let prevGeoPosition = void 0;
3677
+ const isGeoWorkingRef = Vue.ref(true);
3678
+ const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
3679
+ const startWatch = async () => {
3680
+ do {
3681
+ if (visibilityStateRef.value === "hidden") {
3682
+ await sleep(ANDROID_GET_LOCATION_INTERVAL);
3683
+ continue;
3684
+ }
3685
+ const geoPosition = await new Promise((resolve) => {
3686
+ navigator.geolocation.getCurrentPosition(
3687
+ function onSuccess2(geoLocationPosition) {
3688
+ isGeoWorkingRef.value = true;
3689
+ resolve(geoLocationPosition);
3690
+ },
3691
+ function onFail(geoError) {
3692
+ const isGeoWorking = isGeoWorkingRef.value;
3693
+ isGeoWorkingRef.value = false;
3694
+ resolve(void 0);
3695
+ if (!isGeoWorking)
3696
+ return;
3697
+ console.warn(
3698
+ "MyWarning: navigator.geolocation.getCurrentPosition failed: ",
3699
+ geoError.message
3700
+ );
3701
+ onError == null ? void 0 : onError(geoError);
3702
+ },
3703
+ option
3704
+ );
3705
+ });
3706
+ if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
3707
+ onSuccess(geoPosition);
3708
+ prevGeoPosition = geoPosition;
3709
+ await sleep(ANDROID_GET_LOCATION_INTERVAL);
3710
+ } while (enable);
3711
+ };
3712
+ startWatch();
3713
+ return () => {
3714
+ enable = false;
3715
+ unwatchVisibilityState();
3716
+ };
3717
+ }
3654
3718
  function compatibleWathPosition(onSuccess, onError, option) {
3655
3719
  const isForceBrowserGeo = takeIsForceBrowserGeo();
3656
3720
  if (isForceBrowserGeo) {
3657
- const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3658
- return () => navigator.geolocation.clearWatch(watchId);
3721
+ const watchId2 = navigator.geolocation.watchPosition(onSuccess, onError, option);
3722
+ return () => navigator.geolocation.clearWatch(watchId2);
3659
3723
  }
3660
- switch (detectPlatform()) {
3661
- case "wechat":
3662
- return wechatWatchPosition(onSuccess, onError, option);
3663
- default: {
3664
- const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3665
- return () => navigator.geolocation.clearWatch(watchId);
3666
- }
3724
+ const browserPlatform = detectBrowserPlatform();
3725
+ const osPlatform = detectOSPlatform();
3726
+ console.log("osPlatform = ", osPlatform);
3727
+ if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
3728
+ return wechatWatchPosition(onSuccess, onError, option);
3667
3729
  }
3730
+ if (osPlatform === OS_PLATFORM.ANDROID) {
3731
+ return androidWatchPosition(onSuccess, onError, option);
3732
+ }
3733
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3734
+ return () => navigator.geolocation.clearWatch(watchId);
3668
3735
  }
3669
3736
  class SingleGeoWatch {
3670
3737
  constructor(option) {
@@ -5758,6 +5825,69 @@ const useMapRecomendPlace = (props) => {
5758
5825
  const { supplier } = useMapSupplier();
5759
5826
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5760
5827
  };
5828
+ const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5829
+ const DEFAULT_ZOOM$1 = 13;
5830
+ const useAmapZoom = (props) => {
5831
+ var _a, _b, _c;
5832
+ const { onChange, mapRef, defaultValue } = props;
5833
+ const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5834
+ const setZoom = (v) => {
5835
+ var _a2;
5836
+ zoomRef.value = v;
5837
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5838
+ };
5839
+ const handleZoomEnd = (_, { target }) => {
5840
+ const zoom = target.getZoom();
5841
+ zoomRef.value = zoom;
5842
+ onChange == null ? void 0 : onChange(zoom);
5843
+ };
5844
+ Vue.watch(
5845
+ () => mapRef.value,
5846
+ (map) => {
5847
+ if (!map)
5848
+ return;
5849
+ zoomRef.value = map.getZoom();
5850
+ }
5851
+ );
5852
+ watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5853
+ "onZoomEnd"
5854
+ ]);
5855
+ return { zoomRef, setZoom };
5856
+ };
5857
+ const useGmapZoom = (props) => {
5858
+ var _a, _b, _c;
5859
+ const { onChange, mapRef, defaultValue } = props;
5860
+ const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5861
+ const setZoom = (v) => {
5862
+ var _a2;
5863
+ zoomRef.value = v;
5864
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5865
+ };
5866
+ const handleZoomChange = debounce(
5867
+ (_, { target }) => {
5868
+ const zoom = target.getZoom();
5869
+ zoomRef.value = zoom;
5870
+ onChange == null ? void 0 : onChange(zoom);
5871
+ },
5872
+ GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5873
+ );
5874
+ Vue.watch(
5875
+ () => mapRef.value,
5876
+ (map) => {
5877
+ if (!map)
5878
+ return;
5879
+ zoomRef.value = map.getZoom();
5880
+ }
5881
+ );
5882
+ watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5883
+ "onZoom_changed"
5884
+ ]);
5885
+ return { zoomRef, setZoom };
5886
+ };
5887
+ const useMapZoom = (props) => {
5888
+ const { supplier } = useMapSupplier();
5889
+ return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
5890
+ };
5761
5891
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5762
5892
  const polygonRef = Vue.shallowRef();
5763
5893
  const mapRef = useAmap();
@@ -6020,69 +6150,6 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6020
6150
  })]);
6021
6151
  };
6022
6152
  });
6023
- const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
6024
- const DEFAULT_ZOOM$1 = 13;
6025
- const useAmapZoom = (props) => {
6026
- var _a, _b, _c;
6027
- const { onChange, mapRef, defaultValue } = props;
6028
- const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
6029
- const setZoom = (v) => {
6030
- var _a2;
6031
- zoomRef.value = v;
6032
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
6033
- };
6034
- const handleZoomEnd = (_, { target }) => {
6035
- const zoom = target.getZoom();
6036
- zoomRef.value = zoom;
6037
- onChange == null ? void 0 : onChange(zoom);
6038
- };
6039
- Vue.watch(
6040
- () => mapRef.value,
6041
- (map) => {
6042
- if (!map)
6043
- return;
6044
- zoomRef.value = map.getZoom();
6045
- }
6046
- );
6047
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
6048
- "onZoomEnd"
6049
- ]);
6050
- return { zoomRef, setZoom };
6051
- };
6052
- const useGmapZoom = (props) => {
6053
- var _a, _b, _c;
6054
- const { onChange, mapRef, defaultValue } = props;
6055
- const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
6056
- const setZoom = (v) => {
6057
- var _a2;
6058
- zoomRef.value = v;
6059
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
6060
- };
6061
- const handleZoomChange = debounce(
6062
- (_, { target }) => {
6063
- const zoom = target.getZoom();
6064
- zoomRef.value = zoom;
6065
- onChange == null ? void 0 : onChange(zoom);
6066
- },
6067
- GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
6068
- );
6069
- Vue.watch(
6070
- () => mapRef.value,
6071
- (map) => {
6072
- if (!map)
6073
- return;
6074
- zoomRef.value = map.getZoom();
6075
- }
6076
- );
6077
- watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
6078
- "onZoom_changed"
6079
- ]);
6080
- return { zoomRef, setZoom };
6081
- };
6082
- const useMapZoom = (props) => {
6083
- const { supplier } = useMapSupplier();
6084
- return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
6085
- };
6086
6153
  const usePointsLabelDirection = (props) => {
6087
6154
  const { widthLimit, heightLimit } = props;
6088
6155
  const mapRef = useMap();
@@ -6127,11 +6194,23 @@ function createLabelDirections(props) {
6127
6194
  const { sortedPoints, widthLimit, heightLimit, distanceFn } = props;
6128
6195
  const len = sortedPoints.length;
6129
6196
  const result = [];
6130
- const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2) => {
6197
+ const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2, isNextLimited, dx) => {
6198
+ spaceLog(
6199
+ "calcDirection",
6200
+ "isLimited, isDoubleLimited, prevDx, prevDirection, isNextLimited, dx = ",
6201
+ isLimited2,
6202
+ isDoubleLimited2,
6203
+ prevDx2,
6204
+ prevDirection2,
6205
+ isNextLimited,
6206
+ dx
6207
+ );
6131
6208
  if (isLimited2)
6132
6209
  return prevDx2 > 0 ? "right" : "left";
6133
6210
  if (isDoubleLimited2 && prevDx2 < 0 && prevDirection2 === "left")
6134
6211
  return "left";
6212
+ if (isNextLimited)
6213
+ return dx > 0 ? "left" : "right";
6135
6214
  return "right";
6136
6215
  };
6137
6216
  let prevDirection = "right";
@@ -6140,7 +6219,15 @@ function createLabelDirections(props) {
6140
6219
  let prevDx = Infinity;
6141
6220
  for (let idx = 0; idx < len; idx++) {
6142
6221
  if (idx === len - 1) {
6143
- const direction2 = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6222
+ const isNextLimited2 = false;
6223
+ const direction2 = calcDirection(
6224
+ isLimited,
6225
+ isDoubleLimited,
6226
+ prevDx,
6227
+ prevDirection,
6228
+ isNextLimited2,
6229
+ 0
6230
+ );
6144
6231
  result.push(direction2);
6145
6232
  continue;
6146
6233
  }
@@ -6155,11 +6242,19 @@ function createLabelDirections(props) {
6155
6242
  continue;
6156
6243
  }
6157
6244
  const [dx, dy] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6158
- const direction = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6245
+ const isNextLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6246
+ const direction = calcDirection(
6247
+ isLimited,
6248
+ isDoubleLimited,
6249
+ prevDx,
6250
+ prevDirection,
6251
+ isNextLimited,
6252
+ dx
6253
+ );
6159
6254
  result.push(direction);
6160
6255
  prevDirection = direction;
6161
6256
  prevDx = dx;
6162
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6257
+ isLimited = isNextLimited;
6163
6258
  isDoubleLimited = dx > -widthLimit * 2 && dx < widthLimit * 2 && dy > -heightLimit && dy < heightLimit;
6164
6259
  }
6165
6260
  return result;
@@ -6170,7 +6265,7 @@ function filterNoOverlapPlaces(props) {
6170
6265
  const [dx, dy] = distanceFn(place2point(place1), place2point(place2));
6171
6266
  const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6172
6267
  spaceLog(
6173
- "usePointsLabelDirection",
6268
+ "filterNoOverlapPlaces",
6174
6269
  "p1, p2, dx, dy, isOverlap = ",
6175
6270
  place1.displayName,
6176
6271
  place2.displayName,
@@ -6432,10 +6527,11 @@ const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6432
6527
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6433
6528
  const RECOMMEND_PLACE_ICON_ZOOM_MIN = 16.25;
6434
6529
  const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.25;
6435
- const RECOMMEND_PLACE_ZONE_ICON_MIN = 15.25;
6530
+ const RECOMMEND_PLACE_ZONE_ICON_MIN = 12.75;
6436
6531
  const RECOMMEND_PLACE_ZONE_TEXT_MIN = 21;
6437
6532
  const DEFAULT_PLACE_NAME = "当前位置";
6438
6533
  const DEFAULT_ZOOM = 17;
6534
+ const ZONE_ZOOM = 13.75;
6439
6535
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
6440
6536
  emit,
6441
6537
  slots
@@ -6455,6 +6551,13 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6455
6551
  setMap,
6456
6552
  panTo
6457
6553
  } = useHeycarMap();
6554
+ const {
6555
+ zoomRef,
6556
+ setZoom
6557
+ } = useMapZoom({
6558
+ mapRef,
6559
+ defaultValue: DEFAULT_ZOOM
6560
+ });
6458
6561
  const {
6459
6562
  readyPromise
6460
6563
  } = useMapSupplier();
@@ -6493,6 +6596,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6493
6596
  centerPlace.name = place.name;
6494
6597
  centerPlace.displayName = place.displayName;
6495
6598
  setPlaceCandidatesAndZone(recommends);
6599
+ setZoom(ZONE_ZOOM);
6496
6600
  emit("changePlace", {
6497
6601
  ...place
6498
6602
  });
@@ -6504,6 +6608,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6504
6608
  centerPlace.lat = place.lat;
6505
6609
  centerPlace.name = place.name;
6506
6610
  centerPlace.displayName = place.displayName;
6611
+ if (zoneRef.value)
6612
+ setZoom(ZONE_ZOOM);
6507
6613
  emit("changePlace", {
6508
6614
  ...place
6509
6615
  });
@@ -6612,6 +6718,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6612
6718
  Object.assign(centerPlace, {
6613
6719
  ...place
6614
6720
  });
6721
+ if (isInZone)
6722
+ setZoom(ZONE_ZOOM);
6615
6723
  emit("changeRecomandPlace", {
6616
6724
  place,
6617
6725
  inputPlace,
@@ -6639,7 +6747,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6639
6747
  return Vue.h(HeycarMap, {
6640
6748
  "attrs": {
6641
6749
  "center": centerPoint.value,
6642
- "zoom": DEFAULT_ZOOM,
6750
+ "zoom": zoomRef.value,
6643
6751
  "touchZoomCenter": true,
6644
6752
  "mapRef": setMap,
6645
6753
  "fallback": slots.fallback,
@@ -6701,6 +6809,13 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6701
6809
  setMap,
6702
6810
  panTo
6703
6811
  } = useHeycarMap();
6812
+ const {
6813
+ zoomRef,
6814
+ setZoom
6815
+ } = useMapZoom({
6816
+ mapRef,
6817
+ defaultValue: DEFAULT_ZOOM
6818
+ });
6704
6819
  const centerPlace = Vue.reactive({
6705
6820
  lng: defaultPlace.lng,
6706
6821
  lat: defaultPlace.lat,
@@ -6735,6 +6850,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6735
6850
  centerPlace.lat = place.lat;
6736
6851
  centerPlace.name = place.name;
6737
6852
  centerPlace.displayName = place.displayName;
6853
+ setZoom(ZONE_ZOOM);
6738
6854
  setPlaceCandidatesAndZone(recommends);
6739
6855
  emit("changePlace", {
6740
6856
  ...place
@@ -6747,6 +6863,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6747
6863
  centerPlace.lat = place.lat;
6748
6864
  centerPlace.name = place.name;
6749
6865
  centerPlace.displayName = place.displayName;
6866
+ if (zoneRef.value)
6867
+ setZoom(ZONE_ZOOM);
6750
6868
  emit("changePlace", {
6751
6869
  ...place
6752
6870
  });
@@ -6834,6 +6952,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6834
6952
  Object.assign(centerPlace, {
6835
6953
  ...place
6836
6954
  });
6955
+ if (isInZone)
6956
+ setZoom(ZONE_ZOOM);
6837
6957
  emit("changeRecomandPlace", {
6838
6958
  place,
6839
6959
  inputPlace,
@@ -6864,7 +6984,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6864
6984
  return Vue.h(HeycarMap, {
6865
6985
  "attrs": {
6866
6986
  "center": centerPoint.value,
6867
- "zoom": DEFAULT_ZOOM,
6987
+ "zoom": zoomRef.value,
6868
6988
  "touchZoomCenter": true,
6869
6989
  "mapRef": setMap,
6870
6990
  "fallback": slots.fallback,
@@ -6883,8 +7003,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6883
7003
  "attrs": {
6884
7004
  "basePlace": centerPlace,
6885
7005
  "places": placeCandidates.value,
6886
- "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6887
- "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
7006
+ "zoomIconMin": zoneRef.value ? RECOMMEND_PLACE_ZONE_ICON_MIN : RECOMMEND_PLACE_ICON_ZOOM_MIN,
7007
+ "zoomTextMin": zoneRef.value ? RECOMMEND_PLACE_ZONE_TEXT_MIN : RECOMMEND_PLACE_TEXT_ZOOM_MIN
6888
7008
  },
6889
7009
  "on": {
6890
7010
  "click": panToCenterByPlace
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ var __publicField = (obj, key, value) => {
7
7
  import Vue, { defineComponent, h, computed, inject, provide, watch, onMounted, onUnmounted, watchPostEffect, shallowRef, ref, watchEffect, reactive, toRefs, toRef } from "vue";
8
8
  const style = "";
9
9
  const name = "@heycar/heycars-map";
10
- const version = "0.8.9";
10
+ const version = "0.9.0";
11
11
  const type = "module";
12
12
  const scripts = {
13
13
  dev: "vite -c vite.config.dev.ts",
@@ -3471,12 +3471,13 @@ const patchMiniprogramRedirectTo = (wx2) => {
3471
3471
  };
3472
3472
  return patchedRedirectTo;
3473
3473
  };
3474
- const DEVICE_ORIENTATION_INTERVAL = 1e3;
3474
+ const DEVICE_ORIENTATION_INTERVAL = 200;
3475
3475
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3476
3476
  const useDeviceOrientation = (props) => {
3477
3477
  const { onChange, elementRef } = props;
3478
3478
  const orientation = reactive({ cssRotationVariableName: void 0 });
3479
3479
  const cssVarName = `${CSS_DEVICE_ORIENTATION_VAR_PREFIX}${Date.now()}`;
3480
+ const toTransitionAngle = createToTransitionAngle();
3480
3481
  watch(
3481
3482
  () => elementRef.value,
3482
3483
  (element, _, onCleanup) => {
@@ -3486,7 +3487,7 @@ const useDeviceOrientation = (props) => {
3486
3487
  const alpha = webkitCompassHeading !== void 0 ? 360 - webkitCompassHeading : (_b = event.alpha) != null ? _b : void 0;
3487
3488
  const beta = (_c = event.beta) != null ? _c : void 0;
3488
3489
  const gamma = (_d = event.gamma) != null ? _d : void 0;
3489
- const cssRotationVariableValue = `${360 - (alpha != null ? alpha : 0)}deg`;
3490
+ const cssRotationVariableValue = `${toTransitionAngle(360 - (alpha != null ? alpha : 0))}deg`;
3490
3491
  const cssRotationVariableName = alpha === void 0 ? void 0 : cssVarName;
3491
3492
  Object.assign(orientation, { alpha, beta, gamma });
3492
3493
  if (orientation.cssRotationVariableName !== cssRotationVariableName) {
@@ -3558,6 +3559,32 @@ function waitMiniProgramWebviewClose(duration) {
3558
3559
  }, duration);
3559
3560
  });
3560
3561
  }
3562
+ function createToTransitionAngle() {
3563
+ let prev = void 0;
3564
+ const mod = (x, m) => {
3565
+ const negatabbleValue = x % m;
3566
+ return negatabbleValue < 0 ? m + negatabbleValue : negatabbleValue;
3567
+ };
3568
+ return function toTransitionAngle(angle) {
3569
+ if (prev === void 0) {
3570
+ prev = angle;
3571
+ console.log("toTransitionAngle angle = ", angle);
3572
+ return angle;
3573
+ }
3574
+ const prevRemainder = mod(prev, 360);
3575
+ const cycles = (prev - prevRemainder) / 360;
3576
+ if (Math.abs(angle - prevRemainder) <= 180) {
3577
+ const result = angle + cycles * 360;
3578
+ prev = result;
3579
+ return result;
3580
+ } else {
3581
+ const deltaCycles = angle > prevRemainder ? -1 : 1;
3582
+ const result = angle + (cycles + deltaCycles) * 360;
3583
+ prev = result;
3584
+ return result;
3585
+ }
3586
+ };
3587
+ }
3561
3588
  const watchVisibilityState = () => {
3562
3589
  const visibilityStateRef = ref(document.visibilityState);
3563
3590
  const handleVisibilityChange = () => {
@@ -3572,6 +3599,7 @@ const watchVisibilityState = () => {
3572
3599
  const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3573
3600
  const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3574
3601
  const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
3602
+ const ANDROID_GET_LOCATION_INTERVAL = 1 * 1e3;
3575
3603
  const takeIsForceBrowserGeo = () => {
3576
3604
  const searchParam = new URLSearchParams(location.search);
3577
3605
  return searchParam.has(`force-browser-geo`);
@@ -3580,14 +3608,6 @@ const wxReady = () => new Promise((resolve, reject) => {
3580
3608
  wx.ready(resolve);
3581
3609
  wx.error(reject);
3582
3610
  });
3583
- const detectPlatform = () => {
3584
- const useragent = navigator.userAgent.toLowerCase();
3585
- if (useragent.includes("micromessenger"))
3586
- return "wechat";
3587
- if (useragent.includes("alipay"))
3588
- return "alipay";
3589
- return "other";
3590
- };
3591
3611
  function wechatWatchPosition(onSuccess, onError, option) {
3592
3612
  const { timeout } = option;
3593
3613
  let enable = true;
@@ -3649,20 +3669,67 @@ function wechatWatchPosition(onSuccess, onError, option) {
3649
3669
  unwatchVisibilityState();
3650
3670
  };
3651
3671
  }
3672
+ function androidWatchPosition(onSuccess, onError, option) {
3673
+ let enable = true;
3674
+ let prevGeoPosition = void 0;
3675
+ const isGeoWorkingRef = ref(true);
3676
+ const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
3677
+ const startWatch = async () => {
3678
+ do {
3679
+ if (visibilityStateRef.value === "hidden") {
3680
+ await sleep(ANDROID_GET_LOCATION_INTERVAL);
3681
+ continue;
3682
+ }
3683
+ const geoPosition = await new Promise((resolve) => {
3684
+ navigator.geolocation.getCurrentPosition(
3685
+ function onSuccess2(geoLocationPosition) {
3686
+ isGeoWorkingRef.value = true;
3687
+ resolve(geoLocationPosition);
3688
+ },
3689
+ function onFail(geoError) {
3690
+ const isGeoWorking = isGeoWorkingRef.value;
3691
+ isGeoWorkingRef.value = false;
3692
+ resolve(void 0);
3693
+ if (!isGeoWorking)
3694
+ return;
3695
+ console.warn(
3696
+ "MyWarning: navigator.geolocation.getCurrentPosition failed: ",
3697
+ geoError.message
3698
+ );
3699
+ onError == null ? void 0 : onError(geoError);
3700
+ },
3701
+ option
3702
+ );
3703
+ });
3704
+ if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
3705
+ onSuccess(geoPosition);
3706
+ prevGeoPosition = geoPosition;
3707
+ await sleep(ANDROID_GET_LOCATION_INTERVAL);
3708
+ } while (enable);
3709
+ };
3710
+ startWatch();
3711
+ return () => {
3712
+ enable = false;
3713
+ unwatchVisibilityState();
3714
+ };
3715
+ }
3652
3716
  function compatibleWathPosition(onSuccess, onError, option) {
3653
3717
  const isForceBrowserGeo = takeIsForceBrowserGeo();
3654
3718
  if (isForceBrowserGeo) {
3655
- const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3656
- return () => navigator.geolocation.clearWatch(watchId);
3719
+ const watchId2 = navigator.geolocation.watchPosition(onSuccess, onError, option);
3720
+ return () => navigator.geolocation.clearWatch(watchId2);
3657
3721
  }
3658
- switch (detectPlatform()) {
3659
- case "wechat":
3660
- return wechatWatchPosition(onSuccess, onError, option);
3661
- default: {
3662
- const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3663
- return () => navigator.geolocation.clearWatch(watchId);
3664
- }
3722
+ const browserPlatform = detectBrowserPlatform();
3723
+ const osPlatform = detectOSPlatform();
3724
+ console.log("osPlatform = ", osPlatform);
3725
+ if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
3726
+ return wechatWatchPosition(onSuccess, onError, option);
3665
3727
  }
3728
+ if (osPlatform === OS_PLATFORM.ANDROID) {
3729
+ return androidWatchPosition(onSuccess, onError, option);
3730
+ }
3731
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3732
+ return () => navigator.geolocation.clearWatch(watchId);
3666
3733
  }
3667
3734
  class SingleGeoWatch {
3668
3735
  constructor(option) {
@@ -5756,6 +5823,69 @@ const useMapRecomendPlace = (props) => {
5756
5823
  const { supplier } = useMapSupplier();
5757
5824
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5758
5825
  };
5826
+ const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5827
+ const DEFAULT_ZOOM$1 = 13;
5828
+ const useAmapZoom = (props) => {
5829
+ var _a, _b, _c;
5830
+ const { onChange, mapRef, defaultValue } = props;
5831
+ const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5832
+ const setZoom = (v) => {
5833
+ var _a2;
5834
+ zoomRef.value = v;
5835
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5836
+ };
5837
+ const handleZoomEnd = (_, { target }) => {
5838
+ const zoom = target.getZoom();
5839
+ zoomRef.value = zoom;
5840
+ onChange == null ? void 0 : onChange(zoom);
5841
+ };
5842
+ watch(
5843
+ () => mapRef.value,
5844
+ (map) => {
5845
+ if (!map)
5846
+ return;
5847
+ zoomRef.value = map.getZoom();
5848
+ }
5849
+ );
5850
+ watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5851
+ "onZoomEnd"
5852
+ ]);
5853
+ return { zoomRef, setZoom };
5854
+ };
5855
+ const useGmapZoom = (props) => {
5856
+ var _a, _b, _c;
5857
+ const { onChange, mapRef, defaultValue } = props;
5858
+ const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5859
+ const setZoom = (v) => {
5860
+ var _a2;
5861
+ zoomRef.value = v;
5862
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5863
+ };
5864
+ const handleZoomChange = debounce(
5865
+ (_, { target }) => {
5866
+ const zoom = target.getZoom();
5867
+ zoomRef.value = zoom;
5868
+ onChange == null ? void 0 : onChange(zoom);
5869
+ },
5870
+ GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5871
+ );
5872
+ watch(
5873
+ () => mapRef.value,
5874
+ (map) => {
5875
+ if (!map)
5876
+ return;
5877
+ zoomRef.value = map.getZoom();
5878
+ }
5879
+ );
5880
+ watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5881
+ "onZoom_changed"
5882
+ ]);
5883
+ return { zoomRef, setZoom };
5884
+ };
5885
+ const useMapZoom = (props) => {
5886
+ const { supplier } = useMapSupplier();
5887
+ return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
5888
+ };
5759
5889
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5760
5890
  const polygonRef = shallowRef();
5761
5891
  const mapRef = useAmap();
@@ -6018,69 +6148,6 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6018
6148
  })]);
6019
6149
  };
6020
6150
  });
6021
- const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
6022
- const DEFAULT_ZOOM$1 = 13;
6023
- const useAmapZoom = (props) => {
6024
- var _a, _b, _c;
6025
- const { onChange, mapRef, defaultValue } = props;
6026
- const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
6027
- const setZoom = (v) => {
6028
- var _a2;
6029
- zoomRef.value = v;
6030
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
6031
- };
6032
- const handleZoomEnd = (_, { target }) => {
6033
- const zoom = target.getZoom();
6034
- zoomRef.value = zoom;
6035
- onChange == null ? void 0 : onChange(zoom);
6036
- };
6037
- watch(
6038
- () => mapRef.value,
6039
- (map) => {
6040
- if (!map)
6041
- return;
6042
- zoomRef.value = map.getZoom();
6043
- }
6044
- );
6045
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
6046
- "onZoomEnd"
6047
- ]);
6048
- return { zoomRef, setZoom };
6049
- };
6050
- const useGmapZoom = (props) => {
6051
- var _a, _b, _c;
6052
- const { onChange, mapRef, defaultValue } = props;
6053
- const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
6054
- const setZoom = (v) => {
6055
- var _a2;
6056
- zoomRef.value = v;
6057
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
6058
- };
6059
- const handleZoomChange = debounce(
6060
- (_, { target }) => {
6061
- const zoom = target.getZoom();
6062
- zoomRef.value = zoom;
6063
- onChange == null ? void 0 : onChange(zoom);
6064
- },
6065
- GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
6066
- );
6067
- watch(
6068
- () => mapRef.value,
6069
- (map) => {
6070
- if (!map)
6071
- return;
6072
- zoomRef.value = map.getZoom();
6073
- }
6074
- );
6075
- watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
6076
- "onZoom_changed"
6077
- ]);
6078
- return { zoomRef, setZoom };
6079
- };
6080
- const useMapZoom = (props) => {
6081
- const { supplier } = useMapSupplier();
6082
- return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
6083
- };
6084
6151
  const usePointsLabelDirection = (props) => {
6085
6152
  const { widthLimit, heightLimit } = props;
6086
6153
  const mapRef = useMap();
@@ -6125,11 +6192,23 @@ function createLabelDirections(props) {
6125
6192
  const { sortedPoints, widthLimit, heightLimit, distanceFn } = props;
6126
6193
  const len = sortedPoints.length;
6127
6194
  const result = [];
6128
- const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2) => {
6195
+ const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2, isNextLimited, dx) => {
6196
+ spaceLog(
6197
+ "calcDirection",
6198
+ "isLimited, isDoubleLimited, prevDx, prevDirection, isNextLimited, dx = ",
6199
+ isLimited2,
6200
+ isDoubleLimited2,
6201
+ prevDx2,
6202
+ prevDirection2,
6203
+ isNextLimited,
6204
+ dx
6205
+ );
6129
6206
  if (isLimited2)
6130
6207
  return prevDx2 > 0 ? "right" : "left";
6131
6208
  if (isDoubleLimited2 && prevDx2 < 0 && prevDirection2 === "left")
6132
6209
  return "left";
6210
+ if (isNextLimited)
6211
+ return dx > 0 ? "left" : "right";
6133
6212
  return "right";
6134
6213
  };
6135
6214
  let prevDirection = "right";
@@ -6138,7 +6217,15 @@ function createLabelDirections(props) {
6138
6217
  let prevDx = Infinity;
6139
6218
  for (let idx = 0; idx < len; idx++) {
6140
6219
  if (idx === len - 1) {
6141
- const direction2 = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6220
+ const isNextLimited2 = false;
6221
+ const direction2 = calcDirection(
6222
+ isLimited,
6223
+ isDoubleLimited,
6224
+ prevDx,
6225
+ prevDirection,
6226
+ isNextLimited2,
6227
+ 0
6228
+ );
6142
6229
  result.push(direction2);
6143
6230
  continue;
6144
6231
  }
@@ -6153,11 +6240,19 @@ function createLabelDirections(props) {
6153
6240
  continue;
6154
6241
  }
6155
6242
  const [dx, dy] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6156
- const direction = calcDirection(isLimited, isDoubleLimited, prevDx, prevDirection);
6243
+ const isNextLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6244
+ const direction = calcDirection(
6245
+ isLimited,
6246
+ isDoubleLimited,
6247
+ prevDx,
6248
+ prevDirection,
6249
+ isNextLimited,
6250
+ dx
6251
+ );
6157
6252
  result.push(direction);
6158
6253
  prevDirection = direction;
6159
6254
  prevDx = dx;
6160
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6255
+ isLimited = isNextLimited;
6161
6256
  isDoubleLimited = dx > -widthLimit * 2 && dx < widthLimit * 2 && dy > -heightLimit && dy < heightLimit;
6162
6257
  }
6163
6258
  return result;
@@ -6168,7 +6263,7 @@ function filterNoOverlapPlaces(props) {
6168
6263
  const [dx, dy] = distanceFn(place2point(place1), place2point(place2));
6169
6264
  const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6170
6265
  spaceLog(
6171
- "usePointsLabelDirection",
6266
+ "filterNoOverlapPlaces",
6172
6267
  "p1, p2, dx, dy, isOverlap = ",
6173
6268
  place1.displayName,
6174
6269
  place2.displayName,
@@ -6430,10 +6525,11 @@ const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6430
6525
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6431
6526
  const RECOMMEND_PLACE_ICON_ZOOM_MIN = 16.25;
6432
6527
  const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.25;
6433
- const RECOMMEND_PLACE_ZONE_ICON_MIN = 15.25;
6528
+ const RECOMMEND_PLACE_ZONE_ICON_MIN = 12.75;
6434
6529
  const RECOMMEND_PLACE_ZONE_TEXT_MIN = 21;
6435
6530
  const DEFAULT_PLACE_NAME = "当前位置";
6436
6531
  const DEFAULT_ZOOM = 17;
6532
+ const ZONE_ZOOM = 13.75;
6437
6533
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
6438
6534
  emit,
6439
6535
  slots
@@ -6453,6 +6549,13 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6453
6549
  setMap,
6454
6550
  panTo
6455
6551
  } = useHeycarMap();
6552
+ const {
6553
+ zoomRef,
6554
+ setZoom
6555
+ } = useMapZoom({
6556
+ mapRef,
6557
+ defaultValue: DEFAULT_ZOOM
6558
+ });
6456
6559
  const {
6457
6560
  readyPromise
6458
6561
  } = useMapSupplier();
@@ -6491,6 +6594,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6491
6594
  centerPlace.name = place.name;
6492
6595
  centerPlace.displayName = place.displayName;
6493
6596
  setPlaceCandidatesAndZone(recommends);
6597
+ setZoom(ZONE_ZOOM);
6494
6598
  emit("changePlace", {
6495
6599
  ...place
6496
6600
  });
@@ -6502,6 +6606,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6502
6606
  centerPlace.lat = place.lat;
6503
6607
  centerPlace.name = place.name;
6504
6608
  centerPlace.displayName = place.displayName;
6609
+ if (zoneRef.value)
6610
+ setZoom(ZONE_ZOOM);
6505
6611
  emit("changePlace", {
6506
6612
  ...place
6507
6613
  });
@@ -6610,6 +6716,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6610
6716
  Object.assign(centerPlace, {
6611
6717
  ...place
6612
6718
  });
6719
+ if (isInZone)
6720
+ setZoom(ZONE_ZOOM);
6613
6721
  emit("changeRecomandPlace", {
6614
6722
  place,
6615
6723
  inputPlace,
@@ -6637,7 +6745,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6637
6745
  return h(HeycarMap, {
6638
6746
  "attrs": {
6639
6747
  "center": centerPoint.value,
6640
- "zoom": DEFAULT_ZOOM,
6748
+ "zoom": zoomRef.value,
6641
6749
  "touchZoomCenter": true,
6642
6750
  "mapRef": setMap,
6643
6751
  "fallback": slots.fallback,
@@ -6699,6 +6807,13 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6699
6807
  setMap,
6700
6808
  panTo
6701
6809
  } = useHeycarMap();
6810
+ const {
6811
+ zoomRef,
6812
+ setZoom
6813
+ } = useMapZoom({
6814
+ mapRef,
6815
+ defaultValue: DEFAULT_ZOOM
6816
+ });
6702
6817
  const centerPlace = reactive({
6703
6818
  lng: defaultPlace.lng,
6704
6819
  lat: defaultPlace.lat,
@@ -6733,6 +6848,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6733
6848
  centerPlace.lat = place.lat;
6734
6849
  centerPlace.name = place.name;
6735
6850
  centerPlace.displayName = place.displayName;
6851
+ setZoom(ZONE_ZOOM);
6736
6852
  setPlaceCandidatesAndZone(recommends);
6737
6853
  emit("changePlace", {
6738
6854
  ...place
@@ -6745,6 +6861,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6745
6861
  centerPlace.lat = place.lat;
6746
6862
  centerPlace.name = place.name;
6747
6863
  centerPlace.displayName = place.displayName;
6864
+ if (zoneRef.value)
6865
+ setZoom(ZONE_ZOOM);
6748
6866
  emit("changePlace", {
6749
6867
  ...place
6750
6868
  });
@@ -6832,6 +6950,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6832
6950
  Object.assign(centerPlace, {
6833
6951
  ...place
6834
6952
  });
6953
+ if (isInZone)
6954
+ setZoom(ZONE_ZOOM);
6835
6955
  emit("changeRecomandPlace", {
6836
6956
  place,
6837
6957
  inputPlace,
@@ -6862,7 +6982,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6862
6982
  return h(HeycarMap, {
6863
6983
  "attrs": {
6864
6984
  "center": centerPoint.value,
6865
- "zoom": DEFAULT_ZOOM,
6985
+ "zoom": zoomRef.value,
6866
6986
  "touchZoomCenter": true,
6867
6987
  "mapRef": setMap,
6868
6988
  "fallback": slots.fallback,
@@ -6881,8 +7001,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6881
7001
  "attrs": {
6882
7002
  "basePlace": centerPlace,
6883
7003
  "places": placeCandidates.value,
6884
- "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6885
- "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
7004
+ "zoomIconMin": zoneRef.value ? RECOMMEND_PLACE_ZONE_ICON_MIN : RECOMMEND_PLACE_ICON_ZOOM_MIN,
7005
+ "zoomTextMin": zoneRef.value ? RECOMMEND_PLACE_ZONE_TEXT_MIN : RECOMMEND_PLACE_TEXT_ZOOM_MIN
6886
7006
  },
6887
7007
  "on": {
6888
7008
  "click": panToCenterByPlace
@@ -10,10 +10,11 @@ export declare const RECOMMEND_PLACE_DRAG_LIMIT = 10;
10
10
  export declare const RECOMMEND_PLACE_LARGE_LIMIT = 100;
11
11
  export declare const RECOMMEND_PLACE_ICON_ZOOM_MIN = 16.25;
12
12
  export declare const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.25;
13
- export declare const RECOMMEND_PLACE_ZONE_ICON_MIN = 15.25;
13
+ export declare const RECOMMEND_PLACE_ZONE_ICON_MIN = 12.75;
14
14
  export declare const RECOMMEND_PLACE_ZONE_TEXT_MIN = 21;
15
15
  export declare const DEFAULT_PLACE_NAME = "\u5F53\u524D\u4F4D\u7F6E";
16
16
  export declare const DEFAULT_ZOOM = 17;
17
+ export declare const ZONE_ZOOM = 13.75;
17
18
  export interface CenterPlaceSource {
18
19
  source: "default" | "geo" | "drag" | "recomend" | "api";
19
20
  }
package/dist/style.css CHANGED
@@ -216,6 +216,7 @@ a[title*="Google"]>div>img[alt="Google"], .gmnoprint {
216
216
  display: none;
217
217
  }._1l6offo0 {
218
218
  display: flex;
219
+ transition: transform .2s;
219
220
  }
220
221
  ._1l6offo1 {
221
222
  width: 6.6vw;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.8.9",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",