@heycar/heycars-map 0.8.3 → 0.8.4

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.3";
12
+ const version = "0.8.4";
13
13
  const type = "module";
14
14
  const scripts = {
15
15
  dev: "vite -c vite.config.dev.ts",
@@ -857,7 +857,6 @@ const useMapOverlay = (props) => {
857
857
  registerOverlay == null ? void 0 : registerOverlay.remove(overlay);
858
858
  });
859
859
  };
860
- const isLatLngLiteral = (obj) => obj != null && typeof obj === "object" && Number.isFinite(obj.lat) && Number.isFinite(obj.lng);
861
860
  var HAS_WEAK_MAP_SUPPORT = typeof WeakMap === "function";
862
861
  var keys = Object.keys;
863
862
  function sameValueZeroEqual(a, b) {
@@ -1098,6 +1097,23 @@ createComparator(function() {
1098
1097
  });
1099
1098
  createComparator(createCircularEqualCreator());
1100
1099
  createComparator(createCircularEqualCreator(sameValueZeroEqual));
1100
+ const isPlace = (place) => {
1101
+ return place.lng !== void 0 && place.lat !== void 0;
1102
+ };
1103
+ const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
1104
+ const assertPoint = (point) => {
1105
+ if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
1106
+ return;
1107
+ throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
1108
+ };
1109
+ const assertAngle = (angle) => {
1110
+ if (typeof angle === "number" || typeof angle === "undefined")
1111
+ return;
1112
+ throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
1113
+ };
1114
+ const isLatLngLiteral = (value) => {
1115
+ return value != null && typeof value === "object" && Number.isFinite(value.lat) && Number.isFinite(value.lng);
1116
+ };
1101
1117
  const vec2lnglat = ([lng, lat]) => ({
1102
1118
  lng: Number(lng),
1103
1119
  lat: Number(lat)
@@ -1214,8 +1230,8 @@ const wxGetLocationSuccessResponse2GeolocationPosition = (res) => {
1214
1230
  return { timestamp, coords };
1215
1231
  };
1216
1232
  const deepCompareEqualsForMaps = createComparator((deepEqual) => (a, b) => {
1217
- if (isLatLngLiteral(a) || isLatLngLiteral(b)) {
1218
- return new google.maps.LatLng(a).equals(new google.maps.LatLng(b));
1233
+ if (isLatLngLiteral(a) && isLatLngLiteral(b)) {
1234
+ return isPlaceEqual(a, b);
1219
1235
  }
1220
1236
  return deepEqual(a, b);
1221
1237
  });
@@ -3557,20 +3573,6 @@ const watchVisibilityState = () => {
3557
3573
  document.addEventListener("visibilitychange", handleVisibilityChange);
3558
3574
  return { visibilityStateRef, unwatchVisibilityState };
3559
3575
  };
3560
- const isPlace = (place) => {
3561
- return place.lng !== void 0 && place.lat !== void 0;
3562
- };
3563
- const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
3564
- const assertPoint = (point) => {
3565
- if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
3566
- return;
3567
- throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
3568
- };
3569
- const assertAngle = (angle) => {
3570
- if (typeof angle === "number" || typeof angle === "undefined")
3571
- return;
3572
- throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
3573
- };
3574
3576
  const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3575
3577
  const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3576
3578
  const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
@@ -5758,53 +5760,6 @@ const useMapRecomendPlace = (props) => {
5758
5760
  const { supplier } = useMapSupplier();
5759
5761
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5760
5762
  };
5761
- const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5762
- const DEFAULT_ZOOM$1 = 13;
5763
- const useAmapZoom = (props) => {
5764
- var _a, _b, _c;
5765
- const { onChange, mapRef, defaultValue } = props;
5766
- const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5767
- const setZoom = (v) => {
5768
- var _a2;
5769
- zoomRef.value = v;
5770
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5771
- };
5772
- const handleZoomEnd = (_, { target }) => {
5773
- const zoom = target.getZoom();
5774
- zoomRef.value = zoom;
5775
- onChange == null ? void 0 : onChange(zoom);
5776
- };
5777
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5778
- "onZoomEnd"
5779
- ]);
5780
- return { zoomRef, setZoom };
5781
- };
5782
- const useGmapZoom = (props) => {
5783
- var _a, _b, _c;
5784
- const { onChange, mapRef, defaultValue } = props;
5785
- const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5786
- const setZoom = (v) => {
5787
- var _a2;
5788
- zoomRef.value = v;
5789
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5790
- };
5791
- const handleZoomChange = debounce(
5792
- (_, { target }) => {
5793
- const zoom = target.getZoom();
5794
- zoomRef.value = zoom;
5795
- onChange == null ? void 0 : onChange(zoom);
5796
- },
5797
- GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5798
- );
5799
- watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5800
- "onZoom_changed"
5801
- ]);
5802
- return { zoomRef, setZoom };
5803
- };
5804
- const useMapZoom = (props) => {
5805
- const { supplier } = useMapSupplier();
5806
- return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
5807
- };
5808
5763
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5809
5764
  const polygonRef = Vue.shallowRef();
5810
5765
  const mapRef = useAmap();
@@ -6067,51 +6022,211 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6067
6022
  })]);
6068
6023
  };
6069
6024
  });
