@heycar/heycars-map 0.5.6 → 0.5.7

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.
@@ -7,10 +7,20 @@ export declare const useADrivingRoute: (props: UseDrivingRouteProps) => {
7
7
  path: [number, number][];
8
8
  distance: number;
9
9
  duration: number;
10
+ steps: {
11
+ path: [number, number][];
12
+ duration: number;
13
+ distance: number;
14
+ }[];
10
15
  };
11
16
  export declare const useGDrivingRoute: (props: UseDrivingRouteProps) => {
12
17
  path: [number, number][];
13
18
  distance: number;
14
19
  duration: number;
20
+ steps: {
21
+ path: [number, number][];
22
+ duration: number;
23
+ distance: number;
24
+ }[];
15
25
  };
16
26
  export declare const useDrivingRoute: (props: UseDrivingRouteProps) => Route;
@@ -1,10 +1,17 @@
1
- import type { Point } from "../types/interface";
1
+ import type { Point, Route } from "../types/interface";
2
2
  interface UseDrivingTrackCorrectionProps {
3
3
  track: Point[];
4
- path: Point[];
4
+ route: Route;
5
5
  onDeviation: (point: Point) => any;
6
6
  }
7
7
  export declare const useDrivingTrackCorrection: (props: UseDrivingTrackCorrectionProps) => {
8
- path: import("vue").Ref<[number, number][]>;
8
+ path: [number, number][];
9
+ distance: number;
10
+ duration: number;
11
+ steps: {
12
+ path: [number, number][];
13
+ duration: number;
14
+ distance: number;
15
+ }[];
9
16
  };
10
17
  export {};
package/dist/index.cjs CHANGED
@@ -2324,7 +2324,7 @@ const DrivingLine = defineSetup(function DrivingLine2(props) {
2324
2324
  };
2325
2325
  });
