@heycar/heycars-map 2.5.3 → 2.6.1

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.
Files changed (96) hide show
  1. package/README.md +4 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/v2/Demo/DemoBusinessRecomendPlace.js +1 -1
  5. package/dist/v2/api/contants.d.ts +3 -3
  6. package/dist/v2/api/contants.js +3 -3
  7. package/dist/v2/api/googleDirections.d.ts +26 -0
  8. package/dist/v2/api/googleDirections.js +139 -0
  9. package/dist/v2/api/googleSnapRoad.d.ts +0 -1
  10. package/dist/v2/api/googleSnapRoad.js +6 -14
  11. package/dist/v2/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  12. package/dist/v2/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  13. package/dist/v2/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +4 -3
  14. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +0 -1
  15. package/dist/v2/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +1 -3
  16. package/dist/v2/chunks/{BusinessRecomendPlaceMap.824002ef.js → BusinessRecomendPlaceMap.7b67c30c.js} +3 -2
  17. package/dist/v2/components/Gmap/Gmap.js +15 -3
  18. package/dist/v2/components/MapProvider/MapProvider.d.ts +1 -1
  19. package/dist/v2/components/MapProvider/MapProvider.js +6 -2
  20. package/dist/v2/hooks/useDrivingRoute.js +5 -82
  21. package/dist/v2/hooks/useMapAngle.d.ts +4 -3
  22. package/dist/v2/hooks/useMapCoordinatify.js +1 -1
  23. package/dist/v2/hooks/useMapFitView.js +4 -2
  24. package/dist/v2/hooks/useMapGraspRoad.d.ts +5 -8
  25. package/dist/v2/hooks/useMapGraspRoad.js +9 -60
  26. package/dist/v2/hooks/useMapInChina.d.ts +1 -0
  27. package/dist/v2/hooks/useMapInChina.js +28 -2
  28. package/dist/v2/hooks/useMapPlace.js +3 -3
  29. package/dist/v2/hooks/useMapRecomendPlace.js +2 -1
  30. package/dist/v2/hooks/useMapSupplier.d.ts +2 -0
  31. package/dist/v2/hooks/useResizeObserver.d.ts +1 -0
  32. package/dist/v2/hooks/useResizeObserver.js +3 -1
  33. package/dist/v2/hooks/useWalkingRoute.js +21 -60
  34. package/dist/v2/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  35. package/dist/v2/index.js +1 -1
  36. package/dist/v2/types/interface.d.ts +5 -0
  37. package/dist/v2/utils/compatibleDrivingRoute.d.ts +5 -0
  38. package/dist/v2/utils/compatibleDrivingRoute.js +130 -0
  39. package/dist/v2/utils/compatibleGoogleTypes.d.ts +11 -0
  40. package/dist/v2/utils/compatibleGoogleTypes.js +38 -0
  41. package/dist/v2/utils/compatibleGraspRoad.d.ts +8 -0
  42. package/dist/v2/utils/compatibleGraspRoad.js +67 -0
  43. package/dist/v2/utils/compatibleWalkingRoute.d.ts +5 -0
  44. package/dist/v2/utils/compatibleWalkingRoute.js +81 -0
  45. package/dist/v2/utils/log.js +1 -1
  46. package/dist/v2/utils/transform.d.ts +3 -1
  47. package/dist/v2/utils/transform.js +46 -5
  48. package/dist/v2/utils/typeChecking.d.ts +3 -1
  49. package/dist/v2/utils/typeChecking.js +5 -0
  50. package/dist/v3/Demo/DemoBusinessRecomendPlace.js +1 -1
  51. package/dist/v3/api/contants.d.ts +3 -3
  52. package/dist/v3/api/contants.js +3 -3
  53. package/dist/v3/api/googleDirections.d.ts +26 -0
  54. package/dist/v3/api/googleDirections.js +139 -0
  55. package/dist/v3/api/googleSnapRoad.d.ts +0 -1
  56. package/dist/v3/api/googleSnapRoad.js +6 -14
  57. package/dist/v3/business-components/BusinessRecomendPlaceMap/BusinessRecomendPlaceMap.js +1 -1
  58. package/dist/v3/business-components/BusinessRecomendPlaceMap/index.js +1 -1
  59. package/dist/v3/business-components/BusinessReselectPlaceMap/BusinessReselectPlaceMap.js +4 -3
  60. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.d.ts +0 -1
  61. package/dist/v3/business-components/BusinessTaxiServiceMap/BusinessTaxiServiceMap.js +1 -3
  62. package/dist/v3/chunks/{BusinessRecomendPlaceMap.d14dbe4e.js → BusinessRecomendPlaceMap.8ce05cf5.js} +3 -2
  63. package/dist/v3/components/Gmap/Gmap.js +15 -3
  64. package/dist/v3/components/MapProvider/MapProvider.d.ts +1 -1
  65. package/dist/v3/components/MapProvider/MapProvider.js +6 -2
  66. package/dist/v3/hooks/useDrivingRoute.js +5 -82
  67. package/dist/v3/hooks/useMapAngle.d.ts +4 -3
  68. package/dist/v3/hooks/useMapCoordinatify.js +1 -1
  69. package/dist/v3/hooks/useMapFitView.js +4 -2
  70. package/dist/v3/hooks/useMapGraspRoad.d.ts +5 -8
  71. package/dist/v3/hooks/useMapGraspRoad.js +9 -60
  72. package/dist/v3/hooks/useMapInChina.d.ts +1 -0
  73. package/dist/v3/hooks/useMapInChina.js +28 -2
  74. package/dist/v3/hooks/useMapPlace.js +3 -3
  75. package/dist/v3/hooks/useMapRecomendPlace.js +2 -1
  76. package/dist/v3/hooks/useMapSupplier.d.ts +2 -0
  77. package/dist/v3/hooks/useResizeObserver.d.ts +1 -0
  78. package/dist/v3/hooks/useResizeObserver.js +3 -1
  79. package/dist/v3/hooks/useWalkingRoute.js +21 -60
  80. package/dist/v3/hooks-business/useBusinessRecomendPlaceMap.js +1 -1
  81. package/dist/v3/index.js +1 -1
  82. package/dist/v3/types/interface.d.ts +5 -0
  83. package/dist/v3/utils/compatibleDrivingRoute.d.ts +5 -0
  84. package/dist/v3/utils/compatibleDrivingRoute.js +130 -0
  85. package/dist/v3/utils/compatibleGoogleTypes.d.ts +11 -0
  86. package/dist/v3/utils/compatibleGoogleTypes.js +38 -0
  87. package/dist/v3/utils/compatibleGraspRoad.d.ts +8 -0
  88. package/dist/v3/utils/compatibleGraspRoad.js +67 -0
  89. package/dist/v3/utils/compatibleWalkingRoute.d.ts +5 -0
  90. package/dist/v3/utils/compatibleWalkingRoute.js +81 -0
  91. package/dist/v3/utils/log.js +1 -1
  92. package/dist/v3/utils/transform.d.ts +3 -1
  93. package/dist/v3/utils/transform.js +46 -5
  94. package/dist/v3/utils/typeChecking.d.ts +3 -1
  95. package/dist/v3/utils/typeChecking.js +5 -0
  96. package/package.json +2 -1
