@heycar/heycars-map 0.8.10 → 0.9.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.
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.10";
12
+ const version = "0.9.1";
13
13
  const type = "module";
14
14
  const scripts = {
15
15
  dev: "vite -c vite.config.dev.ts",
@@ -1113,6 +1113,48 @@ const assertAngle = (angle) => {
1113
1113
  const isLatLngLiteral = (value) => {
1114
1114
  return value != null && typeof value === "object" && Number.isFinite(value.lat) && Number.isFinite(value.lng);
1115
1115
  };
1116
+ function defered() {
1117
+ const defer = {};
1118
+ const promise = new Promise((resolve, reject) => {
1119
+ defer.state = "pending";
1120
+ defer.resolve = async (value) => {
1121
+ try {
1122
+ const result = await value;
1123
+ defer.state = "fulfilled";
1124
+ return resolve(result);
1125
+ } catch (err) {
1126
+ defer.state = "rejected";
1127
+ reject(err);
1128
+ }
1129
+ };
1130
+ defer.reject = (reason) => {
1131
+ defer.state = "rejected";
1132
+ return reject(reason);
1133
+ };
1134
+ });
1135
+ return Object.assign(promise, defer);
1136
+ }
1137
+ const pausableSleep = (milliSeconds) => {
1138
+ const sleepDefered = defered();
1139
+ let id = setTimeout(sleepDefered.resolve, milliSeconds);
1140
+ let isPaused = false;
1141
+ const pause = () => {
1142
+ if (isPaused || sleepDefered.state === "fulfilled")
1143
+ return;
1144
+ console.log("pause");
1145
+ isPaused = true;
1146
+ clearTimeout(id);
1147
+ };
1148
+ const restart = () => {
1149
+ if (sleepDefered.state === "fulfilled")
1150
+ return;
1151
+ console.log("restart");
1152
+ isPaused = false;
1153
+ clearTimeout(id);
1154
+ id = setTimeout(sleepDefered.resolve, milliSeconds);
1155
+ };
1156
+ return { sleepPromise: sleepDefered, pause, restart };
1157
+ };
1116
1158
  const vec2lnglat = ([lng, lat]) => ({
1117
1159
  lng: Number(lng),
1118
1160
  lat: Number(lat)
@@ -3147,6 +3189,36 @@ const useMapFitView = (props) => {
3147
3189
  const { supplier } = useMapSupplier();
3148
3190
  return supplier === "gmap" ? useGmapFitView(props) : useAmapFitView(props);
3149
3191
  };
3192
+ const useAmapTouchEvent = () => {
3193
+ const mapRef = useAmap();
3194
+ const addMapEventListener = (name2, handler) => {
3195
+ var _a;
3196
+ return (_a = mapRef == null ? void 0 : mapRef.value) == null ? void 0 : _a.on(name2, handler);
3197
+ };
3198
+ const removeMapEventListener = (name2, handler) => {
3199
+ var _a;
3200
+ return (_a = mapRef == null ? void 0 : mapRef.value) == null ? void 0 : _a.off(name2, handler);
3201
+ };
3202
+ return { addMapEventListener, removeMapEventListener };
3203
+ };
3204
+ const useGmapTouchEvent = () => {
3205
+ const mapRef = useGmap();
3206
+ const addMapEventListener = (name2, handler) => {
3207
+ var _a;
3208
+ const container = (_a = mapRef == null ? void 0 : mapRef.value) == null ? void 0 : _a.getDiv();
3209
+ return container == null ? void 0 : container.addEventListener(name2, handler);
3210
+ };
3211
+ const removeMapEventListener = (name2, handler) => {
3212
+ var _a;
3213
+ const container = (_a = mapRef == null ? void 0 : mapRef.value) == null ? void 0 : _a.getDiv();
3214
+ return container == null ? void 0 : container.removeEventListener(name2, handler);
3215
+ };
3216
+ return { addMapEventListener, removeMapEventListener };
3217
+ };
3218
+ const useMapTouchEvent = () => {
3219
+ const { supplier } = useMapSupplier();
3220
+ return supplier === "gmap" ? useGmapTouchEvent() : useAmapTouchEvent();
3221
+ };
3150
3222
  defineSetup(function FitView(props, {
3151
3223
  slots
3152
3224
  }) {
@@ -3199,7 +3271,7 @@ function createFittableRegisterOverlay(registerOverlay) {
3199
3271
  setFitView
3200
3272
  };
3201
3273
  }
3202
- const KeyedFitView = defineSetup(function KeyedFitView2(props, {
3274
+ defineSetup(function KeyedFitView(props, {
3203
3275
  slots
3204
3276
  }) {
3205
3277
  const mapMountedPromise = useMapMountedPromise();
@@ -3220,6 +3292,48 @@ const KeyedFitView = defineSetup(function KeyedFitView2(props, {
3220
3292
  return Vue.h("div", [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
3221
3293
  };
3222
3294
  });
3295
+ const InterruptableIntervalFitView = defineSetup(function InterruptableIntervalFitView2(props) {
3296
+ const {
3297
+ registerOverlay
3298
+ } = props;
3299
+ const mapMountedPromise = useMapMountedPromise();
3300
+ const {
3301
+ addMapEventListener,
3302
+ removeMapEventListener
3303
+ } = useMapTouchEvent();
3304
+ Vue.watch(() => 0, async (_1, _2, onCleanup) => {
3305
+ await mapMountedPromise;
3306
+ let skip = false;
3307
+ let pause;
3308
+ let restart;
3309
+ let sleepPromise;
3310
+ const handleTouchStartOrMove = () => pause();
3311
+ const handleTouchEnd = () => restart();
3312
+ addMapEventListener("touchstart", handleTouchStartOrMove);
3313
+ addMapEventListener("touchmove", handleTouchStartOrMove);
3314
+ addMapEventListener("touchend", handleTouchEnd);
3315
+ onCleanup(() => {
3316
+ skip = true;
3317
+ removeEventListener("touchstart", handleTouchStartOrMove);
3318
+ removeMapEventListener("touchmove", handleTouchStartOrMove);
3319
+ removeMapEventListener("touchend", handleTouchEnd);
3320
+ });
3321
+ while (!skip) {
3322
+ ({
3323
+ pause,
3324
+ restart,
3325
+ sleepPromise
3326
+ } = pausableSleep(props.interval));
3327
+ await sleepPromise;
3328
+ console.log("InterruptableIntervalFitView setFitView");
3329
+ registerOverlay.setFitView();
3330
+ }
3331
+ }, {
3332
+ immediate: true,
3333
+ flush: "post"
3334
+ });
3335
+ return () => null;
3336
+ });
3223
3337
  const imgEndPoint = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IHgxPSI3Mi4zMzklIiB5MT0iNTAlIiB4Mj0iMCUiIHkyPSI1MCUiIG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W5nU0MtU2VtaWJvbGQsIFBpbmdGYW5nIFNDIiBmb250LXNpemU9IjEyIiBmb250LXdlaWdodD0iNTAwIiBmaWxsPSIjRkZGIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgxIDEuMjE1KSI+PHRzcGFuIHg9IjUiIHk9IjE1LjYyNCI+6LW3PC90c3Bhbj48L3RleHQ+PC9nPjwvc3ZnPg==";
3225
3339
  const StartEndPoint_css_ts_vanilla = "";
@@ -3473,12 +3587,13 @@ const patchMiniprogramRedirectTo = (wx2) => {
3473
3587
  };
3474
3588
  return patchedRedirectTo;
3475
3589
  };
3476
- const DEVICE_ORIENTATION_INTERVAL = 1e3;
3590
+ const DEVICE_ORIENTATION_INTERVAL = 200;
3477
3591
  const CSS_DEVICE_ORIENTATION_VAR_PREFIX = "--CSS_DEVICE_ORIENTATION_VAR_ROTATION_DEGREE_";
3478
3592
  const useDeviceOrientation = (props) => {
3479
3593
  const { onChange, elementRef } = props;
3480
3594
  const orientation = Vue.reactive({ cssRotationVariableName: void 0 });
3481
3595
  const cssVarName = `${CSS_DEVICE_ORIENTATION_VAR_PREFIX}${Date.now()}`;
3596
+ const toTransitionAngle = createToTransitionAngle();
3482
3597
  Vue.watch(
3483
3598
  () => elementRef.value,
3484
3599
  (element, _, onCleanup) => {
@@ -3488,7 +3603,7 @@ const useDeviceOrientation = (props) => {
3488
3603
  const alpha = webkitCompassHeading !== void 0 ? 360 - webkitCompassHeading : (_b = event.alpha) != null ? _b : void 0;
3489
3604
  const beta = (_c = event.beta) != null ? _c : void 0;
3490
3605
  const gamma = (_d = event.gamma) != null ? _d : void 0;
3491
- const cssRotationVariableValue = `${360 - (alpha != null ? alpha : 0)}deg`;
3606
+ const cssRotationVariableValue = `${toTransitionAngle(360 - (alpha != null ? alpha : 0))}deg`;
3492
3607
  const cssRotationVariableName = alpha === void 0 ? void 0 : cssVarName;
3493
3608
  Object.assign(orientation, { alpha, beta, gamma });
3494
3609
  if (orientation.cssRotationVariableName !== cssRotationVariableName) {
@@ -3560,6 +3675,32 @@ function waitMiniProgramWebviewClose(duration) {
3560
3675
  }, duration);
3561
3676
  });
3562
3677
  }
3678
+ function createToTransitionAngle() {
3679
+ let prev = void 0;
3680
+ const mod = (x, m) => {
3681
+ const negatabbleValue = x % m;
3682
+ return negatabbleValue < 0 ? m + negatabbleValue : negatabbleValue;
3683
+ };
3684
+ return function toTransitionAngle(angle) {
3685
+ if (prev === void 0) {
3686
+ prev = angle;
3687
+ console.log("toTransitionAngle angle = ", angle);
3688
+ return angle;
3689
+ }
3690
+ const prevRemainder = mod(prev, 360);
3691
+ const cycles = (prev - prevRemainder) / 360;
3692
+ if (Math.abs(angle - prevRemainder) <= 180) {
3693
+ const result = angle + cycles * 360;
3694
+ prev = result;
3695
+ return result;
3696
+ } else {
3697
+ const deltaCycles = angle > prevRemainder ? -1 : 1;
3698
+ const result = angle + (cycles + deltaCycles) * 360;
3699
+ prev = result;
3700
+ return result;
3701
+ }
3702
+ };
3703
+ }
3563
3704
  const watchVisibilityState = () => {
3564
3705
  const visibilityStateRef = Vue.ref(document.visibilityState);
3565
3706
  const handleVisibilityChange = () => {
@@ -3574,6 +3715,7 @@ const watchVisibilityState = () => {
3574
3715
  const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3575
3716
  const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3576
3717
  const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
3718
+ const ANDROID_GET_LOCATION_INTERVAL = 1 * 1e3;
3577
3719
  const takeIsForceBrowserGeo = () => {
3578
3720
  const searchParam = new URLSearchParams(location.search);
3579
3721
  return searchParam.has(`force-browser-geo`);
@@ -3582,14 +3724,6 @@ const wxReady = () => new Promise((resolve, reject) => {
3582
3724
  wx.ready(resolve);
3583
3725
  wx.error(reject);
3584
3726
  });
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
3727
  function wechatWatchPosition(onSuccess, onError, option) {
3594
3728
  const { timeout } = option;
3595
3729
  let enable = true;
@@ -3651,20 +3785,67 @@ function wechatWatchPosition(onSuccess, onError, option) {
3651
3785
  unwatchVisibilityState();
3652
3786
  };
3653
3787
  }
3788
+ function androidWatchPosition(onSuccess, onError, option) {
3789
+ let enable = true;
3790
+ let prevGeoPosition = void 0;
3791
+ const isGeoWorkingRef = Vue.ref(true);
3792
+ const { visibilityStateRef, unwatchVisibilityState } = watchVisibilityState();
3793
+ const startWatch = async () => {
3794
+ do {
3795
+ if (visibilityStateRef.value === "hidden") {
3796
+ await sleep(ANDROID_GET_LOCATION_INTERVAL);
3797
+ continue;
3798
+ }
3799
+ const geoPosition = await new Promise((resolve) => {
3800
+ navigator.geolocation.getCurrentPosition(
3801
+ function onSuccess2(geoLocationPosition) {
3802
+ isGeoWorkingRef.value = true;
3803
+ resolve(geoLocationPosition);
3804
+ },
3805
+ function onFail(geoError) {
3806
+ const isGeoWorking = isGeoWorkingRef.value;
3807
+ isGeoWorkingRef.value = false;
3808
+ resolve(void 0);
3809
+ if (!isGeoWorking)
3810
+ return;
3811
+ console.warn(
3812
+ "MyWarning: navigator.geolocation.getCurrentPosition failed: ",
3813
+ geoError.message
3814
+ );
3815
+ onError == null ? void 0 : onError(geoError);
3816
+ },
3817
+ option
3818
+ );
3819
+ });
3820
+ if (geoPosition && !isGeoPositionEqual(geoPosition, prevGeoPosition))
3821
+ onSuccess(geoPosition);
3822
+ prevGeoPosition = geoPosition;
3823
+ await sleep(ANDROID_GET_LOCATION_INTERVAL);
3824
+ } while (enable);
3825
+ };
3826
+ startWatch();
3827
+ return () => {
3828
+ enable = false;
3829
+ unwatchVisibilityState();
3830
+ };
3831
+ }
3654
3832
  function compatibleWathPosition(onSuccess, onError, option) {
3655
3833
  const isForceBrowserGeo = takeIsForceBrowserGeo();
3656
3834
  if (isForceBrowserGeo) {
3657
- const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3658
- return () => navigator.geolocation.clearWatch(watchId);
3835
+ const watchId2 = navigator.geolocation.watchPosition(onSuccess, onError, option);
3836
+ return () => navigator.geolocation.clearWatch(watchId2);
3659
3837
  }
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
- }
3838
+ const browserPlatform = detectBrowserPlatform();
3839
+ const osPlatform = detectOSPlatform();
3840
+ console.log("osPlatform = ", osPlatform);
3841
+ if (browserPlatform === BRWOSER_PLATFORM.WECHAT || browserPlatform === BRWOSER_PLATFORM.WECHAT_MINIPROGRAM) {
3842
+ return wechatWatchPosition(onSuccess, onError, option);
3843
+ }
3844
+ if (osPlatform === OS_PLATFORM.ANDROID) {
3845
+ return androidWatchPosition(onSuccess, onError, option);
3667
3846
  }
3847
+ const watchId = navigator.geolocation.watchPosition(onSuccess, onError, option);
3848
+ return () => navigator.geolocation.clearWatch(watchId);
3668
3849
  }
3669
3850
  class SingleGeoWatch {
3670
3851
  constructor(option) {
@@ -5758,6 +5939,69 @@ const useMapRecomendPlace = (props) => {
5758
5939
  const { supplier } = useMapSupplier();
5759
5940
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5760
5941
  };
5942
+ const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5943
+ const DEFAULT_ZOOM$1 = 13;
5944
+ const useAmapZoom = (props) => {
5945
+ var _a, _b, _c;
5946
+ const { onChange, mapRef, defaultValue } = props;
5947
+ const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5948
+ const setZoom = (v) => {
5949
+ var _a2;
5950
+ zoomRef.value = v;
5951
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5952
+ };
5953
+ const handleZoomEnd = (_, { target }) => {
5954
+ const zoom = target.getZoom();
5955
+ zoomRef.value = zoom;
5956
+ onChange == null ? void 0 : onChange(zoom);
5957
+ };
5958
+ Vue.watch(
5959
+ () => mapRef.value,
5960
+ (map) => {
5961
+ if (!map)
5962
+ return;
5963
+ zoomRef.value = map.getZoom();
5964
+ }
5965
+ );
5966
+ watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5967
+ "onZoomEnd"
5968
+ ]);
5969
+ return { zoomRef, setZoom };
5970
+ };
5971
+ const useGmapZoom = (props) => {
5972
+ var _a, _b, _c;
5973
+ const { onChange, mapRef, defaultValue } = props;
5974
+ const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5975
+ const setZoom = (v) => {
5976
+ var _a2;
5977
+ zoomRef.value = v;
5978
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5979
+ };
5980
+ const handleZoomChange = debounce(
5981
+ (_, { target }) => {
5982
+ const zoom = target.getZoom();
5983
+ zoomRef.value = zoom;
5984
+ onChange == null ? void 0 : onChange(zoom);
5985
+ },
5986
+ GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5987
+ );
5988
+ Vue.watch(
5989
+ () => mapRef.value,
5990
+ (map) => {
5991
+ if (!map)
5992
+ return;
5993
+ zoomRef.value = map.getZoom();
5994
+ }
5995
+ );
5996
+ watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5997
+ "onZoom_changed"
5998
+ ]);
5999
+ return { zoomRef, setZoom };
6000
+ };
6001
+ const useMapZoom = (props) => {
6002
+ const { supplier } = useMapSupplier();
6003
+ return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
6004
+ };
5761
6005
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5762
6006
  const polygonRef = Vue.shallowRef();
5763
6007
  const mapRef = useAmap();
@@ -6012,77 +6256,13 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6012
6256
  "size": "small",
6013
6257
  "registerOverlay": registerOverlay
6014
6258
  }
6015
- }), Vue.h(KeyedFitView, {
6259
+ }), Vue.h(FitViewOnce, {
6016
6260
  "attrs": {
6017
- "registerOverlay": registerOverlay,
6018
- "fitViewKey": JSON.stringify(position)
6261
+ "registerOverlay": registerOverlay
6019
6262
  }
6020
6263
  })]);
6021
6264
  };
6022
6265
  });
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
6266
  const usePointsLabelDirection = (props) => {
6087
6267
  const { widthLimit, heightLimit } = props;
6088
6268
  const mapRef = useMap();
@@ -6460,10 +6640,11 @@ const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6460
6640
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6461
6641
  const RECOMMEND_PLACE_ICON_ZOOM_MIN = 16.25;
6462
6642
  const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.25;
6463
- const RECOMMEND_PLACE_ZONE_ICON_MIN = 15.25;
6643
+ const RECOMMEND_PLACE_ZONE_ICON_MIN = 12.75;
6464
6644
  const RECOMMEND_PLACE_ZONE_TEXT_MIN = 21;
6465
6645
  const DEFAULT_PLACE_NAME = "当前位置";
6466
6646
  const DEFAULT_ZOOM = 17;
6647
+ const ZONE_ZOOM = 13.75;
6467
6648
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
6468
6649
  emit,
6469
6650
  slots
@@ -6483,6 +6664,13 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6483
6664
  setMap,
6484
6665
  panTo
6485
6666
  } = useHeycarMap();
6667
+ const {
6668
+ zoomRef,
6669
+ setZoom
6670
+ } = useMapZoom({
6671
+ mapRef,
6672
+ defaultValue: DEFAULT_ZOOM
6673
+ });
6486
6674
  const {
6487
6675
  readyPromise
6488
6676
  } = useMapSupplier();
@@ -6521,6 +6709,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6521
6709
  centerPlace.name = place.name;
6522
6710
  centerPlace.displayName = place.displayName;
6523
6711
  setPlaceCandidatesAndZone(recommends);
6712
+ setZoom(ZONE_ZOOM);
6524
6713
  emit("changePlace", {
6525
6714
  ...place
6526
6715
  });
@@ -6532,6 +6721,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6532
6721
  centerPlace.lat = place.lat;
6533
6722
  centerPlace.name = place.name;
6534
6723
  centerPlace.displayName = place.displayName;
6724
+ if (zoneRef.value)
6725
+ setZoom(ZONE_ZOOM);
6535
6726
  emit("changePlace", {
6536
6727
  ...place
6537
6728
  });
@@ -6640,6 +6831,8 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6640
6831
  Object.assign(centerPlace, {
6641
6832
  ...place
6642
6833
  });
6834
+ if (isInZone)
6835
+ setZoom(ZONE_ZOOM);
6643
6836
  emit("changeRecomandPlace", {
6644
6837
  place,
6645
6838
  inputPlace,
@@ -6667,7 +6860,7 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6667
6860
  return Vue.h(HeycarMap, {
6668
6861
  "attrs": {
6669
6862
  "center": centerPoint.value,
6670
- "zoom": DEFAULT_ZOOM,
6863
+ "zoom": zoomRef.value,
6671
6864
  "touchZoomCenter": true,
6672
6865
  "mapRef": setMap,
6673
6866
  "fallback": slots.fallback,
@@ -6729,6 +6922,13 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6729
6922
  setMap,
6730
6923
  panTo
6731
6924
  } = useHeycarMap();
6925
+ const {
6926
+ zoomRef,
6927
+ setZoom
6928
+ } = useMapZoom({
6929
+ mapRef,
6930
+ defaultValue: DEFAULT_ZOOM
6931
+ });
6732
6932
  const centerPlace = Vue.reactive({
6733
6933
  lng: defaultPlace.lng,
6734
6934
  lat: defaultPlace.lat,
@@ -6763,6 +6963,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6763
6963
  centerPlace.lat = place.lat;
6764
6964
  centerPlace.name = place.name;
6765
6965
  centerPlace.displayName = place.displayName;
6966
+ setZoom(ZONE_ZOOM);
6766
6967
  setPlaceCandidatesAndZone(recommends);
6767
6968
  emit("changePlace", {
6768
6969
  ...place
@@ -6775,6 +6976,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6775
6976
  centerPlace.lat = place.lat;
6776
6977
  centerPlace.name = place.name;
6777
6978
  centerPlace.displayName = place.displayName;
6979
+ if (zoneRef.value)
6980
+ setZoom(ZONE_ZOOM);
6778
6981
  emit("changePlace", {
6779
6982
  ...place
6780
6983
  });
@@ -6862,6 +7065,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6862
7065
  Object.assign(centerPlace, {
6863
7066
  ...place
6864
7067
  });
7068
+ if (isInZone)
7069
+ setZoom(ZONE_ZOOM);
6865
7070
  emit("changeRecomandPlace", {
6866
7071
  place,
6867
7072
  inputPlace,
@@ -6892,7 +7097,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6892
7097
  return Vue.h(HeycarMap, {
6893
7098
  "attrs": {
6894
7099
  "center": centerPoint.value,
6895
- "zoom": DEFAULT_ZOOM,
7100
+ "zoom": zoomRef.value,
6896
7101
  "touchZoomCenter": true,
6897
7102
  "mapRef": setMap,
6898
7103
  "fallback": slots.fallback,
@@ -6911,8 +7116,8 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6911
7116
  "attrs": {
6912
7117
  "basePlace": centerPlace,
6913
7118
  "places": placeCandidates.value,
6914
- "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6915
- "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
7119
+ "zoomIconMin": zoneRef.value ? RECOMMEND_PLACE_ZONE_ICON_MIN : RECOMMEND_PLACE_ICON_ZOOM_MIN,
7120
+ "zoomTextMin": zoneRef.value ? RECOMMEND_PLACE_ZONE_TEXT_MIN : RECOMMEND_PLACE_TEXT_ZOOM_MIN
6916
7121
  },
6917
7122
  "on": {
6918
7123
  "click": panToCenterByPlace
@@ -7302,6 +7507,7 @@ const WaveCircle = defineSetup(function WaveCircle2(props) {
7302
7507
  const PASSENGER_DISTANCE_MAX = 2e3;
7303
7508
  const PASSENGER_DISTANCE_MIN = 10;
7304
7509
  const CAR_DISTANCE_MIN = 100;
7510
+ const AUTO_FIT_VIEW_INTERVAL = 15e3;
7305
7511
  const carDurationWithinMinDistance = (distance) => Math.floor(distance / 5);
7306
7512
  const SectionDispatching = defineSetup(function SectionDispatching2(props) {
7307
7513
  return () => {
@@ -7332,6 +7538,11 @@ const SectionDispatching = defineSetup(function SectionDispatching2(props) {
7332
7538
  "attrs": {
7333
7539
  "registerOverlay": registerOverlay
7334
7540
  }
7541
+ }), Vue.h(InterruptableIntervalFitView, {
7542
+ "attrs": {
7543
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7544
+ "registerOverlay": registerOverlay
7545
+ }
7335
7546
  })]);
7336
7547
  };
7337
7548
  });
@@ -7397,10 +7608,19 @@ const SectionConfirmed = defineSetup(function SectionConfirmed2(props) {
7397
7608
  "attrs": {
7398
7609
  "registerOverlay": registerOverlay
7399
7610
  }
7611
+ }), Vue.h(InterruptableIntervalFitView, {
7612
+ "attrs": {
7613
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7614
+ "registerOverlay": registerOverlay
7615
+ }
7400
7616
  })]);
7401
7617
  };
7402
7618
  });
7403
7619
  const SectionDriverStartService = defineSetup(function SectionDriverStartService2(props) {
7620
+ const {
7621
+ registerOverlay
7622
+ } = props;
7623
+ const fittableRegistryOverlay = createFittableRegisterOverlay(registerOverlay);
7404
7624
  const {
7405
7625
  apiMapDistance
7406
7626
  } = useMapGeometry();
@@ -7411,8 +7631,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
7411
7631
  carAngle,
7412
7632
  passengerPosition,
7413
7633
  passengerAngle,
7414
- renderTitle,
7415
- registerOverlay
7634
+ renderTitle
7416
7635
  } = props;
7417
7636
  const from = place2point(fromPlace);
7418
7637
  const passengerDistance = passengerPosition ? apiMapDistance(passengerPosition, from) : void 0;
@@ -7446,7 +7665,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
7446
7665
  distance,
7447
7666
  duration
7448
7667
  }) => {
7449
- var _a, _b;
7668
+ var _a;
7450
7669
  spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
7451
7670
  return [Vue.h(DrivingLine, {
7452
7671
  "attrs": {
@@ -7460,12 +7679,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
7460
7679
  distance,
7461
7680
  duration
7462
7681
  }),
7463
- "registerOverlay": registerOverlay
7464
- }
7465
- }), Vue.h(KeyedFitView, {
7466
- "attrs": {
7467
- "registerOverlay": registerOverlay,
7468
- "fitViewKey": JSON.stringify((_b = path[0]) != null ? _b : carPosition)
7682
+ "registerOverlay": fittableRegistryOverlay
7469
7683
  }
7470
7684
  })];
7471
7685
  }
@@ -7478,12 +7692,7 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
7478
7692
  distance: carDistance,
7479
7693
  duration: carDurationWithinMinDistance(carDistance)
7480
7694
  }),
7481
- "registerOverlay": registerOverlay
7482
- }
7483
- }), Vue.h(KeyedFitView, {
7484
- "attrs": {
7485
- "registerOverlay": registerOverlay,
7486
- "fitViewKey": JSON.stringify(carPosition)
7695
+ "registerOverlay": fittableRegistryOverlay
7487
7696
  }
7488
7697
  })], !!passengerPosition && passengerDistance && passengerDistance < PASSENGER_DISTANCE_MAX && passengerDistance > PASSENGER_DISTANCE_MIN && Vue.h(WalkingRoute, {
7489
7698
  "attrs": {
@@ -7501,6 +7710,11 @@ const SectionDriverStartService = defineSetup(function SectionDriverStartService
7501
7710
  "attrs": {
7502
7711
  "registerOverlay": registerOverlay
7503
7712
  }
7713
+ }), Vue.h(InterruptableIntervalFitView, {
7714
+ "attrs": {
7715
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7716
+ "registerOverlay": registerOverlay
7717
+ }
7504
7718
  })]);
7505
7719
  };
7506
7720
  });
@@ -7578,10 +7792,19 @@ const SectionBookDispatched = defineSetup(function SectionBookDispatched2(props)
7578
7792
  "attrs": {
7579
7793
  "registerOverlay": registerOverlay
7580
7794
  }
7795
+ }), Vue.h(InterruptableIntervalFitView, {
7796
+ "attrs": {
7797
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7798
+ "registerOverlay": registerOverlay
7799
+ }
7581
7800
  })]);
