@heycar/heycars-map 0.9.23-alpha7 → 0.9.23-alpha8
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 +30 -20
- package/dist/index.js +30 -20
- package/dist/src/hooks/usePlacesLabelDirection.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -19,7 +19,7 @@ if (typeof GeolocationPositionError === "undefined") {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
const name = "@heycar/heycars-map";
|
|
22
|
-
const version = "0.9.23-
|
|
22
|
+
const version = "0.9.23-alpha8";
|
|
23
23
|
const type = "module";
|
|
24
24
|
const bin = {
|
|
25
25
|
checkVersion: "./bin/checkVersion.js"
|
|
@@ -8033,13 +8033,13 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
|
|
|
8033
8033
|
};
|
|
8034
8034
|
});
|
|
8035
8035
|
const usePointsLabelDirection = (props) => {
|
|
8036
|
-
const { widthLimit,
|
|
8036
|
+
const { widthLimit, getHeightLimit } = props;
|
|
8037
8037
|
const mapRef = useMap();
|
|
8038
8038
|
const { apiMapLngLatToVw } = useMapLngLatToVw({ mapRef });
|
|
8039
8039
|
const { zoomRef } = useMapZoom({ mapRef });
|
|
8040
8040
|
const diffVw = (from, to) => {
|
|
8041
|
-
const [x1, y1] = apiMapLngLatToVw(from);
|
|
8042
|
-
const [x2, y2] = apiMapLngLatToVw(to);
|
|
8041
|
+
const [x1, y1] = apiMapLngLatToVw(lnglat2point(from));
|
|
8042
|
+
const [x2, y2] = apiMapLngLatToVw(lnglat2point(to));
|
|
8043
8043
|
return [x2 - x1, y2 - y1];
|
|
8044
8044
|
};
|
|
8045
8045
|
const directionsRef = Vue.ref([]);
|
|
@@ -8062,14 +8062,14 @@ const usePointsLabelDirection = (props) => {
|
|
|
8062
8062
|
basePlace,
|
|
8063
8063
|
sortedPlaces,
|
|
8064
8064
|
widthLimit,
|
|
8065
|
-
|
|
8066
|
-
|
|
8065
|
+
getHeightLimit,
|
|
8066
|
+
placeDistanceFn: diffVw
|
|
8067
8067
|
});
|
|
8068
8068
|
const directions = createLabelDirections({
|
|
8069
|
-
|
|
8069
|
+
sortedPlaces: noOverlapPlaces,
|
|
8070
8070
|
widthLimit,
|
|
8071
|
-
|
|
8072
|
-
|
|
8071
|
+
getHeightLimit,
|
|
8072
|
+
placeDistanceFn: diffVw
|
|
8073
8073
|
});
|
|
8074
8074
|
directionsRef.value = directions;
|
|
8075
8075
|
labeledPlacesRef.value = noOverlapPlaces;
|
|
@@ -8078,8 +8078,8 @@ const usePointsLabelDirection = (props) => {
|
|
|
8078
8078
|
return { directionsRef, labeledPlacesRef, isContainBasePlaceRef };
|
|
8079
8079
|
};
|
|
8080
8080
|
function createLabelDirections(props) {
|
|
8081
|
-
const {
|
|
8082
|
-
const len =
|
|
8081
|
+
const { sortedPlaces, widthLimit, getHeightLimit, placeDistanceFn } = props;
|
|
8082
|
+
const len = sortedPlaces.length;
|
|
8083
8083
|
const result = [];
|
|
8084
8084
|
const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2, isNextLimited, dx) => {
|
|
8085
8085
|
spaceLog(
|
|
@@ -8119,16 +8119,18 @@ function createLabelDirections(props) {
|
|
|
8119
8119
|
continue;
|
|
8120
8120
|
}
|
|
8121
8121
|
if (idx === 0) {
|
|
8122
|
-
const [dx2, dy2] =
|
|
8123
|
-
|
|
8124
|
-
|
|
8122
|
+
const [dx2, dy2] = placeDistanceFn(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8123
|
+
const heightLimit2 = getHeightLimit(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8124
|
+
isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit2 && dy2 < heightLimit2;
|
|
8125
|
+
isDoubleLimited = dx2 > -widthLimit * 2 && dx2 < widthLimit * 2 && dy2 > -heightLimit2 && dy2 < heightLimit2;
|
|
8125
8126
|
const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
|
|
8126
8127
|
result.push(direction2);
|
|
8127
8128
|
prevDirection = direction2;
|
|
8128
8129
|
prevDx = dx2;
|
|
8129
8130
|
continue;
|
|
8130
8131
|
}
|
|
8131
|
-
const [dx, dy] =
|
|
8132
|
+
const [dx, dy] = placeDistanceFn(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8133
|
+
const heightLimit = getHeightLimit(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8132
8134
|
const isNextLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
|
|
8133
8135
|
const direction = calcDirection(
|
|
8134
8136
|
isLimited,
|
|
@@ -8147,9 +8149,10 @@ function createLabelDirections(props) {
|
|
|
8147
8149
|
return result;
|
|
8148
8150
|
}
|
|
8149
8151
|
function filterNoOverlapPlaces(props) {
|
|
8150
|
-
const { basePlace, sortedPlaces, widthLimit,
|
|
8152
|
+
const { basePlace, sortedPlaces, widthLimit, getHeightLimit, placeDistanceFn } = props;
|
|
8151
8153
|
const measureOverlap = (place1, place2) => {
|
|
8152
|
-
const [dx, dy] =
|
|
8154
|
+
const [dx, dy] = placeDistanceFn(place1, place2);
|
|
8155
|
+
const heightLimit = getHeightLimit(place1, place2);
|
|
8153
8156
|
const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
|
|
8154
8157
|
spaceLog(
|
|
8155
8158
|
"filterNoOverlapPlaces",
|
|
@@ -8166,7 +8169,7 @@ function filterNoOverlapPlaces(props) {
|
|
|
8166
8169
|
let overlapPlaces = findRelation(nextPlaces, measureOverlap);
|
|
8167
8170
|
while (overlapPlaces.length > 0) {
|
|
8168
8171
|
const maxPlace = findMax(overlapPlaces, (place) => {
|
|
8169
|
-
const [dx, dy] =
|
|
8172
|
+
const [dx, dy] = placeDistanceFn(place, basePlace);
|
|
8170
8173
|
return dx * dx + dy * dy;
|
|
8171
8174
|
});
|
|
8172
8175
|
nextPlaces = nextPlaces.filter((place) => !isPlaceEqual(maxPlace, place));
|
|
@@ -8376,6 +8379,9 @@ const PlaceCircle = defineSetup(function PlaceCircle2(props, {
|
|
|
8376
8379
|
});
|
|
8377
8380
|
};
|
|
8378
8381
|
});
|
|
8382
|
+
const REGULAR_PLACE_WIDTH_LIMIT = 34;
|
|
8383
|
+
const REGULAR_PLACE_HEIGHT_LIMIT = 9;
|
|
8384
|
+
const TAGED_PLACE_HEIGHT_LIMIT = 14;
|
|
8379
8385
|
const PickupPoints = defineSetup(function PickupPoints2(props, {
|
|
8380
8386
|
emit
|
|
8381
8387
|
}) {
|
|
@@ -8385,6 +8391,10 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
|
|
|
8385
8391
|
} = useMapZoom({
|
|
8386
8392
|
mapRef
|
|
8387
8393
|
});
|
|
8394
|
+
const getHeightLimit = (place) => {
|
|
8395
|
+
var _a;
|
|
8396
|
+
return ((_a = props.renderPlaceTag) == null ? void 0 : _a.call(props, place)) ? TAGED_PLACE_HEIGHT_LIMIT : REGULAR_PLACE_HEIGHT_LIMIT;
|
|
8397
|
+
};
|
|
8388
8398
|
const {
|
|
8389
8399
|
directionsRef,
|
|
8390
8400
|
labeledPlacesRef,
|
|
@@ -8392,8 +8402,8 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
|
|
|
8392
8402
|
} = usePointsLabelDirection(Vue.reactive({
|
|
8393
8403
|
basePlace: Vue.toRef(props, "basePlace"),
|
|
8394
8404
|
places: Vue.toRef(props, "places"),
|
|
8395
|
-
|
|
8396
|
-
widthLimit:
|
|
8405
|
+
getHeightLimit,
|
|
8406
|
+
widthLimit: REGULAR_PLACE_WIDTH_LIMIT,
|
|
8397
8407
|
skip: Vue.toRef(props, "noLabel")
|
|
8398
8408
|
}));
|
|
8399
8409
|
return () => {
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ if (typeof GeolocationPositionError === "undefined") {
|
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
const name = "@heycar/heycars-map";
|
|
20
|
-
const version = "0.9.23-
|
|
20
|
+
const version = "0.9.23-alpha8";
|
|
21
21
|
const type = "module";
|
|
22
22
|
const bin = {
|
|
23
23
|
checkVersion: "./bin/checkVersion.js"
|
|
@@ -8031,13 +8031,13 @@ const ConditionalFittablePassengerCircle = defineSetup(function ConditionalFitta
|
|
|
8031
8031
|
};
|
|
8032
8032
|
});
|
|
8033
8033
|
const usePointsLabelDirection = (props) => {
|
|
8034
|
-
const { widthLimit,
|
|
8034
|
+
const { widthLimit, getHeightLimit } = props;
|
|
8035
8035
|
const mapRef = useMap();
|
|
8036
8036
|
const { apiMapLngLatToVw } = useMapLngLatToVw({ mapRef });
|
|
8037
8037
|
const { zoomRef } = useMapZoom({ mapRef });
|
|
8038
8038
|
const diffVw = (from, to) => {
|
|
8039
|
-
const [x1, y1] = apiMapLngLatToVw(from);
|
|
8040
|
-
const [x2, y2] = apiMapLngLatToVw(to);
|
|
8039
|
+
const [x1, y1] = apiMapLngLatToVw(lnglat2point(from));
|
|
8040
|
+
const [x2, y2] = apiMapLngLatToVw(lnglat2point(to));
|
|
8041
8041
|
return [x2 - x1, y2 - y1];
|
|
8042
8042
|
};
|
|
8043
8043
|
const directionsRef = ref([]);
|
|
@@ -8060,14 +8060,14 @@ const usePointsLabelDirection = (props) => {
|
|
|
8060
8060
|
basePlace,
|
|
8061
8061
|
sortedPlaces,
|
|
8062
8062
|
widthLimit,
|
|
8063
|
-
|
|
8064
|
-
|
|
8063
|
+
getHeightLimit,
|
|
8064
|
+
placeDistanceFn: diffVw
|
|
8065
8065
|
});
|
|
8066
8066
|
const directions = createLabelDirections({
|
|
8067
|
-
|
|
8067
|
+
sortedPlaces: noOverlapPlaces,
|
|
8068
8068
|
widthLimit,
|
|
8069
|
-
|
|
8070
|
-
|
|
8069
|
+
getHeightLimit,
|
|
8070
|
+
placeDistanceFn: diffVw
|
|
8071
8071
|
});
|
|
8072
8072
|
directionsRef.value = directions;
|
|
8073
8073
|
labeledPlacesRef.value = noOverlapPlaces;
|
|
@@ -8076,8 +8076,8 @@ const usePointsLabelDirection = (props) => {
|
|
|
8076
8076
|
return { directionsRef, labeledPlacesRef, isContainBasePlaceRef };
|
|
8077
8077
|
};
|
|
8078
8078
|
function createLabelDirections(props) {
|
|
8079
|
-
const {
|
|
8080
|
-
const len =
|
|
8079
|
+
const { sortedPlaces, widthLimit, getHeightLimit, placeDistanceFn } = props;
|
|
8080
|
+
const len = sortedPlaces.length;
|
|
8081
8081
|
const result = [];
|
|
8082
8082
|
const calcDirection = (isLimited2, isDoubleLimited2, prevDx2, prevDirection2, isNextLimited, dx) => {
|
|
8083
8083
|
spaceLog(
|
|
@@ -8117,16 +8117,18 @@ function createLabelDirections(props) {
|
|
|
8117
8117
|
continue;
|
|
8118
8118
|
}
|
|
8119
8119
|
if (idx === 0) {
|
|
8120
|
-
const [dx2, dy2] =
|
|
8121
|
-
|
|
8122
|
-
|
|
8120
|
+
const [dx2, dy2] = placeDistanceFn(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8121
|
+
const heightLimit2 = getHeightLimit(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8122
|
+
isLimited = dx2 > -widthLimit && dx2 < widthLimit && dy2 > -heightLimit2 && dy2 < heightLimit2;
|
|
8123
|
+
isDoubleLimited = dx2 > -widthLimit * 2 && dx2 < widthLimit * 2 && dy2 > -heightLimit2 && dy2 < heightLimit2;
|
|
8123
8124
|
const direction2 = !isLimited ? "right" : dx2 > 0 ? "left" : "right";
|
|
8124
8125
|
result.push(direction2);
|
|
8125
8126
|
prevDirection = direction2;
|
|
8126
8127
|
prevDx = dx2;
|
|
8127
8128
|
continue;
|
|
8128
8129
|
}
|
|
8129
|
-
const [dx, dy] =
|
|
8130
|
+
const [dx, dy] = placeDistanceFn(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8131
|
+
const heightLimit = getHeightLimit(sortedPlaces[idx], sortedPlaces[idx + 1]);
|
|
8130
8132
|
const isNextLimited = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
|
|
8131
8133
|
const direction = calcDirection(
|
|
8132
8134
|
isLimited,
|
|
@@ -8145,9 +8147,10 @@ function createLabelDirections(props) {
|
|
|
8145
8147
|
return result;
|
|
8146
8148
|
}
|
|
8147
8149
|
function filterNoOverlapPlaces(props) {
|
|
8148
|
-
const { basePlace, sortedPlaces, widthLimit,
|
|
8150
|
+
const { basePlace, sortedPlaces, widthLimit, getHeightLimit, placeDistanceFn } = props;
|
|
8149
8151
|
const measureOverlap = (place1, place2) => {
|
|
8150
|
-
const [dx, dy] =
|
|
8152
|
+
const [dx, dy] = placeDistanceFn(place1, place2);
|
|
8153
|
+
const heightLimit = getHeightLimit(place1, place2);
|
|
8151
8154
|
const isOverlap = dx > -widthLimit && dx < widthLimit && dy > -heightLimit && dy < heightLimit;
|
|
8152
8155
|
spaceLog(
|
|
8153
8156
|
"filterNoOverlapPlaces",
|
|
@@ -8164,7 +8167,7 @@ function filterNoOverlapPlaces(props) {
|
|
|
8164
8167
|
let overlapPlaces = findRelation(nextPlaces, measureOverlap);
|
|
8165
8168
|
while (overlapPlaces.length > 0) {
|
|
8166
8169
|
const maxPlace = findMax(overlapPlaces, (place) => {
|
|
8167
|
-
const [dx, dy] =
|
|
8170
|
+
const [dx, dy] = placeDistanceFn(place, basePlace);
|
|
8168
8171
|
return dx * dx + dy * dy;
|
|
8169
8172
|
});
|
|
8170
8173
|
nextPlaces = nextPlaces.filter((place) => !isPlaceEqual(maxPlace, place));
|
|
@@ -8374,6 +8377,9 @@ const PlaceCircle = defineSetup(function PlaceCircle2(props, {
|
|
|
8374
8377
|
});
|
|
8375
8378
|
};
|
|
8376
8379
|
});
|
|
8380
|
+
const REGULAR_PLACE_WIDTH_LIMIT = 34;
|
|
8381
|
+
const REGULAR_PLACE_HEIGHT_LIMIT = 9;
|
|
8382
|
+
const TAGED_PLACE_HEIGHT_LIMIT = 14;
|
|
8377
8383
|
const PickupPoints = defineSetup(function PickupPoints2(props, {
|
|
8378
8384
|
emit
|
|
8379
8385
|
}) {
|
|
@@ -8383,6 +8389,10 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
|
|
|
8383
8389
|
} = useMapZoom({
|
|
8384
8390
|
mapRef
|
|
8385
8391
|
});
|
|
8392
|
+
const getHeightLimit = (place) => {
|
|
8393
|
+
var _a;
|
|
8394
|
+
return ((_a = props.renderPlaceTag) == null ? void 0 : _a.call(props, place)) ? TAGED_PLACE_HEIGHT_LIMIT : REGULAR_PLACE_HEIGHT_LIMIT;
|
|
8395
|
+
};
|
|
8386
8396
|
const {
|
|
8387
8397
|
directionsRef,
|
|
8388
8398
|
labeledPlacesRef,
|
|
@@ -8390,8 +8400,8 @@ const PickupPoints = defineSetup(function PickupPoints2(props, {
|
|
|
8390
8400
|
} = usePointsLabelDirection(reactive({
|
|
8391
8401
|
basePlace: toRef(props, "basePlace"),
|
|
8392
8402
|
places: toRef(props, "places"),
|
|
8393
|
-
|
|
8394
|
-
widthLimit:
|
|
8403
|
+
getHeightLimit,
|
|
8404
|
+
widthLimit: REGULAR_PLACE_WIDTH_LIMIT,
|
|
8395
8405
|
skip: toRef(props, "noLabel")
|
|
8396
8406
|
}));
|
|
8397
8407
|
return () => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Place } from "../types/interface";
|
|
2
2
|
export type LabelDirection = "left" | "right";
|
|
3
|
+
type GetHeightLimitFn = (p1: Place, p2: Place) => number;
|
|
3
4
|
export interface UsePointsLabelDirectionProps {
|
|
4
5
|
basePlace: Place;
|
|
5
6
|
places: Place[];
|
|
6
7
|
widthLimit: number;
|
|
7
|
-
|
|
8
|
+
getHeightLimit: GetHeightLimitFn;
|
|
8
9
|
skip: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare const usePointsLabelDirection: (props: UsePointsLabelDirectionProps) => {
|
|
@@ -17,3 +18,4 @@ export declare const usePointsLabelDirection: (props: UsePointsLabelDirectionPro
|
|
|
17
18
|
}[]>;
|
|
18
19
|
isContainBasePlaceRef: import("vue-demi").Ref<boolean>;
|
|
19
20
|
};
|
|
21
|
+
export {};
|