package/README.md CHANGED
@@ -130,6 +130,10 @@ export type RecommendType = "Restricted" | "Forbidden" | "Recommend";
130
130
  gmapKey={gmapApiKey}
131
131
  // 使用哪个地图供应商,目前两个供应商: amap 高德 / gmap 谷歌
132
132
  supplier={"amap"}
133
+ // 可选,谷歌路线纠偏代理地址
134
+ googleSnapRoadProxyUrl="/overseas/maps/snapToRoads"
135
+ // 可选,谷歌路线规划代理地址
136
+ googleDirectionsProxyUrl="/overseas/maps/directions/json"
133
137
  // 地图加载失败时显示的标题
134
138
  renderLoadFailedTitle={() => (supplier === "gmap" ? "未能成功访问谷歌地图" : "高德地图加载失败")}
135
139
  // 地图加载失败时显示的描述
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./v2"
1
+ export * from "./v3"
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./v2"
1
+ export * from "./v3"
@@ -1,5 +1,5 @@
1
1
  import { h } from "vue";
2
- import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.824002ef.js";
2
+ import { B as BusinessRecomendPlaceMap } from "../chunks/BusinessRecomendPlaceMap.7b67c30c.js";
3
3
  import { useBusinessRecomendPlaceMap } from "../hooks-business/useBusinessRecomendPlaceMap.js";
4
4
  import { defineSetup } from "../types/helper.js";
5
5
  import { d as demo } from "../chunks/Demo.css.e921a2f6.js";
@@ -1,8 +1,8 @@
1
1
  import type { Point } from "../types/interface";
2
2
  export declare const MAX_ANIMATION_DISTANCE_VW = 300;
3
- export declare const MIN_ANIMATION_DURATION = 300;
4
- export declare const ANIMATION_DURATION_FOR_100VW = 200;
5
- export declare const ANIMATION_DURATION_PER_ZOOM = 400;
3
+ export declare const MIN_ANIMATION_DURATION = 200;
4
+ export declare const ANIMATION_DURATION_FOR_100VW = 100;
5
+ export declare const ANIMATION_DURATION_PER_ZOOM = 200;
6
6
  export declare const BEIJIN_POINT: Point;
7
7
  export declare const MAX_DEVIATION_DISTANCE = 30;
8
8
  export declare const CAR_DISTANCE_MIN = 100;
@@ -1,7 +1,7 @@
1
1
  const MAX_ANIMATION_DISTANCE_VW = 300;
2
- const MIN_ANIMATION_DURATION = 300;
3
- const ANIMATION_DURATION_FOR_100VW = 200;
4
- const ANIMATION_DURATION_PER_ZOOM = 400;
2
+ const MIN_ANIMATION_DURATION = 200;
3
+ const ANIMATION_DURATION_FOR_100VW = 100;
4
+ const ANIMATION_DURATION_PER_ZOOM = 200;
5
5
  const BEIJIN_POINT = [116.2317, 39.5427];
6
6
  const MAX_DEVIATION_DISTANCE = 30;
7
7
  const CAR_DISTANCE_MIN = 100;