7582
7801
  };
7583
7802
  });
7584
7803
  const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
7804
+ const {
7805
+ registerOverlay
7806
+ } = props;
7807
+ const fittableRegistryOverlay = createFittableRegisterOverlay(registerOverlay);
7585
7808
  const {
7586
7809
  apiMapDistance
7587
7810
  } = useMapGeometry();
@@ -7592,8 +7815,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
7592
7815
  carAngle,
7593
7816
  passengerPosition,
7594
7817
  passengerAngle,
7595
- title,
7596
- registerOverlay
7818
+ title
7597
7819
  } = props;
7598
7820
  const from = place2point(fromPlace);
7599
7821
  const passengerDistance = passengerPosition ? apiMapDistance(passengerPosition, from) : void 0;
@@ -7621,12 +7843,7 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
7621
7843
  "position": carPosition,
7622
7844
  "angle": carAngle,
7623
7845
  "title": title,
7624
- "registerOverlay": registerOverlay
7625
- }
7626
- }), Vue.h(KeyedFitView, {
7627
- "attrs": {
7628
- "registerOverlay": registerOverlay,
7629
- "fitViewKey": JSON.stringify(carPosition)
7846
+ "registerOverlay": fittableRegistryOverlay
7630
7847
  }
7631
7848
  })], Vue.h(StartEndPoint, {
7632
7849
  "attrs": {
@@ -7644,17 +7861,25 @@ const SectionDriverArrived = defineSetup(function SectionDriverArrived2(props) {
7644
7861
  "attrs": {
7645
7862
  "registerOverlay": registerOverlay
7646
7863
  }
7864
+ }), Vue.h(InterruptableIntervalFitView, {
7865
+ "attrs": {
7866
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7867
+ "registerOverlay": registerOverlay
7868
+ }
7647
7869
  })]);
7648
7870
  };