6025
+ const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
6026
+ const DEFAULT_ZOOM$1 = 13;
6027
+ const useAmapZoom = (props) => {
6028
+ var _a, _b, _c;
6029
+ const { onChange, mapRef, defaultValue } = props;
6030
+ const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
6031
+ const setZoom = (v) => {
6032
+ var _a2;
6033
+ zoomRef.value = v;
6034
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
6035
+ };
6036
+ const handleZoomEnd = (_, { target }) => {
6037
+ const zoom = target.getZoom();
6038
+ zoomRef.value = zoom;
6039
+ onChange == null ? void 0 : onChange(zoom);
6040
+ };
6041
+ Vue.watch(
6042
+ () => mapRef.value,
6043
+ (map) => {
6044
+ if (!map)
6045
+ return;
6046
+ zoomRef.value = map.getZoom();
6047
+ }
6048
+ );
6049
+ watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
6050
+ "onZoomEnd"
6051
+ ]);
6052
+ return { zoomRef, setZoom };
6053
+ };
6054
+ const useGmapZoom = (props) => {
6055
+ var _a, _b, _c;
6056
+ const { onChange, mapRef, defaultValue } = props;
6057
+ const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
6058
+ const setZoom = (v) => {
6059
+ var _a2;
6060
+ zoomRef.value = v;
6061
+ (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
6062
+ };
6063
+ const handleZoomChange = debounce(
6064
+ (_, { target }) => {
6065
+ const zoom = target.getZoom();
6066
+ zoomRef.value = zoom;
6067
+ onChange == null ? void 0 : onChange(zoom);
6068
+ },
6069
+ GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
6070
+ );
6071
+ Vue.watch(
6072
+ () => mapRef.value,
6073
+ (map) => {
6074
+ if (!map)
6075
+ return;
6076
+ zoomRef.value = map.getZoom();
6077
+ }
6078
+ );
6079
+ watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
6080
+ "onZoom_changed"
6081
+ ]);
6082
+ return { zoomRef, setZoom };
6083
+ };
6084
+ const useMapZoom = (props) => {
6085
+ const { supplier } = useMapSupplier();
6086
+ return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
6087
+ };
6070
6088
  const reverse = (direction) => direction === "left" ? "right" : "left";