@@ -0,0 +1,26 @@
1
+ /// <reference types="google.maps" />
2
+ import type { Point } from "../types/interface";
3
+ type DirectionsStatus = `${google.maps.DirectionsStatus}`;
4
+ export interface GoogleDirectionsResponse extends Pick<google.maps.DirectionsResult, "routes" | "geocoded_waypoints" | "available_travel_modes"> {
5
+ status: DirectionsStatus;
6
+ error_message?: string;
7
+ }
8
+ export interface ApiGoogleDirectionsProps {
9
+ proxyUrl?: string;
10
+ origin: Point;
11
+ destination: Point;
12
+ waypoints?: Point[];
13
+ mode?: `${google.maps.TravelMode}`;
14
+ traffic_model?: `${google.maps.TrafficModel}`;
15
+ alternatives?: boolean;
16
+ arrival_time?: number;
17
+ departure_time?: number;
18
+ avoid?: ("tolls" | "highways" | "ferries" | "indoor")[];
19
+ language?: string;
20
+ region?: string;
21
+ units?: "metric" | "imperial";
22
+ transit_mode?: `${google.maps.TransitMode}`;
23
+ transit_routing_preference?: `${google.maps.TransitRoutePreference}`;
24
+ }
25
+ export declare function apiGoogleDirections(props: ApiGoogleDirectionsProps): Promise<GoogleDirectionsResponse>;
26
+ export {};
@@ -0,0 +1,139 @@
1
+ import { googlePointsStringify, googleEncodedPolyline2googleLatLng } from "../utils/transform.js";
2
+ import { isProxyServiceError, createTypeError } from "../utils/typeChecking.js";
3
+ const ALL_DIRECTIONS_STATUS = [
4
+ "INVALID_REQUEST",
5
+ "MAX_WAYPOINTS_EXCEEDED",
6
+ "NOT_FOUND",
7
+ "OK",
8
+ "OVER_QUERY_LIMIT",
9
+ "REQUEST_DENIED",
10
+ "UNKNOWN_ERROR",
11
+ "ZERO_RESULTS"
12
+ ];
13
+ function isGoogleDistance(value) {
14
+ return typeof value === "object" && value !== null && "text" in value && typeof value.text === "string" && "value" in value && typeof value.value === "number";
15
+ }
16
+ function isGoogleDuration(value) {
17
+ return typeof value === "object" && value !== null && "text" in value && typeof value.text === "string" && "value" in value && typeof value.value === "number";
18
+ }
19
+ function isGoogleDirectionsPolyline(value) {
20
+ return typeof value === "object" && value !== null && "points" in value && typeof value.points === "string";
21
+ }
22
+ function isMeasurableObject(value) {
23
+ return typeof value === "object" && value !== null && (!("distance" in value) || value.distance === void 0 || isGoogleDistance(value.distance)) && (!("duration" in value) || value.duration === void 0 || isGoogleDuration(value.duration));
24
+ }
25
+ function assertGoogleDirectionsStep(value) {
26
+ const error = createTypeError("google.maps.DirectionsStep", value);
27
+ if (!isMeasurableObject(value))
28
+ throw error;
29
+ if (!("polyline" in value)) {
30
+ value.path = [];
31
+ return;
32
+ }
33
+ if (!isGoogleDirectionsPolyline(value.polyline))
34
+ throw error;
35
+ value.path = googleEncodedPolyline2googleLatLng(
36
+ value.polyline.points
37
+ );
38
+ }
39
+ function assertGoogleDirectionsLeg(value) {
40
+ if (!isMeasurableObject(value) || !("steps" in value) || !Array.isArray(value.steps))
41
+ throw createTypeError("google.maps.DirectionsLeg", value);
42
+ try {
43
+ for (const step of value.steps) {
44
+ assertGoogleDirectionsStep(step);
45
+ }
46
+ } catch (error) {
47
+ const { message: detail } = error;
48
+ throw createTypeError("google.maps.DirectionsLeg", value, detail);
49
+ }
50
+ }
51
+ function assertGoogleDirectionsRoute(value) {
52
+ if (typeof value !== "object" || value === null || !("legs" in value) || !Array.isArray(value.legs) || !("overview_polyline" in value) || !isGoogleDirectionsPolyline(value.overview_polyline))
53
+ throw createTypeError("google.maps.DirectionsRoute", value);
54
+ value.overview_path = googleEncodedPolyline2googleLatLng(
55
+ value.overview_polyline.points
56
+ );
57
+ try {
58
+ for (const leg of value.legs) {
59
+ assertGoogleDirectionsLeg(leg);
60
+ }
61
+ } catch (error) {
62
+ const { message: detail } = error;
63
+ throw createTypeError("google.maps.DirectionsRoute", value, detail);
64
+ }
65
+ }
66
+ function assertGoogleDirectionsResponse(value) {
67
+ if (typeof value !== "object" || value === null || !("status" in value) || !("routes" in value) || !isGoogleDirectionsStatus(value.status) || !Array.isArray(value.routes))
68
+ throw createTypeError("GoogleDirectionsResponse", value);
69
+ try {
70
+ for (const route of value.routes) {
71
+ assertGoogleDirectionsRoute(route);
72
+ }
73
+ } catch (error) {
74
+ const { message: detail } = error;
75
+ throw createTypeError("GoogleDirectionsResponse", value, detail);
76
+ }
77
+ }
78
+ function isGoogleDirectionsStatus(value) {
79
+ return typeof value === "string" && ALL_DIRECTIONS_STATUS.includes(value);
80
+ }
81
+ function isGoogleDirectionsError(error) {
82
+ return typeof error === "object" && !!error && "status" in error && isGoogleDirectionsStatus(error.status) && "error_message" in error;
83
+ }
84
+ async function apiGoogleDirections(props) {
85
+ const { proxyUrl, origin, destination, waypoints, avoid } = props;
86
+ if (!proxyUrl)
87
+ return {
88
+ status: "ZERO_RESULTS",
89
+ routes: [],
90
+ error_message: "Warning: google directions service is bypassed due to proxyUrl is not provided!"
91
+ };
92
+ const { protocol, host } = location;
93
+ const baseUrl = proxyUrl.startsWith(protocol) ? void 0 : `${protocol}//${host}`;
94
+ const url = new URL(proxyUrl, baseUrl);
95
+ url.searchParams.set("origin", googlePointsStringify([origin]));
96
+ url.searchParams.set("destination", googlePointsStringify([destination]));
97
+ if (waypoints && waypoints.length > 0)
98
+ url.searchParams.set("waypoints", googlePointsStringify(waypoints));
99
+ if (avoid && avoid.length > 0)
100
+ url.searchParams.set("avoid", avoid.join("|"));
101
+ for (const key of [
102
+ "mode",
103
+ "traffic_model",
104
+ "alternatives",
105
+ "arrival_time",
106
+ "departure_time",
107
+ "language",
108
+ "region",
109
+ "units",
110
+ "transit_mode",
111
+ "transit_routing_preference"
112
+ ]) {
113
+ if (props[key] !== void 0)
114
+ url.searchParams.set(key, String(key));
115
+ }
116
+ const response = await fetch(url);
117
+ if (response.ok) {
118
+ const result = await response.json();
119
+ assertGoogleDirectionsResponse(result);
120
+ return result;
121
+ }
122
+ const error = await response.json();
123
+ if (isProxyServiceError(error)) {
124
+ const { code, msg } = error;
125
+ throw new Error(`apiGoogleDirections proxy failed code: ${code}, msg:
126
+ ${msg}`);
127
+ }
128
+ if (isGoogleDirectionsError(error)) {
129
+ const { status, error_message } = error;
130
+ throw new Error(`apiGoogleDirections failed status: ${status}, message:
131
+ ${error_message}`);
132
+ }
133
+ throw new Error(
134
+ `apiGoogleSnapRoad failed with unrecognized server response: ${JSON.stringify(error)}`
135
+ );
136
+ }
137
+ export {
138
+ apiGoogleDirections
139
+ };
@@ -18,5 +18,4 @@ export interface ApiGoogleSnapRoadProps {
18
18
  proxyUrl?: string;
19
19
  }