7649
7871
  });
7650
7872
  const SectionInService = defineSetup(function SectionInService2(props) {
7873
+ const {
7874
+ registerOverlay
7875
+ } = props;
7876
+ const fittableRegistryOverlay = createFittableRegisterOverlay(registerOverlay);
7651
7877
  return () => {
7652
7878
  const {
7653
7879
  to: toPlace,
7654
7880
  carPosition,
7655
7881
  carAngle,
7656
- renderTitle,
7657
- registerOverlay
7882
+ renderTitle
7658
7883
  } = props;
7659
7884
  const to = place2point(toPlace);
7660
7885
  const {
@@ -7671,7 +7896,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
7671
7896
  distance,
7672
7897
  duration
7673
7898
  }) => {
7674
- var _a, _b;
7899
+ var _a;
7675
7900
  spaceLog("angleDifference", "carPosition, routeAngle, driverAngle = ", carPosition, angle, carAngle);
7676
7901
  return [Vue.h(DrivingLine, {
7677
7902
  "attrs": {
@@ -7685,12 +7910,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
7685
7910
  distance,
7686
7911
  duration
7687
7912
  }),
7688
- "registerOverlay": registerOverlay
7689
- }
7690
- }), Vue.h(KeyedFitView, {
7691
- "attrs": {
7692
- "registerOverlay": registerOverlay,
7693
- "fitViewKey": JSON.stringify((_b = path[0]) != null ? _b : carPosition)
7913
+ "registerOverlay": fittableRegistryOverlay
7694
7914
  }
7695
7915
  })];
7696
7916
  }