6071
6089
  const usePointsLabelDirection = (props) => {
6072
6090
  const { widthLimit, heightLimit } = props;
6073
6091
  const mapRef = useMap();
6074
6092
  const { apiMapLngLatToVw } = useMapLngLatToVw({ mapRef });
6093
+ const { zoomRef } = useMapZoom({ mapRef });
6075
6094
  const diffVw = (from, to) => {
6076
6095
  const [x1, y1] = apiMapLngLatToVw(from);
6077
6096
  const [x2, y2] = apiMapLngLatToVw(to);
6078
6097
  return [x2 - x1, y2 - y1];
6079
6098
  };
6080
- const directionsRef = Vue.ref(Array(props.places.length).fill("right"));
6099
+ const directionsRef = Vue.ref([]);
6100
+ const labeledPlacesRef = Vue.ref([]);
6101
+ const isContainBasePlaceRef = Vue.ref(false);
6081
6102
  watchEffectForDeepOption(
6082
- () => props.places.map(place2point),
6083
- (points) => {
6084
- const sortedPoints = points.map((point, index) => ({ point, index })).sort(
6085
- ({ point: [, lat1] }, { point: [, lat2] }) => lat1 < lat2 ? 1 : lat1 > lat2 ? -1 : 0
6103
+ () => [[...props.places], { ...props.basePlace }, zoomRef.value],
6104
+ ([places, basePlace]) => {
6105
+ const placesExcludeBase = places.filter((place) => !isPlaceEqual(place, basePlace));
6106
+ isContainBasePlaceRef.value = placesExcludeBase.length < places.length;
6107
+ const sortedPlaces = placesExcludeBase.sort(
6108
+ ({ lat: lat1 }, { lat: lat2 }) => lat1 < lat2 ? 1 : lat1 > lat2 ? -1 : 0
6109
+ );
6110
+ const noOverlapPlaces = filterNoOverlapPlaces({
6111
+ basePlace,
6112
+ sortedPlaces,
6113
+ widthLimit,
6114
+ heightLimit,
6115
+ distanceFn: diffVw
6116
+ });
6117
+ const directions = createLabelDirections({
6118
+ sortedPoints: sortedPlaces.map(place2point),
6119
+ widthLimit,
6120
+ heightLimit,
6121
+ distanceFn: diffVw
6122
+ });
6123
+ directionsRef.value = directions;
6124
+ labeledPlacesRef.value = noOverlapPlaces;
6125
+ console.log(
6126
+ "usePointsLabelDirection basePlace, noOverlapPlaces = ",
6127
+ basePlace.displayName,
6128
+ noOverlapPlaces.map((item) => item.displayName)
6086
6129
  );
6087
- const len = points.length;
6088
- const result = Array(len);
6089
- let prevDirection = "right";
6090
- let isLimited = false;
6091
- for (let idx = 0; idx < len; idx++) {
6092
- const { index } = sortedPoints[idx];
6093
- if (idx === len - 1) {
6094
- result[index] = isLimited ? reverse(prevDirection) : "right";
6095
- continue;
6096
- }
6097
- if (idx === 0) {
6098
- const [dx2, dy2] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6099
- isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6100
- const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6101
- result[index] = direction2;
6102
- prevDirection = direction2;
6103
- continue;
6104
- }
6105
- const [dx, dy] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6106
- const direction = isLimited ? reverse(prevDirection) : "right";
6107
- result[index] = direction;
6108
- prevDirection = direction;
6109
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6110
- }
6111
- directionsRef.value = result;
6112
6130
  }
6113
6131
  );
6114
- return directionsRef;
6132
+ return { directionsRef, labeledPlacesRef, isContainBasePlaceRef };
6133
+ };
6134
+ function createLabelDirections(props) {
6135
+ const { sortedPoints, widthLimit, heightLimit, distanceFn } = props;
6136
+ const len = sortedPoints.length;
6137
+ const result = [];
6138
+ let prevDirection = "right";
6139
+ let isLimited = false;
6140
+ for (let idx = 0; idx < len; idx++) {
6141
+ if (idx === len - 1) {
6142
+ const direction2 = isLimited ? reverse(prevDirection) : "right";
6143
+ result.push(direction2);
6144
+ continue;
6145
+ }
6146
+ if (idx === 0) {
6147
+ const [dx2, dy2] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6148
+ isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6149
+ const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6150
+ result.push(direction2);
6151
+ prevDirection = direction2;
6152
+ continue;
6153
+ }
6154
+ const [dx, dy] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6155
+ const direction = isLimited ? reverse(prevDirection) : "right";
6156
+ result.push(direction);
6157
+ prevDirection = direction;
6158
+ isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6159
+ }
6160
+ return result;
6161
+ }
6162
+ function filterNoOverlapPlaces(props) {
6163
+ const { basePlace, sortedPlaces, widthLimit, heightLimit, distanceFn } = props;
6164
+ const measureOverlap = (place1, place2) => {
6165
+ const [dx, dy] = distanceFn(place2point(place1), place2point(place2));
6166
+ const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6167
+ console.log(
6168
+ "p1, p2, dx, dy, isOverlap = ",
6169
+ place1.displayName,
6170
+ place2.displayName,
6171
+ dx,
6172
+ dy,
6173
+ isOverlap
6174
+ );
6175
+ return isOverlap;
6176
+ };
6177
+ let nextPlaces = sortedPlaces;
6178
+ let overlapPlaces = findRelation(nextPlaces, measureOverlap);
6179
+ while (overlapPlaces.length > 0) {
6180
+ const maxPlace = findMax(overlapPlaces, (place) => {
6181
+ const [dx, dy] = distanceFn(place2point(place), place2point(basePlace));
6182
+ return dx * dx + dy * dy;
6183
+ });
6184
+ nextPlaces = nextPlaces.filter((place) => !isPlaceEqual(maxPlace, place));
6185
+ overlapPlaces = findRelation(nextPlaces, measureOverlap);
6186
+ }
6187
+ return nextPlaces;
6188
+ }
6189
+ const findRelation = (places, measureRelate) => {
6190
+ let isPrevRelated = false;
6191
+ let isNextRelated = false;
6192
+ let isFound = false;
6193
+ const result = [];
6194
+ for (const [idx, place] of places.slice(0, -1).entries()) {
6195
+ isNextRelated = measureRelate(place, places[idx + 1]);
6196
+ if (!isPrevRelated) {
6197
+ isPrevRelated = isNextRelated;
6198
+ continue;
6199
+ }
6200
+ if (!isNextRelated) {
6201
+ if (isFound) {
6202
+ result.push(place);
6203
+ result.push(places[idx + 1]);
6204
+ return result;
6205
+ }
6206
+ isPrevRelated = isNextRelated;
6207
+ continue;
6208
+ }
6209
+ if (!isFound)
6210
+ result.push(places[idx - 1]);
6211
+ if (idx === places.length - 2)
6212
+ result.push(places[idx + 1]);
6213
+ result.push(place);
6214
+ isPrevRelated = isNextRelated;
6215
+ isFound = true;
6216
+ }
6217
+ return result;
6218
+ };
6219
+ const findMax = (list, measure) => {
6220
+ let max = -Infinity;
6221
+ let index = 0;
6222
+ for (const [idx, item] of list.entries()) {
6223
+ const value = measure(item);
6224
+ if (value <= max)
6225
+ continue;
6226
+ max = value;
6227
+ index = idx;
6228
+ }
6229
+ return list[index];
6115
6230
  };
6116
6231
  var AnchorType = /* @__PURE__ */ ((AnchorType2) => {
6117
6232
  AnchorType2["topLeft"] = "top-left";
@@ -6257,18 +6372,31 @@ const PlaceCircle = defineSetup(function PlaceCircle2(props, {
6257
6372
  const PickupPoints = defineSetup(function PickupPoints2(props, {
6258
6373
  emit
6259
6374
  }) {
6375
+ const mapRef = useMap();
6260
6376
  const {
6261
- renderLabel
6262
- } = props;
6263
- const directions = usePointsLabelDirection(Vue.reactive({
6377
+ zoomRef
6378
+ } = useMapZoom({
6379
+ mapRef
6380
+ });
6381
+ const {
6382
+ directionsRef,
6383
+ labeledPlacesRef,
6384
+ isContainBasePlaceRef
6385
+ } = usePointsLabelDirection(Vue.reactive({
6386
+ basePlace: Vue.toRef(props, "basePlace"),
6264
6387
  places: Vue.toRef(props, "places"),
6265
6388
  heightLimit: 9,
6266
6389
  widthLimit: 32
6267
6390
  }));
6268
6391
  return () => {
6269
- return Vue.h("div", [props.places.map((place, idx) => {
6270
- const direction = directions.value[idx];
6271
- const label2 = renderLabel ? renderLabel(place) : place.displayName;
6392
+ const {
6393
+ basePlace,
6394
+ zoomIconMin,
6395
+ zoomTextMin
6396
+ } = props;
6397
+ return Vue.h("div", [zoomRef.value >= zoomIconMin && labeledPlacesRef.value.map((place, idx) => {
6398
+ const direction = directionsRef.value[idx];
6399
+ const label2 = zoomRef.value < zoomTextMin ? void 0 : place.displayName;
6272
6400
  return Vue.h(PlaceCircle, {
6273
6401
  "attrs": {
6274
6402
  "position": place2point(place),
@@ -6279,12 +6407,17 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
6279
6407
  "click": () => emit("click", place)
6280
6408
  }
6281
6409
  });
6410
+ }), isContainBasePlaceRef.value && Vue.h(PlaceCircle, {
6411
+ "attrs": {
6412
+ "position": place2point(basePlace)
6413
+ }
6282
6414
  })]);
6283
6415
  };
6284
6416
  });
6285
6417
  const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6286
6418
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6287
- const RECOMMEND_PLACE_ZOOM_MIN = 13;
6419
+ const RECOMMEND_PLACE_ICON_ZOOM_MIN = 15.75;
6420
+ const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.75;
6288
6421
  const DEFAULT_PLACE_NAME = "当前位置";
6289
6422
  const DEFAULT_ZOOM = 17;
6290
6423
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
@@ -6309,12 +6442,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6309
6442
  const {
6310
6443
  readyPromise
6311
6444
  } = useMapSupplier();
6312
- const {
6313
- zoomRef
6314
- } = useMapZoom({
6315
- mapRef,
6316
- defaultValue: DEFAULT_ZOOM
6317
- });
6318
6445
  const centerPlace = Vue.reactive({
6319
6446
  lng: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _a : 0,
6320
6447
  lat: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _b : 0,
@@ -6491,13 +6618,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6491
6618
  recomendDescription,
6492
6619
  unavailableTitle
6493
6620
  } = props;
6494
- console.log("centerPlace = ", JSON.stringify(centerPlace));
6495
6621
  const title = geoLoading.value ? geoLoadingTitle2 : !availableRef.value ? unavailableTitle : centerPlace.displayName;
6496
6622
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
6497
6623
  return Vue.h(HeycarMap, {
6498
6624
  "attrs": {
6499
6625
  "center": centerPoint.value,
6500
- "zoom": zoomRef.value,
6626
+ "zoom": DEFAULT_ZOOM,
6501
6627
  "touchZoomCenter": true,
6502
6628
  "mapRef": setMap,
6503
6629
  "fallback": slots.fallback,
@@ -6512,10 +6638,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6512
6638
  "position": geoPosition.value,
6513
6639
  "angle": orientation.cssRotationVariableName
6514
6640
  }
6515
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && Vue.h(PickupPoints, {
6641
+ }), Vue.h(PickupPoints, {
6516
6642
  "attrs": {
6643
+ "basePlace": centerPlace,
6517
6644
  "places": placeCandidates.value,
6518
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6645
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6646
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6519
6647
  },
6520
6648
  "on": {
6521
6649
  "click": panToCenterByPlace
@@ -6557,12 +6685,6 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6557
6685
  setMap,
6558
6686
  panTo
6559
6687
  } = useHeycarMap();
6560
- const {
6561
- zoomRef
6562
- } = useMapZoom({
6563
- mapRef,
6564
- defaultValue: DEFAULT_ZOOM
6565
- });
6566
6688
  const centerPlace = Vue.reactive({
6567
6689
  lng: defaultPlace.lng,
6568
6690
  lat: defaultPlace.lat,
@@ -6726,7 +6848,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6726
6848
  return Vue.h(HeycarMap, {
6727
6849
  "attrs": {
6728
6850
  "center": centerPoint.value,
6729
- "zoom": zoomRef.value,
6851
+ "zoom": DEFAULT_ZOOM,
6730
6852
  "touchZoomCenter": true,
6731
6853
  "mapRef": setMap,
6732
6854
  "fallback": slots.fallback,
@@ -6741,10 +6863,12 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6741
6863
  "position": geoPosition.value,
6742
6864
  "angle": orientation.cssRotationVariableName
6743
6865
  }
6744
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && Vue.h(PickupPoints, {
6866
+ }), Vue.h(PickupPoints, {
6745
6867
  "attrs": {
6868
+ "basePlace": centerPlace,
6746
6869
  "places": placeCandidates.value,
6747
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6870
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6871
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6748
6872
  },
6749
6873
  "on": {
6750
6874
  "click": panToCenterByPlace
@@ -7916,7 +8040,6 @@ const useBusinessTaxiServiceMap = () => {
7916
8040
  const { mapRef, setMap } = useHeycarMap();
7917
8041
  const { registerFitVeiw, setFitView } = useMapFitView({
7918
8042
  mapRef,
7919
- autoFitTimeout: 5e3,
7920
8043
  padding: [19, 36, 19, 26]
7921
8044
  });
7922
8045
  return { setMap, registerFitVeiw, setFitView };
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.3";
10
+ const version = "0.8.4";
11
11
  const type = "module";
12
12
  const scripts = {
13
13
  dev: "vite -c vite.config.dev.ts",
@@ -855,7 +855,6 @@ const useMapOverlay = (props) => {
855
855
  registerOverlay == null ? void 0 : registerOverlay.remove(overlay);
856
856
  });
857
857
  };
858
- const isLatLngLiteral = (obj) => obj != null && typeof obj === "object" && Number.isFinite(obj.lat) && Number.isFinite(obj.lng);
859
858
  var HAS_WEAK_MAP_SUPPORT = typeof WeakMap === "function";
860
859
  var keys = Object.keys;
861
860
  function sameValueZeroEqual(a, b) {
@@ -1096,6 +1095,23 @@ createComparator(function() {
1096
1095
  });
1097
1096
  createComparator(createCircularEqualCreator());
1098
1097
  createComparator(createCircularEqualCreator(sameValueZeroEqual));
1098
+ const isPlace = (place) => {
1099
+ return place.lng !== void 0 && place.lat !== void 0;
1100
+ };
1101
+ const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
1102
+ const assertPoint = (point) => {
1103
+ if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
1104
+ return;
1105
+ throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
1106
+ };
1107
+ const assertAngle = (angle) => {
1108
+ if (typeof angle === "number" || typeof angle === "undefined")
1109
+ return;
1110
+ throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
1111
+ };
1112
+ const isLatLngLiteral = (value) => {
1113
+ return value != null && typeof value === "object" && Number.isFinite(value.lat) && Number.isFinite(value.lng);
1114
+ };
1099
1115
  const vec2lnglat = ([lng, lat]) => ({
1100
1116
  lng: Number(lng),
1101
1117
  lat: Number(lat)
@@ -1212,8 +1228,8 @@ const wxGetLocationSuccessResponse2GeolocationPosition = (res) => {
1212
1228
  return { timestamp, coords };
1213
1229
  };
1214
1230
  const deepCompareEqualsForMaps = createComparator((deepEqual) => (a, b) => {
1215
- if (isLatLngLiteral(a) || isLatLngLiteral(b)) {
1216
- return new google.maps.LatLng(a).equals(new google.maps.LatLng(b));
1231
+ if (isLatLngLiteral(a) && isLatLngLiteral(b)) {
1232
+ return isPlaceEqual(a, b);
1217
1233
  }
1218
1234
  return deepEqual(a, b);
1219
1235
  });
@@ -3555,20 +3571,6 @@ const watchVisibilityState = () => {
3555
3571
  document.addEventListener("visibilitychange", handleVisibilityChange);
3556
3572
  return { visibilityStateRef, unwatchVisibilityState };
3557
3573
  };
3558
- const isPlace = (place) => {
3559
- return place.lng !== void 0 && place.lat !== void 0;
3560
- };
3561
- const sleep = (milliSeconds) => new Promise((resolve) => setTimeout(resolve, milliSeconds));
3562
- const assertPoint = (point) => {
3563
- if (Array.isArray(point) && point.length === 2 && typeof point[0] === "number" && typeof point[1] === "number")
3564
- return;
3565
- throw new Error(`Assertion Error: expect type [number, number], actual is ${point}`);
3566
- };
3567
- const assertAngle = (angle) => {
3568
- if (typeof angle === "number" || typeof angle === "undefined")
3569
- return;
3570
- throw new Error(`Assertion Error: expect type number | undefined, actual is ${angle}`);
3571
- };
3572
3574
  const WX_GET_LOCATION_INTERVAL_STILL = 10 * 1e3;
3573
3575
  const WX_GET_LOCATION_INTERVAL_SLOW = 3 * 1e3;
3574
3576
  const WX_GET_LOCATION_INTERVAL_FAST = 1 * 1e3;
@@ -5756,53 +5758,6 @@ const useMapRecomendPlace = (props) => {
5756
5758
  const { supplier } = useMapSupplier();
5757
5759
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5758
5760
  };
5759
- const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5760
- const DEFAULT_ZOOM$1 = 13;
5761
- const useAmapZoom = (props) => {
5762
- var _a, _b, _c;
5763
- const { onChange, mapRef, defaultValue } = props;
5764
- const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5765
- const setZoom = (v) => {
5766
- var _a2;
5767
- zoomRef.value = v;
5768
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5769
- };
5770
- const handleZoomEnd = (_, { target }) => {
5771
- const zoom = target.getZoom();
5772
- zoomRef.value = zoom;
5773
- onChange == null ? void 0 : onChange(zoom);
5774
- };
5775
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5776
- "onZoomEnd"
5777
- ]);
5778
- return { zoomRef, setZoom };
5779
- };
5780
- const useGmapZoom = (props) => {
5781
- var _a, _b, _c;
5782
- const { onChange, mapRef, defaultValue } = props;
5783
- const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5784
- const setZoom = (v) => {
5785
- var _a2;
5786
- zoomRef.value = v;
5787
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5788
- };
5789
- const handleZoomChange = debounce(
5790
- (_, { target }) => {
5791
- const zoom = target.getZoom();
5792
- zoomRef.value = zoom;
5793
- onChange == null ? void 0 : onChange(zoom);
5794
- },
5795
- GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5796
- );
5797
- watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5798
- "onZoom_changed"
5799
- ]);
5800
- return { zoomRef, setZoom };
5801
- };
5802
- const useMapZoom = (props) => {
5803
- const { supplier } = useMapSupplier();
5804
- return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
5805
- };
5806
5761
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5807
5762
  const polygonRef = shallowRef();
5808
5763
  const mapRef = useAmap();
@@ -6065,51 +6020,211 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6065
6020
  })]);
6066
6021
  };
6067
6022
  });
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 = 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
+ 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 = 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
+ 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
+ };
6068
6086
  const reverse = (direction) => direction === "left" ? "right" : "left";
6069
6087
  const usePointsLabelDirection = (props) => {
6070
6088
  const { widthLimit, heightLimit } = props;
6071
6089
  const mapRef = useMap();
6072
6090
  const { apiMapLngLatToVw } = useMapLngLatToVw({ mapRef });
6091
+ const { zoomRef } = useMapZoom({ mapRef });
6073
6092
  const diffVw = (from, to) => {
6074
6093
  const [x1, y1] = apiMapLngLatToVw(from);
6075
6094
  const [x2, y2] = apiMapLngLatToVw(to);
6076
6095
  return [x2 - x1, y2 - y1];
6077
6096
  };
6078
- const directionsRef = ref(Array(props.places.length).fill("right"));
6097
+ const directionsRef = ref([]);
6098
+ const labeledPlacesRef = ref([]);
6099
+ const isContainBasePlaceRef = ref(false);
6079
6100
  watchEffectForDeepOption(
6080
- () => props.places.map(place2point),
6081
- (points) => {
6082
- const sortedPoints = points.map((point, index) => ({ point, index })).sort(
6083
- ({ point: [, lat1] }, { point: [, lat2] }) => lat1 < lat2 ? 1 : lat1 > lat2 ? -1 : 0
6101
+ () => [[...props.places], { ...props.basePlace }, zoomRef.value],
6102
+ ([places, basePlace]) => {
6103
+ const placesExcludeBase = places.filter((place) => !isPlaceEqual(place, basePlace));
6104
+ isContainBasePlaceRef.value = placesExcludeBase.length < places.length;
6105
+ const sortedPlaces = placesExcludeBase.sort(
6106
+ ({ lat: lat1 }, { lat: lat2 }) => lat1 < lat2 ? 1 : lat1 > lat2 ? -1 : 0
6107
+ );
6108
+ const noOverlapPlaces = filterNoOverlapPlaces({
6109
+ basePlace,
6110
+ sortedPlaces,
6111
+ widthLimit,
6112
+ heightLimit,
6113
+ distanceFn: diffVw
6114
+ });
6115
+ const directions = createLabelDirections({
6116
+ sortedPoints: sortedPlaces.map(place2point),
6117
+ widthLimit,
6118
+ heightLimit,
6119
+ distanceFn: diffVw
6120
+ });
6121
+ directionsRef.value = directions;
6122
+ labeledPlacesRef.value = noOverlapPlaces;
6123
+ console.log(
6124
+ "usePointsLabelDirection basePlace, noOverlapPlaces = ",
6125
+ basePlace.displayName,
6126
+ noOverlapPlaces.map((item) => item.displayName)
6084
6127
  );
6085
- const len = points.length;
6086
- const result = Array(len);
6087
- let prevDirection = "right";
6088
- let isLimited = false;
6089
- for (let idx = 0; idx < len; idx++) {
6090
- const { index } = sortedPoints[idx];
6091
- if (idx === len - 1) {
6092
- result[index] = isLimited ? reverse(prevDirection) : "right";
6093
- continue;
6094
- }
6095
- if (idx === 0) {
6096
- const [dx2, dy2] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6097
- isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6098
- const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6099
- result[index] = direction2;
6100
- prevDirection = direction2;
6101
- continue;
6102
- }
6103
- const [dx, dy] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6104
- const direction = isLimited ? reverse(prevDirection) : "right";
6105
- result[index] = direction;
6106
- prevDirection = direction;
6107
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6108
- }
6109
- directionsRef.value = result;
6110
6128
  }
6111
6129
  );
6112
- return directionsRef;
6130
+ return { directionsRef, labeledPlacesRef, isContainBasePlaceRef };
6131
+ };
6132
+ function createLabelDirections(props) {
6133
+ const { sortedPoints, widthLimit, heightLimit, distanceFn } = props;
6134
+ const len = sortedPoints.length;
6135
+ const result = [];
6136
+ let prevDirection = "right";
6137
+ let isLimited = false;
6138
+ for (let idx = 0; idx < len; idx++) {
6139
+ if (idx === len - 1) {
6140
+ const direction2 = isLimited ? reverse(prevDirection) : "right";
6141
+ result.push(direction2);
6142
+ continue;
6143
+ }
6144
+ if (idx === 0) {
6145
+ const [dx2, dy2] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6146
+ isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6147
+ const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6148
+ result.push(direction2);
6149
+ prevDirection = direction2;
6150
+ continue;
6151
+ }
6152
+ const [dx, dy] = distanceFn(sortedPoints[idx], sortedPoints[idx + 1]);
6153
+ const direction = isLimited ? reverse(prevDirection) : "right";
6154
+ result.push(direction);
6155
+ prevDirection = direction;
6156
+ isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6157
+ }
6158
+ return result;
6159
+ }
6160
+ function filterNoOverlapPlaces(props) {
6161
+ const { basePlace, sortedPlaces, widthLimit, heightLimit, distanceFn } = props;
6162
+ const measureOverlap = (place1, place2) => {
6163
+ const [dx, dy] = distanceFn(place2point(place1), place2point(place2));
6164
+ const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6165
+ console.log(
6166
+ "p1, p2, dx, dy, isOverlap = ",
6167
+ place1.displayName,
6168
+ place2.displayName,
6169
+ dx,
6170
+ dy,
6171
+ isOverlap
6172
+ );
6173
+ return isOverlap;
6174
+ };
6175
+ let nextPlaces = sortedPlaces;
6176
+ let overlapPlaces = findRelation(nextPlaces, measureOverlap);
6177
+ while (overlapPlaces.length > 0) {
6178
+ const maxPlace = findMax(overlapPlaces, (place) => {
6179
+ const [dx, dy] = distanceFn(place2point(place), place2point(basePlace));
6180
+ return dx * dx + dy * dy;
6181
+ });
6182
+ nextPlaces = nextPlaces.filter((place) => !isPlaceEqual(maxPlace, place));
6183
+ overlapPlaces = findRelation(nextPlaces, measureOverlap);
6184
+ }
6185
+ return nextPlaces;
6186
+ }
6187
+ const findRelation = (places, measureRelate) => {
6188
+ let isPrevRelated = false;
6189
+ let isNextRelated = false;
6190
+ let isFound = false;
6191
+ const result = [];
6192
+ for (const [idx, place] of places.slice(0, -1).entries()) {
6193
+ isNextRelated = measureRelate(place, places[idx + 1]);
6194
+ if (!isPrevRelated) {
6195
+ isPrevRelated = isNextRelated;
6196
+ continue;
6197
+ }
6198
+ if (!isNextRelated) {
6199
+ if (isFound) {
6200
+ result.push(place);
6201
+ result.push(places[idx + 1]);
6202
+ return result;
6203
+ }
6204
+ isPrevRelated = isNextRelated;
6205
+ continue;
6206
+ }
6207
+ if (!isFound)
6208
+ result.push(places[idx - 1]);
6209
+ if (idx === places.length - 2)
6210
+ result.push(places[idx + 1]);
6211
+ result.push(place);
6212
+ isPrevRelated = isNextRelated;
6213
+ isFound = true;
6214
+ }
6215
+ return result;
6216
+ };
6217
+ const findMax = (list, measure) => {
6218
+ let max = -Infinity;
6219
+ let index = 0;
6220
+ for (const [idx, item] of list.entries()) {
6221
+ const value = measure(item);
6222
+ if (value <= max)
6223
+ continue;
6224
+ max = value;
6225
+ index = idx;
6226
+ }
6227
+ return list[index];
6113
6228
  };
6114
6229
  var AnchorType = /* @__PURE__ */ ((AnchorType2) => {
6115
6230
  AnchorType2["topLeft"] = "top-left";
@@ -6255,18 +6370,31 @@ const PlaceCircle = defineSetup(function PlaceCircle2(props, {
6255
6370
  const PickupPoints = defineSetup(function PickupPoints2(props, {
6256
6371
  emit
6257
6372
  }) {
6373
+ const mapRef = useMap();
6258
6374
  const {
6259
- renderLabel
6260
- } = props;
6261
- const directions = usePointsLabelDirection(reactive({
6375
+ zoomRef
6376
+ } = useMapZoom({
6377
+ mapRef
6378
+ });
6379
+ const {
6380
+ directionsRef,
6381
+ labeledPlacesRef,
6382
+ isContainBasePlaceRef
6383
+ } = usePointsLabelDirection(reactive({
6384
+ basePlace: toRef(props, "basePlace"),
6262
6385
  places: toRef(props, "places"),
6263
6386
  heightLimit: 9,
6264
6387
  widthLimit: 32
6265
6388
  }));
6266
6389
  return () => {
6267
- return h("div", [props.places.map((place, idx) => {
6268
- const direction = directions.value[idx];
6269
- const label2 = renderLabel ? renderLabel(place) : place.displayName;
6390
+ const {
6391
+ basePlace,
6392
+ zoomIconMin,
6393
+ zoomTextMin
6394
+ } = props;
6395
+ return h("div", [zoomRef.value >= zoomIconMin && labeledPlacesRef.value.map((place, idx) => {
6396
+ const direction = directionsRef.value[idx];
6397
+ const label2 = zoomRef.value < zoomTextMin ? void 0 : place.displayName;
6270
6398
  return h(PlaceCircle, {
6271
6399
  "attrs": {
6272
6400
  "position": place2point(place),
@@ -6277,12 +6405,17 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
6277
6405
  "click": () => emit("click", place)
6278
6406
  }
6279
6407
  });
6408
+ }), isContainBasePlaceRef.value && h(PlaceCircle, {
6409
+ "attrs": {
6410
+ "position": place2point(basePlace)
6411
+ }
6280
6412
  })]);
6281
6413
  };
6282
6414
  });
6283
6415
  const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6284
6416
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6285
- const RECOMMEND_PLACE_ZOOM_MIN = 13;
6417
+ const RECOMMEND_PLACE_ICON_ZOOM_MIN = 15.75;
6418
+ const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.75;
6286
6419
  const DEFAULT_PLACE_NAME = "当前位置";
6287
6420
  const DEFAULT_ZOOM = 17;
6288
6421
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
@@ -6307,12 +6440,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6307
6440
  const {
6308
6441
  readyPromise
6309
6442
  } = useMapSupplier();
6310
- const {
6311
- zoomRef
6312
- } = useMapZoom({
6313
- mapRef,
6314
- defaultValue: DEFAULT_ZOOM
6315
- });
6316
6443
  const centerPlace = reactive({
6317
6444
  lng: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _a : 0,
6318
6445
  lat: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _b : 0,
@@ -6489,13 +6616,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6489
6616
  recomendDescription,
6490
6617
  unavailableTitle
6491
6618
  } = props;
6492
- console.log("centerPlace = ", JSON.stringify(centerPlace));
6493
6619
  const title = geoLoading.value ? geoLoadingTitle2 : !availableRef.value ? unavailableTitle : centerPlace.displayName;
6494
6620
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
6495
6621
  return h(HeycarMap, {
6496
6622
  "attrs": {
6497
6623
  "center": centerPoint.value,
6498
- "zoom": zoomRef.value,
6624
+ "zoom": DEFAULT_ZOOM,
6499
6625
  "touchZoomCenter": true,
6500
6626
  "mapRef": setMap,
6501
6627
  "fallback": slots.fallback,
@@ -6510,10 +6636,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6510
6636
  "position": geoPosition.value,
6511
6637
  "angle": orientation.cssRotationVariableName
6512
6638
  }
6513
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && h(PickupPoints, {
6639
+ }), h(PickupPoints, {
6514
6640
  "attrs": {
6641
+ "basePlace": centerPlace,
6515
6642
  "places": placeCandidates.value,
6516
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6643
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6644
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6517
6645
  },
6518
6646
  "on": {
6519
6647
  "click": panToCenterByPlace
@@ -6555,12 +6683,6 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6555
6683
  setMap,
6556
6684
  panTo
6557
6685
  } = useHeycarMap();
6558
- const {
6559
- zoomRef
6560
- } = useMapZoom({
6561
- mapRef,
6562
- defaultValue: DEFAULT_ZOOM
6563
- });
6564
6686
  const centerPlace = reactive({
6565
6687
  lng: defaultPlace.lng,
6566
6688
  lat: defaultPlace.lat,
@@ -6724,7 +6846,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6724
6846
  return h(HeycarMap, {
6725
6847
  "attrs": {
6726
6848
  "center": centerPoint.value,
6727
- "zoom": zoomRef.value,
6849
+ "zoom": DEFAULT_ZOOM,
6728
6850
  "touchZoomCenter": true,
6729
6851
  "mapRef": setMap,
6730
6852
  "fallback": slots.fallback,
@@ -6739,10 +6861,12 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6739
6861
  "position": geoPosition.value,
6740
6862
  "angle": orientation.cssRotationVariableName
6741
6863
  }
6742
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && h(PickupPoints, {
6864
+ }), h(PickupPoints, {
6743
6865
  "attrs": {
6866
+ "basePlace": centerPlace,
6744
6867
  "places": placeCandidates.value,
6745
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6868
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6869
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6746
6870
  },
6747
6871
  "on": {
6748
6872
  "click": panToCenterByPlace
@@ -7914,7 +8038,6 @@ const useBusinessTaxiServiceMap = () => {
7914
8038
  const { mapRef, setMap } = useHeycarMap();
7915
8039
  const { registerFitVeiw, setFitView } = useMapFitView({
7916
8040
  mapRef,
7917
- autoFitTimeout: 5e3,
7918
8041
  padding: [19, 36, 19, 26]
7919
8042
  });
7920
8043
  return { setMap, registerFitVeiw, setFitView };
@@ -8,7 +8,8 @@ import type { Place, Point } from "../../types/interface";
8
8
  import { AbsoluteAddressBoxProps } from "../AbsoluteAddressBox";
9
9
  export declare const RECOMMEND_PLACE_DRAG_LIMIT = 10;
10
10
  export declare const RECOMMEND_PLACE_LARGE_LIMIT = 100;
11
- export declare const RECOMMEND_PLACE_ZOOM_MIN = 13;
11
+ export declare const RECOMMEND_PLACE_ICON_ZOOM_MIN = 15.75;
12
+ export declare const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.75;
12
13
  export declare const DEFAULT_PLACE_NAME = "\u5F53\u524D\u4F4D\u7F6E";
13
14
  export declare const DEFAULT_ZOOM = 17;
14
15
  export interface CenterPlaceSource {
@@ -1,7 +1,9 @@
1
1
  import type { Place } from "../../types/interface";
2
2
  export interface PickupPointsProps {
3
3
  places: Place[];
4
- renderLabel?: (place: Place) => string | undefined;
4
+ basePlace: Place;
5
+ zoomTextMin: number;
6
+ zoomIconMin: number;
5
7
  onClick?: (value: Place) => any;
6
8
  }
7
9
  export declare const PickupPoints: import("vue-demi").DefineComponent<import("vue/types/v3-component-props").ComponentObjectPropsOptions<PickupPointsProps>, 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<PickupPointsProps, Required<PickupPointsProps>>, "click", PickupPointsProps, {}>;
@@ -1,9 +1,19 @@
1
1
  import type { Place } from "../types/interface";
2
2
  type LabelDirection = "left" | "right";
3
3
  export interface UsePointsLabelDirectionProps {
4
+ basePlace: Place;
4
5
  places: Place[];
5
6
  widthLimit: number;
6
7
  heightLimit: number;
7
8
  }
8
- export declare const usePointsLabelDirection: (props: UsePointsLabelDirectionProps) => import("vue-demi").Ref<LabelDirection[]>;
9
+ export declare const usePointsLabelDirection: (props: UsePointsLabelDirectionProps) => {
10
+ directionsRef: import("vue-demi").Ref<LabelDirection[]>;
11
+ labeledPlacesRef: import("vue-demi").Ref<{
12
+ lng: number;
13
+ lat: number;
14
+ name: string;
15
+ displayName: string;
16
+ }[]>;
17
+ isContainBasePlaceRef: import("vue-demi").Ref<boolean>;
18
+ };
9
19
  export {};
@@ -5,7 +5,6 @@ import type { EmitFn } from "vue/types/v3-setup-context";
5
5
  import type { EmitByProps } from "../types/helper";
6
6
  export declare const deepCompareEqualsForMaps: import("fast-equals").EqualityComparator;
7
7
  export declare function createDeepCompareMemoize<T>(): (value: T) => T;
8
- export declare function useDeepCompareEffectForMaps(callback: () => () => any, dependencies: any[]): void;
9
8
  export declare function watchNoneImmediatePostEffectForDeepOption<T>(getOption: () => T, callback: WatchCallback<T, T>, watchOptions?: WatchOptions<false>): import("vue-demi").WatchStopHandle;
10
9
  export declare function watchPostEffectForDeepOption<T>(getOption: () => T, callback: WatchCallback<T, T | undefined>, watchOptions?: WatchOptions<true>): import("vue-demi").WatchStopHandle;
11
10
  export declare function watchEffectForDeepOption<T>(getOption: () => T, callback: WatchCallback<T, T | undefined>, watchOptions?: WatchOptions<true>): import("vue-demi").WatchStopHandle;
@@ -3,3 +3,4 @@ export declare const isPlace: (place: Partial<Place>) => place is Place;
3
3
  export declare const sleep: (milliSeconds: number) => Promise<unknown>;
4
4
  export declare const assertPoint: (point: unknown) => void;
5
5
  export declare const assertAngle: (angle: unknown) => void;
6
+ export declare const isLatLngLiteral: (value: any) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.8.3",
3
+ "version": "0.8.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",