@heycar/heycars-map 0.8.2 → 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.2";
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;
@@ -5610,6 +5612,11 @@ const useAmapRecomendPlace = (props) => {
5610
5612
  availableRef.value = !!available;
5611
5613
  zoneRef.value = zone;
5612
5614
  placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
5615
+ return {
5616
+ inputPlace: { ...place2 },
5617
+ isInZone: !!zone,
5618
+ place: place2
5619
+ };
5613
5620
  };
5614
5621
  const updateRecommendPlace = (place2) => {
5615
5622
  setPlace(place2);
@@ -5694,6 +5701,11 @@ const useGmapRecomendPlace = (props) => {
5694
5701
  availableRef.value = !!available;
5695
5702
  zoneRef.value = zone;
5696
5703
  placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
5704
+ return {
5705
+ inputPlace: { ...place2 },
5706
+ isInZone: !!zone,
5707
+ place: place2
5708
+ };
5697
5709
  };
5698
5710
  const updateRecommendPlace = (place2) => {
5699
5711
  setPlace(place2);
@@ -5748,53 +5760,6 @@ const useMapRecomendPlace = (props) => {
5748
5760
  const { supplier } = useMapSupplier();
5749
5761
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5750
5762
  };
5751
- const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5752
- const DEFAULT_ZOOM$1 = 13;
5753
- const useAmapZoom = (props) => {
5754
- var _a, _b, _c;
5755
- const { onChange, mapRef, defaultValue } = props;
5756
- const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5757
- const setZoom = (v) => {
5758
- var _a2;
5759
- zoomRef.value = v;
5760
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5761
- };
5762
- const handleZoomEnd = (_, { target }) => {
5763
- const zoom = target.getZoom();
5764
- zoomRef.value = zoom;
5765
- onChange == null ? void 0 : onChange(zoom);
5766
- };
5767
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5768
- "onZoomEnd"
5769
- ]);
5770
- return { zoomRef, setZoom };
5771
- };
5772
- const useGmapZoom = (props) => {
5773
- var _a, _b, _c;
5774
- const { onChange, mapRef, defaultValue } = props;
5775
- const zoomRef = Vue.ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5776
- const setZoom = (v) => {
5777
- var _a2;
5778
- zoomRef.value = v;
5779
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5780
- };
5781
- const handleZoomChange = debounce(
5782
- (_, { target }) => {
5783
- const zoom = target.getZoom();
5784
- zoomRef.value = zoom;
5785
- onChange == null ? void 0 : onChange(zoom);
5786
- },
5787
- GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5788
- );
5789
- watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5790
- "onZoom_changed"
5791
- ]);
5792
- return { zoomRef, setZoom };
5793
- };
5794
- const useMapZoom = (props) => {
5795
- const { supplier } = useMapSupplier();
5796
- return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
5797
- };
5798
5763
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5799
5764
  const polygonRef = Vue.shallowRef();
5800
5765
  const mapRef = useAmap();
@@ -6057,51 +6022,211 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6057
6022
  })]);
6058
6023
  };
6059
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
+ };
6060
6088
  const reverse = (direction) => direction === "left" ? "right" : "left";
6061
6089
  const usePointsLabelDirection = (props) => {
6062
6090
  const { widthLimit, heightLimit } = props;
6063
6091
  const mapRef = useMap();
6064
6092
  const { apiMapLngLatToVw } = useMapLngLatToVw({ mapRef });
6093
+ const { zoomRef } = useMapZoom({ mapRef });
6065
6094
  const diffVw = (from, to) => {
6066
6095
  const [x1, y1] = apiMapLngLatToVw(from);
6067
6096
  const [x2, y2] = apiMapLngLatToVw(to);
6068
6097
  return [x2 - x1, y2 - y1];
6069
6098
  };
6070
- 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);
6071
6102
  watchEffectForDeepOption(
6072
- () => props.places.map(place2point),
6073
- (points) => {
6074
- const sortedPoints = points.map((point, index) => ({ point, index })).sort(
6075
- ({ 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)
6076
6129
  );
6077
- const len = points.length;
6078
- const result = Array(len);
6079
- let prevDirection = "right";
6080
- let isLimited = false;
6081
- for (let idx = 0; idx < len; idx++) {
6082
- const { index } = sortedPoints[idx];
6083
- if (idx === len - 1) {
6084
- result[index] = isLimited ? reverse(prevDirection) : "right";
6085
- continue;
6086
- }
6087
- if (idx === 0) {
6088
- const [dx2, dy2] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6089
- isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6090
- const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6091
- result[index] = direction2;
6092
- prevDirection = direction2;
6093
- continue;
6094
- }
6095
- const [dx, dy] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6096
- const direction = isLimited ? reverse(prevDirection) : "right";
6097
- result[index] = direction;
6098
- prevDirection = direction;
6099
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6100
- }
6101
- directionsRef.value = result;
6102
6130
  }
6103
6131
  );
6104
- 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];
6105
6230
  };