@@ -7703,12 +7923,7 @@ const SectionInService = defineSetup(function SectionInService2(props) {
7703
7923
  distance: carDistance,
7704
7924
  duration: carDurationWithinMinDistance(carDistance)
7705
7925
  }),
7706
- "registerOverlay": registerOverlay
7707
- }
7708
- }), Vue.h(KeyedFitView, {
7709
- "attrs": {
7710
- "registerOverlay": registerOverlay,
7711
- "fitViewKey": JSON.stringify(carPosition)
7926
+ "registerOverlay": fittableRegistryOverlay
7712
7927
  }
7713
7928
  })], Vue.h(StartEndPoint, {
7714
7929
  "attrs": {
@@ -7726,6 +7941,11 @@ const SectionInService = defineSetup(function SectionInService2(props) {
7726
7941
  "attrs": {
7727
7942
  "registerOverlay": registerOverlay
7728
7943
  }
7944
+ }), Vue.h(InterruptableIntervalFitView, {
7945
+ "attrs": {
7946
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7947
+ "registerOverlay": registerOverlay
7948
+ }
7729
7949
  })]);
7730
7950
  };
7731
7951
  });
@@ -7766,6 +7986,11 @@ const SectionCanceled = defineSetup(function SectionCanceled2(props) {
7766
7986
  "attrs": {
7767
7987
  "registerOverlay": registerOverlay
7768
7988
  }
7989
+ }), Vue.h(InterruptableIntervalFitView, {
7990
+ "attrs": {
7991
+ "interval": AUTO_FIT_VIEW_INTERVAL,
7992
+ "registerOverlay": registerOverlay
7993
+ }
7769
7994
  })]);
7770
7995
  };
7771
7996
  });
@@ -7819,6 +8044,11 @@ const SectionEndService = defineSetup(function SectionEndService2(props) {
7819
8044
  "attrs": {
7820
8045
  "registerOverlay": registerOverlay
7821
8046
  }
8047
+ }), Vue.h(InterruptableIntervalFitView, {
8048
+ "attrs": {
8049
+ "interval": AUTO_FIT_VIEW_INTERVAL,
8050
+ "registerOverlay": registerOverlay
8051
+ }
7822
8052
  })]);
7823
8053
  };
7824
8054
  });