@heycar/heycars-map 2.9.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -4
- package/dist/v2/App.js +5 -3
- package/dist/v2/Demo/DemoBusinessRecomendPlace.js +4 -1
- package/dist/v2/Demo/DemoBusinessReselectPlace.js +4 -1
- package/dist/v2/api/googleRoutes.d.ts +27 -0
- package/dist/v2/api/googleRoutes.js +135 -0
- package/dist/v2/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.d.ts +3 -0
- package/dist/v2/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +6 -1
- package/dist/v2/business-components/AbsoluteAddressBox/AbsoluteAddressBox.js +24 -14
- package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +4 -1
- package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
- package/dist/v2/components/MapProvider/MapProvider.js +1 -1
- package/dist/v2/css/{AbsoluteAddressBox-ea4f4761.css → AbsoluteAddressBox-7502ed45.css} +31 -6
- package/dist/v2/hooks/useDrivingRoute.js +4 -4
- package/dist/v2/hooks/useMapSupplier.d.ts +1 -0
- package/dist/v2/hooks/useWalkingRoute.js +4 -4
- package/dist/v2/utils/compatibleDrivingRoute.d.ts +1 -0
- package/dist/v2/utils/compatibleDrivingRoute.js +47 -1
- package/dist/v2/utils/compatibleWalkingRoute.d.ts +1 -0
- package/dist/v2/utils/compatibleWalkingRoute.js +29 -1
- package/dist/v2/utils/log.js +1 -1
- package/dist/v3/App.js +5 -3
- package/dist/v3/Demo/DemoBusinessRecomendPlace.js +4 -1
- package/dist/v3/Demo/DemoBusinessReselectPlace.js +4 -1
- package/dist/v3/api/googleRoutes.d.ts +27 -0
- package/dist/v3/api/googleRoutes.js +135 -0
- package/dist/v3/business-components/AbsoluteAddressBox/AbsoluteAddressBox.css.d.ts +3 -0
- package/dist/v3/business-components/AbsoluteAddressBox/AbsoluteAddressBox.d.ts +6 -1
- package/dist/v3/business-components/AbsoluteAddressBox/AbsoluteAddressBox.js +22 -14
- package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.d.ts +4 -3
- package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.d.ts +0 -2
- package/dist/v3/components/MapProvider/MapProvider.d.ts +1 -1
- package/dist/v3/components/MapProvider/MapProvider.js +1 -1
- package/dist/v3/css/{AbsoluteAddressBox-ea4f4761.css → AbsoluteAddressBox-7502ed45.css} +31 -6
- package/dist/v3/hooks/useDrivingRoute.js +4 -4
- package/dist/v3/hooks/useMapSupplier.d.ts +1 -0
- package/dist/v3/hooks/useWalkingRoute.js +4 -4
- package/dist/v3/utils/compatibleDrivingRoute.d.ts +1 -0
- package/dist/v3/utils/compatibleDrivingRoute.js +47 -1
- package/dist/v3/utils/compatibleWalkingRoute.d.ts +1 -0
- package/dist/v3/utils/compatibleWalkingRoute.js +29 -1
- package/dist/v3/utils/log.js +1 -1
- package/package.json +2 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
|
|
2
2
|
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
3
|
+
import { apiGoogleRoutes } from "../api/googleRoutes.js";
|
|
3
4
|
import { amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
|
|
4
5
|
const amapTmcs2trafficJams = (tmcs) => {
|
|
5
6
|
const trafficJams = {};
|
|
@@ -150,7 +151,7 @@ function gmapJsApiDrivingRoute(from, to, gmapDirectionsService) {
|
|
|
150
151
|
);
|
|
151
152
|
});
|
|
152
153
|
}
|
|
153
|
-
async function
|
|
154
|
+
async function googleServiceApiDrivingDirection(from, to, proxyUrl) {
|
|
154
155
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
155
156
|
const { status, routes, error_message } = await apiGoogleDirections({
|
|
156
157
|
proxyUrl,
|
|
@@ -188,9 +189,54 @@ async function googleServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
|
188
189
|
throw Error(error_message != null ? error_message : status);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
192
|
+
async function googleServiceApiDrivingRoute(from, to, proxyUrl) {
|
|
193
|
+
var _a, _b, _c, _d, _e;
|
|
194
|
+
const { routes } = await apiGoogleRoutes({
|
|
195
|
+
proxyUrl,
|
|
196
|
+
origin: {
|
|
197
|
+
location: {
|
|
198
|
+
latLng: {
|
|
199
|
+
latitude: from[1],
|
|
200
|
+
longitude: from[0]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
destination: {
|
|
205
|
+
location: {
|
|
206
|
+
latLng: {
|
|
207
|
+
latitude: to[1],
|
|
208
|
+
longitude: to[0]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
const firstRoute = routes == null ? void 0 : routes[0];
|
|
214
|
+
if (!firstRoute)
|
|
215
|
+
return { path: [], distance: 0, duration: 0, steps: [] };
|
|
216
|
+
let path = [];
|
|
217
|
+
let distance = 0;
|
|
218
|
+
let duration = 0;
|
|
219
|
+
const routeSteps = [];
|
|
220
|
+
for (const leg of firstRoute.legs) {
|
|
221
|
+
distance += (_a = leg.distanceMeters) != null ? _a : 0;
|
|
222
|
+
duration += (_b = leg.durationSeconds) != null ? _b : 0;
|
|
223
|
+
const staticRatio = leg.staticDurationSeconds ? ((_c = leg.durationSeconds) != null ? _c : 0) / leg.staticDurationSeconds : 1;
|
|
224
|
+
for (const step of leg.steps) {
|
|
225
|
+
const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
|
|
226
|
+
path = path.concat(stepPath);
|
|
227
|
+
routeSteps.push({
|
|
228
|
+
path: stepPath,
|
|
229
|
+
distance: (_d = step.distanceMeters) != null ? _d : 0,
|
|
230
|
+
duration: ((_e = step.staticDurationSeconds) != null ? _e : 0) * staticRatio
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return { path, distance, duration, steps: routeSteps };
|
|
235
|
+
}
|
|
191
236
|
export {
|
|
192
237
|
amapJsApiDrivingRoute,
|
|
193
238
|
gaodeServiceApiDrivingRoute,
|
|
194
239
|
gmapJsApiDrivingRoute,
|
|
240
|
+
googleServiceApiDrivingDirection,
|
|
195
241
|
googleServiceApiDrivingRoute
|
|
196
242
|
};
|
|
@@ -3,4 +3,5 @@ import type { Point } from "../types/interface";
|
|
|
3
3
|
export declare function amapJsApiWalkingRoute(from: Point, to: Point, amapWalking: AMap.Walking): Promise<Point[]>;
|
|
4
4
|
export declare function gaodeServiceApiWalkingRoute(from: Point, to: Point, proxyUrl: string): Promise<Point[]>;
|
|
5
5
|
export declare function gmapJsApiWalkingRoute(from: Point, to: Point, gmapDirectionsService: google.maps.DirectionsService): Promise<Point[]>;
|
|
6
|
+
export declare function googleServiceApiWalkingDirection(from: Point, to: Point, proxyUrl: string): Promise<Point[]>;
|
|
6
7
|
export declare function googleServiceApiWalkingRoute(from: Point, to: Point, proxyUrl: string): Promise<Point[]>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { apiGaodeDirectionWalking } from "../api/gaodeDirectionWalking.js";
|
|
2
2
|
import { apiGoogleDirections } from "../api/googleDirections.js";
|
|
3
|
+
import { apiGoogleRoutes } from "../api/googleRoutes.js";
|
|
3
4
|
const isIgnoredAmapTimeoutError = (err) => err === "RETURN_TIMEOUT";
|
|
4
5
|
function amapJsApiWalkingRoute(from, to, amapWalking) {
|
|
5
6
|
return new Promise((resolve, reject) => {
|
|
@@ -79,7 +80,7 @@ function gmapJsApiWalkingRoute(from, to, gmapDirectionsService) {
|
|
|
79
80
|
);
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
|
-
async function
|
|
83
|
+
async function googleServiceApiWalkingDirection(from, to, proxyUrl) {
|
|
83
84
|
const { status, routes, error_message } = await apiGoogleDirections({
|
|
84
85
|
proxyUrl,
|
|
85
86
|
mode: "WALKING",
|
|
@@ -99,9 +100,36 @@ async function googleServiceApiWalkingRoute(from, to, proxyUrl) {
|
|
|
99
100
|
throw Error(error_message != null ? error_message : status);
|
|
100
101
|
}
|
|
101
102
|
}
|
|
103
|
+
async function googleServiceApiWalkingRoute(from, to, proxyUrl) {
|
|
104
|
+
const { routes } = await apiGoogleRoutes({
|
|
105
|
+
proxyUrl,
|
|
106
|
+
origin: {
|
|
107
|
+
location: {
|
|
108
|
+
latLng: {
|
|
109
|
+
latitude: from[1],
|
|
110
|
+
longitude: from[0]
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
destination: {
|
|
115
|
+
location: {
|
|
116
|
+
latLng: {
|
|
117
|
+
latitude: to[1],
|
|
118
|
+
longitude: to[0]
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
const firstRoute = routes == null ? void 0 : routes[0];
|
|
124
|
+
if (!firstRoute)
|
|
125
|
+
return [];
|
|
126
|
+
const path = firstRoute.path.map(({ lng, lat }) => [lng(), lat()]);
|
|
127
|
+
return path;
|
|
128
|
+
}
|
|
102
129
|
export {
|
|
103
130
|
amapJsApiWalkingRoute,
|
|
104
131
|
gaodeServiceApiWalkingRoute,
|
|
105
132
|
gmapJsApiWalkingRoute,
|
|
133
|
+
googleServiceApiWalkingDirection,
|
|
106
134
|
googleServiceApiWalkingRoute
|
|
107
135
|
};
|
package/dist/v3/utils/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const availableLogKeys = /* @__PURE__ */ new Set();
|
|
2
2
|
const pkgName = "@heycar/heycars-map";
|
|
3
|
-
const pkgVersion = "2.
|
|
3
|
+
const pkgVersion = "2.11.0";
|
|
4
4
|
const isEnableLog = (name) => {
|
|
5
5
|
const searchParam = new URLSearchParams(location.search);
|
|
6
6
|
return searchParam.has(`log-${name}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heycar/heycars-map",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"checkVersion": "./bin/checkVersion.js",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
+
"@googlemaps/routing": "^2.0.1",
|
|
65
66
|
"@types/semver": "^7.5.1",
|
|
66
67
|
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
67
68
|
"@typescript-eslint/parser": "^6.17.0",
|