2326
2326
  const useADrivingRoute = (props) => {
2327
- const outputRoute = Vue.reactive({ path: [], distance: 0, duration: 0 });
2327
+ const outputRoute = Vue.reactive({ path: [], distance: 0, duration: 0, steps: [] });
2328
2328
  const amapDriving = new AMap.Driving({});
2329
2329
  watchPostEffectForDeepOption(
2330
2330
  () => {
@@ -2341,21 +2341,29 @@ const useADrivingRoute = (props) => {
2341
2341
  case "complete": {
2342
2342
  let path = [];
2343
2343
  const drivingResult = result;
2344
+ const routeSteps = [];
2344
2345
  const firstRoute = drivingResult.routes[0];
2345
2346
  for (const step of firstRoute.steps) {
2346
2347
  const basicStep = step;
2347
2348
  const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
2348
2349
  path = path.concat(stepPath);
2350
+ routeSteps.push({
2351
+ path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
2352
+ duration: basicStep.time,
2353
+ distance: basicStep.distance
2354
+ });
2349
2355
  }
2350
2356
  outputRoute.path = path;
2351
2357
  outputRoute.distance = firstRoute.distance;
2352
2358
  outputRoute.duration = firstRoute.time;
2359
+ outputRoute.steps = routeSteps;
2353
2360
  return;
2354
2361
  }
2355
2362
  case "no_data":
2356
2363
  outputRoute.path = [];
2357
2364
  outputRoute.distance = 0;
2358
2365
  outputRoute.duration = 0;
2366
+ outputRoute.steps = [];
2359
2367
  return;
2360
2368
  default:
2361
2369
  throw result;
@@ -2367,7 +2375,7 @@ const useADrivingRoute = (props) => {
2367
2375
  return outputRoute;
2368
2376
  };
2369
2377
  const useGDrivingRoute = (props) => {
2370
- const outputRoute = Vue.reactive({ path: [], distance: 0, duration: 0 });
2378
+ const outputRoute = Vue.reactive({ path: [], distance: 0, duration: 0, steps: [] });
2371
2379
  const gmapDirectionsService = new google.maps.DirectionsService();
2372
2380
  watchPostEffectForDeepOption(
2373
2381
  () => ({ ...props }),
@@ -2379,25 +2387,31 @@ const useGDrivingRoute = (props) => {
2379
2387
  travelMode: google.maps.TravelMode.DRIVING
2380
2388
  },
2381
2389
  (result, status) => {
2382
- var _a, _b, _c, _d;
2390
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2383
2391
  switch (status) {
2384
2392
  case google.maps.DirectionsStatus.OK: {
2385
2393
  let path = [];
2386
2394
  let distance = 0;
2387
2395
  let duration = 0;
2396
+ const routeSteps = [];
2388
2397
  const firstRoute = result.routes[0];
2389
- const stepPath = firstRoute.overview_path.map((item) => [
2390
- item.lng(),
2391
- item.lat()
2392
- ]);
2393
- path = path.concat(stepPath);
2394
2398
  for (const leg of firstRoute.legs) {
2395
2399
  distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
2396
2400
  duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
2401
+ for (const step of leg.steps) {
2402
+ const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
2403
+ path = path.concat(stepPath);
2404
+ routeSteps.push({
2405
+ path: stepPath,
2406
+ distance: (_f = (_e = step.distance) == null ? void 0 : _e.value) != null ? _f : 0,
2407
+ duration: (_h = (_g = step.duration) == null ? void 0 : _g.value) != null ? _h : 0
2408
+ });
2409
+ }
2397
2410
  }
2398
2411
  outputRoute.path = path;
2399
2412
  outputRoute.distance = distance;
2400
2413
  outputRoute.duration = duration;
2414
+ outputRoute.steps = routeSteps;
2401
2415
  return;
2402
2416
  }
2403
2417
  case google.maps.DirectionsStatus.ZERO_RESULTS:
@@ -2405,6 +2419,7 @@ const useGDrivingRoute = (props) => {
2405
2419
  outputRoute.path = [];
2406
2420
  outputRoute.distance = 0;
2407
2421
  outputRoute.duration = 0;
2422
+ outputRoute.steps = [];
2408
2423
  return;
2409
2424
  default:
2410
2425
  throw new Error(status);
@@ -3256,7 +3271,6 @@ const useAmapPlace = (props) => {
3256
3271
  const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3257
3272
  const cityParentName = addressComponent.province;
3258
3273
  const name = formattedAddress ? formattedAddress : emptyPlaceName;
3259
- console.log("geocoder.getAddress status, name, lng, lat = ", status, name, lng, lat);
3260
3274
  place.name = name;
3261
3275
  place.lng = lng;
3262
3276
  place.lat = lat;
@@ -3268,8 +3282,8 @@ const useAmapPlace = (props) => {
3268
3282
  place.name = emptyPlaceName;
3269
3283
  place.lng = lng;
3270
3284
  place.lat = lat;
3271
- console.log("geocoder.getAddress status, name, lng, lat = ", status, "", lng, lat);
3272
3285
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3286
+ onChangeCity == null ? void 0 : onChangeCity({ cityName: "", cityParentName: "", countryName: "" });
3273
3287
  return;
3274
3288
  case "error":
3275
3289
  throw result;
package/dist/index.js CHANGED
@@ -2322,7 +2322,7 @@ const DrivingLine = defineSetup(function DrivingLine2(props) {
2322
2322
  };
2323
2323
  });
2324
2324
  const useADrivingRoute = (props) => {
2325
- const outputRoute = reactive({ path: [], distance: 0, duration: 0 });
2325
+ const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [] });
2326
2326
  const amapDriving = new AMap.Driving({});
2327
2327
  watchPostEffectForDeepOption(
2328
2328
  () => {
@@ -2339,21 +2339,29 @@ const useADrivingRoute = (props) => {
2339
2339
  case "complete": {
2340
2340
  let path = [];
2341
2341
  const drivingResult = result;
2342
+ const routeSteps = [];
2342
2343
  const firstRoute = drivingResult.routes[0];
2343
2344
  for (const step of firstRoute.steps) {
2344
2345
  const basicStep = step;
2345
2346
  const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
2346
2347
  path = path.concat(stepPath);
2348
+ routeSteps.push({
2349
+ path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
2350
+ duration: basicStep.time,
2351
+ distance: basicStep.distance
2352
+ });
2347
2353
  }
2348
2354
  outputRoute.path = path;
2349
2355
  outputRoute.distance = firstRoute.distance;
2350
2356
  outputRoute.duration = firstRoute.time;
2357
+ outputRoute.steps = routeSteps;
2351
2358
  return;
2352
2359
  }
2353
2360
  case "no_data":
2354
2361
  outputRoute.path = [];
2355
2362
  outputRoute.distance = 0;
2356
2363
  outputRoute.duration = 0;
2364
+ outputRoute.steps = [];
2357
2365
  return;
2358
2366
  default:
2359
2367
  throw result;
@@ -2365,7 +2373,7 @@ const useADrivingRoute = (props) => {
2365
2373
  return outputRoute;
2366
2374
  };
2367
2375
  const useGDrivingRoute = (props) => {
2368
- const outputRoute = reactive({ path: [], distance: 0, duration: 0 });
2376
+ const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [] });
2369
2377
  const gmapDirectionsService = new google.maps.DirectionsService();
2370
2378
  watchPostEffectForDeepOption(
2371
2379
  () => ({ ...props }),
@@ -2377,25 +2385,31 @@ const useGDrivingRoute = (props) => {
2377
2385
  travelMode: google.maps.TravelMode.DRIVING
2378
2386
  },
2379
2387
  (result, status) => {
2380
- var _a, _b, _c, _d;
2388
+ var _a, _b, _c, _d, _e, _f, _g, _h;
2381
2389
  switch (status) {
2382
2390
  case google.maps.DirectionsStatus.OK: {
2383
2391
  let path = [];
2384
2392
  let distance = 0;
2385
2393
  let duration = 0;
2394
+ const routeSteps = [];
2386
2395
  const firstRoute = result.routes[0];
2387
- const stepPath = firstRoute.overview_path.map((item) => [
2388
- item.lng(),
2389
- item.lat()
2390
- ]);
2391
- path = path.concat(stepPath);
2392
2396
  for (const leg of firstRoute.legs) {
2393
2397
  distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
2394
2398
  duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
2399
+ for (const step of leg.steps) {
2400
+ const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
2401
+ path = path.concat(stepPath);
2402
+ routeSteps.push({
2403
+ path: stepPath,
2404
+ distance: (_f = (_e = step.distance) == null ? void 0 : _e.value) != null ? _f : 0,
2405
+ duration: (_h = (_g = step.duration) == null ? void 0 : _g.value) != null ? _h : 0
2406
+ });
2407
+ }
2395
2408
  }
2396
2409
  outputRoute.path = path;
2397
2410
  outputRoute.distance = distance;
2398
2411
  outputRoute.duration = duration;
2412
+ outputRoute.steps = routeSteps;
2399
2413
  return;
2400
2414
  }
2401
2415
  case google.maps.DirectionsStatus.ZERO_RESULTS:
@@ -2403,6 +2417,7 @@ const useGDrivingRoute = (props) => {
2403
2417
  outputRoute.path = [];
2404
2418
  outputRoute.distance = 0;
2405
2419
  outputRoute.duration = 0;
2420
+ outputRoute.steps = [];
2406
2421
  return;
2407
2422
  default:
2408
2423
  throw new Error(status);
@@ -3254,7 +3269,6 @@ const useAmapPlace = (props) => {
3254
3269
  const cityName = addressComponent.city ? addressComponent.city : addressComponent.province;
3255
3270
  const cityParentName = addressComponent.province;
3256
3271
  const name = formattedAddress ? formattedAddress : emptyPlaceName;
3257
- console.log("geocoder.getAddress status, name, lng, lat = ", status, name, lng, lat);
3258
3272
  place.name = name;
3259
3273
  place.lng = lng;
3260
3274
  place.lat = lat;
@@ -3266,8 +3280,8 @@ const useAmapPlace = (props) => {
3266
3280
  place.name = emptyPlaceName;
3267
3281
  place.lng = lng;
3268
3282
  place.lat = lat;
3269
- console.log("geocoder.getAddress status, name, lng, lat = ", status, "", lng, lat);
3270
3283
  onChange == null ? void 0 : onChange({ lng, lat, name: "" });
3284
+ onChangeCity == null ? void 0 : onChangeCity({ cityName: "", cityParentName: "", countryName: "" });
3271
3285
  return;
3272
3286
  case "error":
3273
3287
  throw result;
@@ -29,9 +29,15 @@ export interface RegisterOverlay<T> {
29
29
  remove: (overlay: T) => void;
30
30
  setFitView: () => void;
31
31
  }
32
+ export interface RouteStep {
33
+ path: Point[];
34
+ duration: number;
35
+ distance: number;
36
+ }
32
37
  export interface Route {
33
38
  path: Point[];
34
39
  distance: number;
35
40
  duration: number;
41
+ steps: RouteStep[];
36
42
  }
37
43
  export type DriverStatus = "dispatching" | "book-dispatching" | "dispatched" | "driverStartService" | "book-driverStartService" | "book-dispatched" | "driverArrived" | "inService" | "canceled" | "endService" | "completed" | "canceling" | "banlanceRefund" | "waitBanlanceRefund" | "rechargePayed" | "waitRechargePay" | "payed" | "waitpay" | "refund" | "confirmed" | "assign";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite -c vite.config.dev.ts",
package/todo.md CHANGED
@@ -97,3 +97,7 @@ https://dawchihliou.github.io/articles/building-custom-google-maps-marker-react-
97
97
 
98
98
  - 4977
99
99
  - 5381
100
+
101
+ 0.5.6
102
+
103
+ - 5455