6106
6231
  var AnchorType = /* @__PURE__ */ ((AnchorType2) => {
6107
6232
  AnchorType2["topLeft"] = "top-left";
@@ -6247,18 +6372,31 @@ const PlaceCircle = defineSetup(function PlaceCircle2(props, {
6247
6372
  const PickupPoints = defineSetup(function PickupPoints2(props, {
6248
6373
  emit
6249
6374
  }) {
6375
+ const mapRef = useMap();
6250
6376
  const {
6251
- renderLabel
6252
- } = props;
6253
- 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"),
6254
6387
  places: Vue.toRef(props, "places"),
6255
6388
  heightLimit: 9,
6256
6389
  widthLimit: 32
6257
6390
  }));
6258
6391
  return () => {
6259
- return Vue.h("div", [props.places.map((place, idx) => {
6260
- const direction = directions.value[idx];
6261
- 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;
6262
6400
  return Vue.h(PlaceCircle, {
6263
6401
  "attrs": {
6264
6402
  "position": place2point(place),
@@ -6269,12 +6407,17 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
6269
6407
  "click": () => emit("click", place)
6270
6408
  }
6271
6409
  });
6410
+ }), isContainBasePlaceRef.value && Vue.h(PlaceCircle, {
6411
+ "attrs": {
6412
+ "position": place2point(basePlace)
6413
+ }
6272
6414
  })]);
6273
6415
  };
6274
6416
  });
6275
6417
  const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6276
6418
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6277
- const RECOMMEND_PLACE_ZOOM_MIN = 13;
6419
+ const RECOMMEND_PLACE_ICON_ZOOM_MIN = 15.75;
6420
+ const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.75;
6278
6421
  const DEFAULT_PLACE_NAME = "当前位置";
6279
6422
  const DEFAULT_ZOOM = 17;
6280
6423
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
@@ -6299,12 +6442,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6299
6442
  const {
6300
6443
  readyPromise
6301
6444
  } = useMapSupplier();
6302
- const {
6303
- zoomRef
6304
- } = useMapZoom({
6305
- mapRef,
6306
- defaultValue: DEFAULT_ZOOM
6307
- });
6308
6445
  const centerPlace = Vue.reactive({
6309
6446
  lng: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _a : 0,
6310
6447
  lat: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _b : 0,
@@ -6481,13 +6618,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6481
6618
  recomendDescription,
6482
6619
  unavailableTitle
6483
6620
  } = props;
6484
- console.log("centerPlace = ", JSON.stringify(centerPlace));
6485
6621
  const title = geoLoading.value ? geoLoadingTitle2 : !availableRef.value ? unavailableTitle : centerPlace.displayName;
6486
6622
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
6487
6623
  return Vue.h(HeycarMap, {
6488
6624
  "attrs": {
6489
6625
  "center": centerPoint.value,
6490
- "zoom": zoomRef.value,
6626
+ "zoom": DEFAULT_ZOOM,
6491
6627
  "touchZoomCenter": true,
6492
6628
  "mapRef": setMap,
6493
6629
  "fallback": slots.fallback,
@@ -6502,10 +6638,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6502
6638
  "position": geoPosition.value,
6503
6639
  "angle": orientation.cssRotationVariableName
6504
6640
  }
6505
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && Vue.h(PickupPoints, {
6641
+ }), Vue.h(PickupPoints, {
6506
6642
  "attrs": {
6643
+ "basePlace": centerPlace,
6507
6644
  "places": placeCandidates.value,
6508
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6645
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6646
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6509
6647
  },
6510
6648
  "on": {
6511
6649
  "click": panToCenterByPlace
@@ -6547,12 +6685,6 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6547
6685
  setMap,
6548
6686
  panTo
6549
6687
  } = useHeycarMap();
6550
- const {
6551
- zoomRef
6552
- } = useMapZoom({
6553
- mapRef,
6554
- defaultValue: DEFAULT_ZOOM
6555
- });
6556
6688
  const centerPlace = Vue.reactive({
6557
6689
  lng: defaultPlace.lng,
6558
6690
  lat: defaultPlace.lat,
@@ -6693,7 +6825,10 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6693
6825
  });
6694
6826
  }
6695
6827
  });
6696
- watchPostEffectOnce(() => updatePlaceCandidates(defaultPlace));
6828
+ watchPostEffectOnce(async () => {
6829
+ const value = await updatePlaceCandidates(defaultPlace);
6830
+ emit("changeRecomandPlace", value);
6831
+ });
6697
6832
  Vue.watchEffect(() => {
6698
6833
  mapContext.onChangeCenterPlace({
6699
6834
  ...centerPlace
@@ -6713,7 +6848,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6713
6848
  return Vue.h(HeycarMap, {
6714
6849
  "attrs": {
6715
6850
  "center": centerPoint.value,
6716
- "zoom": zoomRef.value,
6851
+ "zoom": DEFAULT_ZOOM,
6717
6852
  "touchZoomCenter": true,
6718
6853
  "mapRef": setMap,
6719
6854
  "fallback": slots.fallback,
@@ -6728,10 +6863,12 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6728
6863
  "position": geoPosition.value,
6729
6864
  "angle": orientation.cssRotationVariableName
6730
6865
  }
6731
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && Vue.h(PickupPoints, {
6866
+ }), Vue.h(PickupPoints, {
6732
6867
  "attrs": {
6868
+ "basePlace": centerPlace,
6733
6869
  "places": placeCandidates.value,
6734
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6870
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6871
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6735
6872
  },
6736
6873
  "on": {
6737
6874
  "click": panToCenterByPlace
@@ -7903,7 +8040,6 @@ const useBusinessTaxiServiceMap = () => {
7903
8040
  const { mapRef, setMap } = useHeycarMap();
7904
8041
  const { registerFitVeiw, setFitView } = useMapFitView({
7905
8042
  mapRef,
7906
- autoFitTimeout: 5e3,
7907
8043
  padding: [19, 36, 19, 26]
7908
8044
  });
7909
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.2";
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;
@@ -5608,6 +5610,11 @@ const useAmapRecomendPlace = (props) => {
5608
5610
  availableRef.value = !!available;
5609
5611
  zoneRef.value = zone;
5610
5612
  placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
5613
+ return {
5614
+ inputPlace: { ...place2 },
5615
+ isInZone: !!zone,
5616
+ place: place2
5617
+ };
5611
5618
  };
5612
5619
  const updateRecommendPlace = (place2) => {
5613
5620
  setPlace(place2);
@@ -5692,6 +5699,11 @@ const useGmapRecomendPlace = (props) => {
5692
5699
  availableRef.value = !!available;
5693
5700
  zoneRef.value = zone;
5694
5701
  placeCandidatesRef.value = placeCandidates != null ? placeCandidates : [];
5702
+ return {
5703
+ inputPlace: { ...place2 },
5704
+ isInZone: !!zone,
5705
+ place: place2
5706
+ };
5695
5707
  };
5696
5708
  const updateRecommendPlace = (place2) => {
5697
5709
  setPlace(place2);
@@ -5746,53 +5758,6 @@ const useMapRecomendPlace = (props) => {
5746
5758
  const { supplier } = useMapSupplier();
5747
5759
  return supplier === "gmap" ? useGmapRecomendPlace(props) : useAmapRecomendPlace(props);
5748
5760
  };
5749
- const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 50;
5750
- const DEFAULT_ZOOM$1 = 13;
5751
- const useAmapZoom = (props) => {
5752
- var _a, _b, _c;
5753
- const { onChange, mapRef, defaultValue } = props;
5754
- const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5755
- const setZoom = (v) => {
5756
- var _a2;
5757
- zoomRef.value = v;
5758
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v, true);
5759
- };
5760
- const handleZoomEnd = (_, { target }) => {
5761
- const zoom = target.getZoom();
5762
- zoomRef.value = zoom;
5763
- onChange == null ? void 0 : onChange(zoom);
5764
- };
5765
- watchPostEffectForAMapEvent(mapRef, {}, handleZoomEnd, [
5766
- "onZoomEnd"
5767
- ]);
5768
- return { zoomRef, setZoom };
5769
- };
5770
- const useGmapZoom = (props) => {
5771
- var _a, _b, _c;
5772
- const { onChange, mapRef, defaultValue } = props;
5773
- const zoomRef = ref((_c = (_b = (_a = mapRef.value) == null ? void 0 : _a.getZoom()) != null ? _b : defaultValue) != null ? _c : DEFAULT_ZOOM$1);
5774
- const setZoom = (v) => {
5775
- var _a2;
5776
- zoomRef.value = v;
5777
- (_a2 = mapRef.value) == null ? void 0 : _a2.setZoom(v);
5778
- };
5779
- const handleZoomChange = debounce(
5780
- (_, { target }) => {
5781
- const zoom = target.getZoom();
5782
- zoomRef.value = zoom;
5783
- onChange == null ? void 0 : onChange(zoom);
5784
- },
5785
- GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT
5786
- );
5787
- watchPostEffectForGMapEvent(mapRef, {}, handleZoomChange, [
5788
- "onZoom_changed"
5789
- ]);
5790
- return { zoomRef, setZoom };
5791
- };
5792
- const useMapZoom = (props) => {
5793
- const { supplier } = useMapSupplier();
5794
- return supplier === "gmap" ? useGmapZoom(props) : useAmapZoom(props);
5795
- };
5796
5761
  const AmapPolygon = defineSetup(function AmapPolygon2(props) {
5797
5762
  const polygonRef = shallowRef();
5798
5763
  const mapRef = useAmap();
@@ -6055,51 +6020,211 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
6055
6020
  })]);
6056
6021
  };
6057
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
+ };
6058
6086
  const reverse = (direction) => direction === "left" ? "right" : "left";
6059
6087
  const usePointsLabelDirection = (props) => {
6060
6088
  const { widthLimit, heightLimit } = props;
6061
6089
  const mapRef = useMap();
6062
6090
  const { apiMapLngLatToVw } = useMapLngLatToVw({ mapRef });
6091
+ const { zoomRef } = useMapZoom({ mapRef });
6063
6092
  const diffVw = (from, to) => {
6064
6093
  const [x1, y1] = apiMapLngLatToVw(from);
6065
6094
  const [x2, y2] = apiMapLngLatToVw(to);
6066
6095
  return [x2 - x1, y2 - y1];
6067
6096
  };
6068
- const directionsRef = ref(Array(props.places.length).fill("right"));
6097
+ const directionsRef = ref([]);
6098
+ const labeledPlacesRef = ref([]);
6099
+ const isContainBasePlaceRef = ref(false);
6069
6100
  watchEffectForDeepOption(
6070
- () => props.places.map(place2point),
6071
- (points) => {
6072
- const sortedPoints = points.map((point, index) => ({ point, index })).sort(
6073
- ({ 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)
6074
6127
  );
6075
- const len = points.length;
6076
- const result = Array(len);
6077
- let prevDirection = "right";
6078
- let isLimited = false;
6079
- for (let idx = 0; idx < len; idx++) {
6080
- const { index } = sortedPoints[idx];
6081
- if (idx === len - 1) {
6082
- result[index] = isLimited ? reverse(prevDirection) : "right";
6083
- continue;
6084
- }
6085
- if (idx === 0) {
6086
- const [dx2, dy2] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6087
- isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit && dy2 < heightLimit;
6088
- const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
6089
- result[index] = direction2;
6090
- prevDirection = direction2;
6091
- continue;
6092
- }
6093
- const [dx, dy] = diffVw(sortedPoints[idx].point, sortedPoints[idx + 1].point);
6094
- const direction = isLimited ? reverse(prevDirection) : "right";
6095
- result[index] = direction;
6096
- prevDirection = direction;
6097
- isLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
6098
- }
6099
- directionsRef.value = result;
6100
6128
  }
6101
6129
  );
6102
- 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];
6103
6228
  };
6104
6229
  var AnchorType = /* @__PURE__ */ ((AnchorType2) => {
6105
6230
  AnchorType2["topLeft"] = "top-left";
@@ -6245,18 +6370,31 @@ const PlaceCircle = defineSetup(function PlaceCircle2(props, {
6245
6370
  const PickupPoints = defineSetup(function PickupPoints2(props, {
6246
6371
  emit
6247
6372
  }) {
6373
+ const mapRef = useMap();
6248
6374
  const {
6249
- renderLabel
6250
- } = props;
6251
- 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"),
6252
6385
  places: toRef(props, "places"),
6253
6386
  heightLimit: 9,
6254
6387
  widthLimit: 32
6255
6388
  }));
6256
6389
  return () => {
6257
- return h("div", [props.places.map((place, idx) => {
6258
- const direction = directions.value[idx];
6259
- 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;
6260
6398
  return h(PlaceCircle, {
6261
6399
  "attrs": {
6262
6400
  "position": place2point(place),
@@ -6267,12 +6405,17 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
6267
6405
  "click": () => emit("click", place)
6268
6406
  }
6269
6407
  });
6408
+ }), isContainBasePlaceRef.value && h(PlaceCircle, {
6409
+ "attrs": {
6410
+ "position": place2point(basePlace)
6411
+ }
6270
6412
  })]);
6271
6413
  };
6272
6414
  });
6273
6415
  const RECOMMEND_PLACE_DRAG_LIMIT = 10;
6274
6416
  const RECOMMEND_PLACE_LARGE_LIMIT = 100;
6275
- const RECOMMEND_PLACE_ZOOM_MIN = 13;
6417
+ const RECOMMEND_PLACE_ICON_ZOOM_MIN = 15.75;
6418
+ const RECOMMEND_PLACE_TEXT_ZOOM_MIN = 16.75;
6276
6419
  const DEFAULT_PLACE_NAME = "当前位置";
6277
6420
  const DEFAULT_ZOOM = 17;
6278
6421
  const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlaceMap2(props, {
@@ -6297,12 +6440,6 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6297
6440
  const {
6298
6441
  readyPromise
6299
6442
  } = useMapSupplier();
6300
- const {
6301
- zoomRef
6302
- } = useMapZoom({
6303
- mapRef,
6304
- defaultValue: DEFAULT_ZOOM
6305
- });
6306
6443
  const centerPlace = reactive({
6307
6444
  lng: (_a = geoDefaultPosition == null ? void 0 : geoDefaultPosition[0]) != null ? _a : 0,
6308
6445
  lat: (_b = geoDefaultPosition == null ? void 0 : geoDefaultPosition[1]) != null ? _b : 0,
@@ -6479,13 +6616,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6479
6616
  recomendDescription,
6480
6617
  unavailableTitle
6481
6618
  } = props;
6482
- console.log("centerPlace = ", JSON.stringify(centerPlace));
6483
6619
  const title = geoLoading.value ? geoLoadingTitle2 : !availableRef.value ? unavailableTitle : centerPlace.displayName;
6484
6620
  const description = !availableRef.value ? void 0 : isElectedRef.value ? recomendDescription : void 0;
6485
6621
  return h(HeycarMap, {
6486
6622
  "attrs": {
6487
6623
  "center": centerPoint.value,
6488
- "zoom": zoomRef.value,
6624
+ "zoom": DEFAULT_ZOOM,
6489
6625
  "touchZoomCenter": true,
6490
6626
  "mapRef": setMap,
6491
6627
  "fallback": slots.fallback,
@@ -6500,10 +6636,12 @@ const BusinessRecomendPlaceMap = defineLagecySetup(function BusinessRecomendPlac
6500
6636
  "position": geoPosition.value,
6501
6637
  "angle": orientation.cssRotationVariableName
6502
6638
  }
6503
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && h(PickupPoints, {
6639
+ }), h(PickupPoints, {
6504
6640
  "attrs": {
6641
+ "basePlace": centerPlace,
6505
6642
  "places": placeCandidates.value,
6506
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6643
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6644
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6507
6645
  },
6508
6646
  "on": {
6509
6647
  "click": panToCenterByPlace
@@ -6545,12 +6683,6 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6545
6683
  setMap,
6546
6684
  panTo
6547
6685
  } = useHeycarMap();
6548
- const {
6549
- zoomRef
6550
- } = useMapZoom({
6551
- mapRef,
6552
- defaultValue: DEFAULT_ZOOM
6553
- });
6554
6686
  const centerPlace = reactive({
6555
6687
  lng: defaultPlace.lng,
6556
6688
  lat: defaultPlace.lat,
@@ -6691,7 +6823,10 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6691
6823
  });
6692
6824
  }
6693
6825
  });
6694
- watchPostEffectOnce(() => updatePlaceCandidates(defaultPlace));
6826
+ watchPostEffectOnce(async () => {
6827
+ const value = await updatePlaceCandidates(defaultPlace);
6828
+ emit("changeRecomandPlace", value);
6829
+ });
6695
6830
  watchEffect(() => {
6696
6831
  mapContext.onChangeCenterPlace({
6697
6832
  ...centerPlace
@@ -6711,7 +6846,7 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6711
6846
  return h(HeycarMap, {
6712
6847
  "attrs": {
6713
6848
  "center": centerPoint.value,
6714
- "zoom": zoomRef.value,
6849
+ "zoom": DEFAULT_ZOOM,
6715
6850
  "touchZoomCenter": true,
6716
6851
  "mapRef": setMap,
6717
6852
  "fallback": slots.fallback,
@@ -6726,10 +6861,12 @@ const BusinessReselectPlaceMap = defineLagecySetup(function BusinessReselectPlac
6726
6861
  "position": geoPosition.value,
6727
6862
  "angle": orientation.cssRotationVariableName
6728
6863
  }
6729
- }), zoomRef.value >= RECOMMEND_PLACE_ZOOM_MIN && h(PickupPoints, {
6864
+ }), h(PickupPoints, {
6730
6865
  "attrs": {
6866
+ "basePlace": centerPlace,
6731
6867
  "places": placeCandidates.value,
6732
- "renderLabel": (place) => isPlaceEqual(place, centerPlace) ? void 0 : place.displayName
6868
+ "zoomIconMin": RECOMMEND_PLACE_ICON_ZOOM_MIN,
6869
+ "zoomTextMin": RECOMMEND_PLACE_TEXT_ZOOM_MIN
6733
6870
  },
6734
6871
  "on": {
6735
6872
  "click": panToCenterByPlace
@@ -7901,7 +8038,6 @@ const useBusinessTaxiServiceMap = () => {
7901
8038
  const { mapRef, setMap } = useHeycarMap();
7902
8039
  const { registerFitVeiw, setFitView } = useMapFitView({
7903
8040
  mapRef,
7904
- autoFitTimeout: 5e3,
7905
8041
  padding: [19, 36, 19, 26]
7906
8042
  });
7907
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, {}>;
@@ -32,7 +32,7 @@ export declare const useAmapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C
32
32
  availableRef: Ref<boolean>;
33
33
  isElectedRef: import("vue-demi").ComputedRef<boolean>;
34
34
  updateRecommendPlace: (place: Place) => void;
35
- updatePlaceCandidates: (place: Place) => Promise<void>;
35
+ updatePlaceCandidates: (place: Place) => Promise<ValueOfOnChangeRecommendPlace>;
36
36
  updatePlace: (value: Point) => void;
37
37
  setPlaceCandidatesAndZone: ({ zone, places: inputPlaceCandidates, }: RecommendZonePlaces) => void;
38
38
  };
@@ -53,7 +53,7 @@ export declare const useGmapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C
53
53
  availableRef: Ref<boolean>;
54
54
  isElectedRef: import("vue-demi").ComputedRef<boolean>;
55
55
  updateRecommendPlace: (place: Place) => void;
56
- updatePlaceCandidates: (place: Place) => Promise<void>;
56
+ updatePlaceCandidates: (place: Place) => Promise<ValueOfOnChangeRecommendPlace>;
57
57
  updatePlace: (value: Point) => void;
58
58
  setPlaceCandidatesAndZone: ({ zone, places }: RecommendZonePlaces) => void;
59
59
  };
@@ -74,7 +74,7 @@ export declare const useMapRecomendPlace: <C>(props: UseMapRecomendPlaceProps<C>
74
74
  availableRef: Ref<boolean>;
75
75
  isElectedRef: import("vue-demi").ComputedRef<boolean>;
76
76
  updateRecommendPlace: (place: Place) => void;
77
- updatePlaceCandidates: (place: Place) => Promise<void>;
77
+ updatePlaceCandidates: (place: Place) => Promise<ValueOfOnChangeRecommendPlace>;
78
78
  updatePlace: (value: Point) => void;
79
79
  setPlaceCandidatesAndZone: ({ zone, places }: RecommendZonePlaces) => void;
80
80
  };
@@ -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.2",
3
+ "version": "0.8.4",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",