20
20
  export declare function apiGoogleSnapRoad(props: ApiGoogleSnapRoadProps): Promise<SnapToRoadsResponse>;
21
- export declare const setGlobalGoogleSnapRoadProxyUrl: (url?: string) => void;
22
21
  export {};
@@ -1,8 +1,5 @@
1
- let googleSnapRoadProxyUrl = void 0;
2
- const googleSnapRoadPointsStringify = (points) => points.map(([lng, lat]) => `${lat},${lng}`).join("|");
3
- function isProxyError(error) {
4
- return !!error && typeof error === "object" && "msg" in error && "code" in error;
5
- }
1
+ import { googlePointsStringify } from "../utils/transform.js";
2
+ import { isProxyServiceError } from "../utils/typeChecking.js";
6
3
  const point2snappedPoint = (point) => {
7
4
  const [longitude, latitude] = point;
8
5
  return { location: { longitude, latitude }, placeId: "" };
@@ -34,7 +31,7 @@ function assertSnapToRoadsResponse(value) {
34
31
  value.snappedPoints.forEach(assertSnappedPoint);
35
32
  }
36
33
  async function apiGoogleSnapRoad(props) {
37
- const { interpolate, path, proxyUrl = googleSnapRoadProxyUrl } = props;
34
+ const { interpolate, path, proxyUrl } = props;
38
35
  if (!proxyUrl)
39
36
  return {
40
37
  snappedPoints: path.map(point2snappedPoint),
@@ -45,7 +42,7 @@ async function apiGoogleSnapRoad(props) {
45
42
  const url = new URL(proxyUrl, baseUrl);
46
43
  if (interpolate !== void 0)
47
44
  url.searchParams.set("interpolate", String(interpolate));
48
- url.searchParams.set("path", googleSnapRoadPointsStringify(path));
45
+ url.searchParams.set("path", googlePointsStringify(path));
49
46
  const response = await fetch(url);
50
47
  if (response.ok) {
51
48
  const result = await response.json();
@@ -53,7 +50,7 @@ async function apiGoogleSnapRoad(props) {
53
50
  return result;
54
51
  }
55
52
  const error = await response.json();
56
- if (isProxyError(error)) {
53
+ if (isProxyServiceError(error)) {
57
54
  const { code: code2, msg } = error;
58
55
  throw new Error(`apiGoogleSnapRoad proxy failed code: ${code2}, msg:
59
56
  ${msg}`);
@@ -64,11 +61,6 @@ ${msg}`);
64
61
  ${message}`
65
62
  );
66
63
  }
67
- const setGlobalGoogleSnapRoadProxyUrl = (url) => {
68
- if (url)
69
- googleSnapRoadProxyUrl = url;
70
- };
71
64
  export {
72
- apiGoogleSnapRoad,
73
- setGlobalGoogleSnapRoadProxyUrl
65
+ apiGoogleSnapRoad
74
66
  };
@@ -27,7 +27,7 @@ import "../GreenZone/GreenZone.js";
27
27
  import "../PassengerCircle/PassengerCircle.js";
28
28
  import "../PickupPoints/PickupPoints.js";
29
29
  import "./useCacheCenterPlace.js";
30
- import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.824002ef.js";
30
+ import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.7b67c30c.js";
31
31
  export {
32
32
  B as BusinessRecomendPlaceMap,
33
33
  f as BusinessRecomendPlaceMapInner,
@@ -1,4 +1,4 @@
1
- import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.824002ef.js";
1
+ import { B, f, D, E, R, c, a, e, b, d, Z } from "../../chunks/BusinessRecomendPlaceMap.7b67c30c.js";
2
2
  export {
3
3
  B as BusinessRecomendPlaceMap,
4
4
  f as BusinessRecomendPlaceMapInner,
@@ -21,7 +21,7 @@ import { detectBrowserPlatform } from "../../utils/platform.js";
21
21
  import { place2point, isPlaceEqual, isZoneEqual, geoPositionError2businessTimeout, pipeDefer } from "../../utils/transform.js";
22
22
  import { toCoordinatePlaceType, toCoordinatePointType, toCoordinateRecommendZonePlacesType } from "../../utils/typeChecking.js";
23
23
  import { AbsoluteAddressBox } from "../AbsoluteAddressBox/AbsoluteAddressBox.js";
24
- import { E as EMPTY_PLACE, m as memoize, R as RECOMMEND_PLACE_DRAG_LIMIT, a as RECOMMEND_PLACE_LARGE_LIMIT, b as RECOMMEND_PLACE_ZONE_ICON_MIN, c as RECOMMEND_PLACE_ICON_ZOOM_MIN, d as RECOMMEND_PLACE_ZONE_TEXT_MIN, e as RECOMMEND_PLACE_TEXT_ZOOM_MIN, D as DEFAULT_ZOOM, Z as ZONE_FITVIEW_PANDING } from "../../chunks/BusinessRecomendPlaceMap.824002ef.js";
24
+ import { E as EMPTY_PLACE, m as memoize, R as RECOMMEND_PLACE_DRAG_LIMIT, a as RECOMMEND_PLACE_LARGE_LIMIT, b as RECOMMEND_PLACE_ZONE_ICON_MIN, c as RECOMMEND_PLACE_ICON_ZOOM_MIN, d as RECOMMEND_PLACE_ZONE_TEXT_MIN, e as RECOMMEND_PLACE_TEXT_ZOOM_MIN, D as DEFAULT_ZOOM, Z as ZONE_FITVIEW_PANDING } from "../../chunks/BusinessRecomendPlaceMap.7b67c30c.js";
25
25
  import { DeviceOrientation } from "../DeviceOrientation/DeviceOrientation.js";
26
26
  import { GreenZone } from "../GreenZone/GreenZone.js";
27
27
  import { PassengerCircle } from "../PassengerCircle/PassengerCircle.js";
@@ -228,7 +228,8 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
228
228
  inputPlace,
229
229
  type,
230
230
  zone,
231
- isSameZone
231
+ isSameZone,
232
+ noAnimation
232
233
  }) => {
233
234
  var _a;
234
235
  centerSource.source = "recomend";
@@ -238,7 +239,7 @@ const BusinessReselectPlaceMapInner = defineSetup("BusinessReselectPlaceMapInner
238
239
  ...place
239
240
  });
240
241
  if ((type === "Restricted" || type === "Forbidden") && !isSameZone)
241
- setFitZoom((_a = zoneRef.value) == null ? void 0 : _a.path);
242
+ setFitZoom((_a = zoneRef.value) == null ? void 0 : _a.path, place2point(place), noAnimation);
242
243
  emit("changeRecomandPlace", coordinatifyValueOfOnChangeRecommendPlace({
243
244
  place,
244
245
  inputPlace,
@@ -12,7 +12,6 @@ export type BusinessTaxiServiceMapProps = CoordinatifyProps<Omit<HeycarMapProps,
12
12
  driverStatus: DriverStatus;
13
13
  interval: number;
14
14
  disablePassenger?: boolean;
15
- googleSnapRoadProxyUrl?: string;
16
15
  mapContext: CoordinatifyProps<BusinessTaxiServiceContext>;
17
16
  renderStartSerivceTitle: (titleProps: {
18
17
  distance: number;
@@ -1,7 +1,6 @@
1
1
  import { h } from "vue";
2
2
  import { ref, watch, onUnmounted } from "vue-demi";
3
3
  import { apiGetAuxiliaryGrapStatus } from "../../api/browser.js";
4
- import { setGlobalGoogleSnapRoadProxyUrl } from "../../api/googleSnapRoad.js";
5
4
  import { HeycarMap } from "../../components/MapProvider/MapProvider.js";
6
5
  import { createElement } from "../../demi-polyfill/demi-polyfill.js";
7
6
  import { useGeoLocation } from "../../hooks/useGeoLocation.js";
@@ -30,7 +29,6 @@ const BusinessTaxiServiceMapInner = defineSetup("BusinessTaxiServiceMapInner", f
30
29
  renderStartSerivceTitle,
31
30
  renderInServiceTitle
32
31
  } = props;
33
- setGlobalGoogleSnapRoadProxyUrl(props.googleSnapRoadProxyUrl);
34
32
  const {
35
33
  mapRef,
36
34
  setMap,
@@ -242,7 +240,7 @@ const BusinessTaxiServiceMap = defineLagecySetup("BusinessTaxiServiceMap", funct
242
240
  attrs: props,
243
241
  key: `${payload.supplier}${instanceNo}`
244
242
  });
245
- }).props(["bookDispatchingTitle", "dispatchingTitle", "driverArrivedTitle", "driverStatus", "googleSnapRoadProxyUrl", "fallback", "from", "getDriverPositionTrack", "interval", "disablePassenger", "loading", "mapContext", "renderInServiceTitle", "renderStartSerivceTitle", "to"]);
243
+ }).props(["bookDispatchingTitle", "dispatchingTitle", "driverArrivedTitle", "driverStatus", "fallback", "from", "getDriverPositionTrack", "interval", "disablePassenger", "loading", "mapContext", "renderInServiceTitle", "renderStartSerivceTitle", "to"]);
246
244
  export {
247
245
  BusinessTaxiServiceMap,
248
246
  BusinessTaxiServiceMapInner
@@ -502,7 +502,8 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
502
502
  inputPlace,
503
503
  type,
504
504
  zone,
505
- isSameZone
505
+ isSameZone,
506
+ noAnimation
506
507
  }) => {
507
508
  var _a;
508
509
  centerSource.source = "recomend";
@@ -512,7 +513,7 @@ const BusinessRecomendPlaceMapInner = defineSetup("BusinessRecomendPlaceMapInner
512
513
  ...place
513
514
  });
514
515
  if ((type === "Restricted" || type === "Forbidden") && !isSameZone)
515
- setFitZoom((_a = zoneRef.value) == null ? void 0 : _a.path, place2point(place));
516
+ setFitZoom((_a = zoneRef.value) == null ? void 0 : _a.path, place2point(place), noAnimation);
516
517
  emit("changeRecomandPlace", coordinatifyValueOfOnChangeRecommendPlace({
517
518
  place,
518
519
  inputPlace,
@@ -13,7 +13,6 @@ const Gmap_css_ts_vanilla = "";
13
13
  var gmap = "_7anfuo0";
14
14
  const Gmap = defineSetup("Gmap", function(props, { slots, emit, attrs }) {
15
15
  const setMap = props.mapRef;
16
- const { onResize } = props;
17
16
  const os = detectOSPlatform();
18
17
  const options = computed(() => {
19
18
  const {
@@ -26,6 +25,7 @@ const Gmap = defineSetup("Gmap", function(props, { slots, emit, attrs }) {
26
25
  gestureHandling,
27
26
  center,
28
27
  zoom,
28
+ renderingType,
29
29
  ...options2
30
30
  } = props;
31
31
  return {
@@ -35,7 +35,12 @@ const Gmap = defineSetup("Gmap", function(props, { slots, emit, attrs }) {
35
35
  isFractionalZoomEnabled: true
36
36
  };
37
37
  });
38
- const defaultOptions = { ...options.value, center: props.center, zoom: props.zoom };
38
+ const defaultOptions = {
39
+ ...options.value,
40
+ renderingType: props.renderingType,
41
+ center: props.center,
42
+ zoom: props.zoom
43
+ };
39
44
  const enableRef = computed(() => !!props.touchZoomCenter);
40
45
  const elementRef = shallowRef();
41
46
  const mapRef = shallowRef();
@@ -49,7 +54,14 @@ const Gmap = defineSetup("Gmap", function(props, { slots, emit, attrs }) {
49
54
  provideGmap(mapRef);
50
55
  useGmapWheelZoomCenter({ mapRef, enableRef });
51
56
  useGmapGestureZoomCenter({ mapRef, elementRef, enableRef });
52
- useResizeObserver({ elementRef, onChange: onResize });
57
+ useResizeObserver({
58
+ elementRef,
59
+ shouldSkip: () => {
60
+ var _a;
61
+ return !((_a = mapRef.value) == null ? void 0 : _a.getProjection());
62
+ },
63
+ onChange: (e) => emit("resize", e)
64
+ });
53
65
  watchPostEffect(() => {
54
66
  const element = elementRef.value;
55
67
  if (mapRef.value || !element)
@@ -5,7 +5,7 @@ import { type GmapLoaderProps, type UseMapLoaderProps } from "../../hooks/useMap
5
5
  import { type MapSupplierPayolad } from "../../hooks/useMapSupplier";
6
6
  import type { AmapMap } from "../../types/interface";
7
7
  import { type AmapProps } from "../Amap";
8
- export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "renderLoadFailedTitle" | "renderLoadFailedDescription">;
8
+ export type MapProviderProps = UseMapLoaderProps & Pick<MapSupplierPayolad, "gmapId" | "gmapRasterId" | "googleDirectionsProxyUrl" | "googleSnapRoadProxyUrl" | "renderLoadFailedTitle" | "renderLoadFailedDescription">;
9
9
  export declare const MapProvider: import("vue-demi").DefineComponent<import("vue3").ComponentObjectPropsOptions<MapProviderProps>, 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<MapProviderProps, Required<MapProviderProps>>, "success" | "fail" | "downloadOptimizeEnd", MapProviderProps>;
10
10
  export interface HeycarMapProps extends Pick<GmapLoaderProps, "fallback" | "loading">, Pick<AmapProps, "center" | "zoom"> {
11
11
  mapRef?: SetMap<AmapMap> | SetMap<google.maps.Map>;
@@ -11,10 +11,12 @@ import { detectWebGL, WEBGL_STATUS, detectBrowserPlatform, OS_PLATFORM, BRWOSER_
11
11
  import { language2vectorMapForeign, vec2lnglat } from "../../utils/transform.js";
12
12
  import { Amap } from "../Amap/Amap.js";
13
13
  import { Gmap } from "../Gmap/Gmap.js";
14
+ import { t as throttle } from "../../chunks/throttle.8bdd8d3b.js";
14
15
  const style_css_ts_vanilla = "";
15
16
  const MapProvider_css_ts_vanilla = "";
16
17
  var heycarGmapBackgroundDefaultLoadingImage = "_16q981k1";
17
18
  var heycarMap = "_16q981k0";
19
+ const MAP_RESIZE_MIN_INTERVAL = 500;
18
20
  window.movingDraw = !new URLSearchParams(location.search).has("disableMovingDraw");
19
21
  if (detectWebGL() === WEBGL_STATUS.ENABLED) {
20
22
  window.forceWebGL = true;
@@ -48,7 +50,7 @@ const MapProvider = defineLagecySetup("MapProvider", function(props, {
48
50
  var _a;
49
51
  return h("div", [(_a = slots.default) == null ? void 0 : _a.call(slots)]);
50
52
  };
51
- }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "renderLoadFailedTitle", "renderLoadFailedDescription"]);
53
+ }).props(["amapKey", "amapSecret", "amapServiceHost", "gmapId", "gmapRasterId", "gmapKey", "supplier", "language", "googleDirectionsProxyUrl", "googleSnapRoadProxyUrl", "renderLoadFailedTitle", "renderLoadFailedDescription"]);
52
54
  const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
53
55
  slots,
54
56
  emit,
@@ -73,7 +75,9 @@ const HeycarMap = defineLagecySetup("HeycarMap", function(props, {
73
75
  } = target.getCenter();
74
76
  emit("dragEnd", [lng, lat]);
75
77
  };
76
- const handleResize = () => emit("resize");
78
+ const handleResize = throttle(() => emit("resize"), MAP_RESIZE_MIN_INTERVAL, {
79
+ trailing: true
80
+ });
77
81
  loadTraditionalChineseConvertOnce(payload.language === "zh-TW");
78
82
  return () => {
79
83
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -1,7 +1,10 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { watchPostEffectForDeepOption } from "../utils/compare.js";
3
+ import { googleServiceApiDrivingRoute, amapJsApiDrivingRoute, gmapJsApiDrivingRoute } from "../utils/compatibleDrivingRoute.js";
4
+ import { inTaiwan } from "./useMapInChina.js";
3
5
  import { useMapSupplier } from "./useMapSupplier.js";
4
6
  const useADrivingRoute = (props) => {
7
+ const { googleDirectionsProxyUrl } = useMapSupplier();
5
8
  const outputRoute = reactive({
6
9
  path: [],
7
10
  distance: 0,
@@ -11,46 +14,7 @@ const useADrivingRoute = (props) => {
11
14
  });
12
15
  const amapDriving = new AMap.Driving({});
13
16
  const apiMapDrivingRoute = (from, to) => {
14
- return new Promise((resolve, reject) => {
15
- amapDriving.search(
16
- AMap.LngLat.from(from),
17
- AMap.LngLat.from(to),
18
- { waypoints: [] },
19
- (status, result) => {
20
- switch (status) {
21
- case "complete": {
22
- let path = [];
23
- const drivingResult = result;
24
- const routeSteps = [];
25
- const firstRoute = drivingResult.routes[0];
26
- if (!firstRoute)
27
- return resolve({ path: [], distance: 0, duration: 0, steps: [] });
28
- for (const step of firstRoute.steps) {
29
- const basicStep = step;
30
- const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
31
- path = path.concat(stepPath);
32
- routeSteps.push({
33
- path: basicStep.path.map(({ lng, lat }) => [lng, lat]),
34
- duration: basicStep.time,
35
- distance: basicStep.distance
36
- });
37
- }
38
- return resolve({
39
- path,
40
- distance: firstRoute.distance,
41
- duration: firstRoute.time,
42
- tolls: firstRoute.tolls,
43
- steps: routeSteps
44
- });
45
- }
46
- case "no_data":
47
- return resolve({ path: [], distance: 0, duration: 0, steps: [] });
48
- default:
49
- return reject(result);
50
- }
51
- }
52
- );
53
- });
17
+ return googleDirectionsProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, googleDirectionsProxyUrl) : amapJsApiDrivingRoute(from, to, amapDriving);
54
18
  };
55
19
  watchPostEffectForDeepOption(
56
20
  () => {
@@ -69,48 +33,7 @@ const useGDrivingRoute = (props) => {
69
33
  const outputRoute = reactive({ path: [], distance: 0, duration: 0, steps: [] });
70
34
  const gmapDirectionsService = new google.maps.DirectionsService();
71
35
  const apiMapDrivingRoute = (from, to) => {
72
- return new Promise((resolve, reject) => {
73
- gmapDirectionsService.route(
74
- {
75
- origin: { lng: from[0], lat: from[1] },
76
- destination: { lng: to[0], lat: to[1] },
77
- travelMode: google.maps.TravelMode.DRIVING
78
- },
79
- (result, status) => {
80
- var _a, _b, _c, _d, _e, _f, _g, _h;
81
- switch (status) {
82
- case google.maps.DirectionsStatus.OK: {
83
- let path = [];
84
- let distance = 0;
85
- let duration = 0;
86
- const routeSteps = [];
87
- const firstRoute = result.routes[0];
88
- if (!firstRoute)
89
- return resolve({ path: [], distance: 0, duration: 0, steps: [] });
90
- for (const leg of firstRoute.legs) {
91
- distance += (_b = (_a = leg.distance) == null ? void 0 : _a.value) != null ? _b : 0;
92
- duration += (_d = (_c = leg.duration) == null ? void 0 : _c.value) != null ? _d : 0;
93
- for (const step of leg.steps) {
94
- const stepPath = step.path.map(({ lng, lat }) => [lng(), lat()]);
95
- path = path.concat(stepPath);
96
- routeSteps.push({
97
- path: stepPath,
98
- distance: (_f = (_e = step.distance) == null ? void 0 : _e.value) != null ? _f : 0,
99
- duration: (_h = (_g = step.duration) == null ? void 0 : _g.value) != null ? _h : 0
100
- });
101
- }
102
- }
103
- return resolve({ path, distance, duration, steps: routeSteps });
104
- }
105
- case google.maps.DirectionsStatus.ZERO_RESULTS:
106
- case google.maps.DirectionsStatus.NOT_FOUND:
107
- return resolve({ path: [], distance: 0, duration: 0, steps: [] });
108
- default:
109
- return reject(new Error(status));
110
- }
111
- }
112
- );
113
- });
36
+ return gmapJsApiDrivingRoute(from, to, gmapDirectionsService);
114
37
  };
115
38
  watchPostEffectForDeepOption(
116
39
  () => {
@@ -1,18 +1,19 @@
1
1
  /// <reference types="google.maps" />
2
2
  import type { AmapMap, Point } from "../types/interface";
3
+ export type ApiMapComputeHeading = (from?: Point, to?: Point) => number | undefined;
3
4
  export type UseMapAngleProps<M = AmapMap | google.maps.Map> = {
4
5
  path: Point[];
5
6
  map?: M;
6
7
  };
7
8
  export declare const useAmapAngle: (props?: UseMapAngleProps<AmapMap>) => {
8
9
  angleRef: import("vue-demi").ComputedRef<number | undefined>;
9
- apiMapComputeHeading: (from?: Point, to?: Point) => number | undefined;
10
+ apiMapComputeHeading: ApiMapComputeHeading;
10
11
  };
11
12
  export declare const useGmapAngle: (props?: UseMapAngleProps<google.maps.Map>) => {
12
13
  angleRef: import("vue-demi").ComputedRef<number | undefined>;
13
- apiMapComputeHeading: (from?: Point, to?: Point) => number | undefined;
14
+ apiMapComputeHeading: ApiMapComputeHeading;
14
15
  };
15
16
  export declare const useMapAngle: (props?: UseMapAngleProps) => {
16
17
  angleRef: import("vue-demi").ComputedRef<number | undefined>;
17
- apiMapComputeHeading: (from?: Point, to?: Point) => number | undefined;
18
+ apiMapComputeHeading: ApiMapComputeHeading;
18
19
  };
@@ -13,7 +13,7 @@ function useMapCoordinatify() {
13
13
  return [lng, lat];
14
14
  if (type === "wgs84") {
15
15
  if (!inChina([lng, lat]))
16
- throw new Error(`国外经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
16
+ throw new Error(`国外(或台湾)经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
17
17
  return toLocalWgs84([lng, lat]);
18
18
  }
19
19
  return toLocalGcj02([lng, lat]);
@@ -5,6 +5,8 @@ import { useMapSupplier } from "./useMapSupplier.js";
5
5
  import { d as debounce } from "../chunks/debounce.5afe7867.js";
6
6
  const GOOGLE_MAP_ZOOM_CHANGE_DEBOUNCE_TIMEOUT = 20;
7
7
  const GOOGLE_MAP_FIT_BOUND_SINGLE_POINT_ZOOM = 17.5;
8
+ const GOOGLE_MAP_FIT_BOUND_MIN_WIDTH = 10;
9
+ const GOOGLE_MAP_FIT_BOUND_MIN_HEIGHT = 10;
8
10
  const useAmapFitView = (props) => {
9
11
  const { mapRef, autoFitTimeout } = props;
10
12
  const overlayGroup = /* @__PURE__ */ new Set();
@@ -80,8 +82,8 @@ function gmapFitBoundNoAnimate(map, bound, padding) {
80
82
  return;
81
83
  const { top = 0, right = 0, bottom = 0, left = 0 } = padding;
82
84
  const { offsetWidth, offsetHeight } = map.getDiv();
83
- const w = offsetWidth - left - right;
84
- const h = offsetHeight - top - bottom;
85
+ const w = Math.max(offsetWidth - left - right, GOOGLE_MAP_FIT_BOUND_MIN_WIDTH);
86
+ const h = Math.max(offsetHeight - top - bottom, GOOGLE_MAP_FIT_BOUND_MIN_HEIGHT);
85
87
  const northEast = bound.getNorthEast();
86
88
  const southWest = bound.getSouthWest();
87
89
  const { x: x0, y: y0 } = projection.fromLatLngToPoint(northEast);