@heycar/heycars-map 2.21.0-gmapCost2 → 2.21.0-gmapCost4

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/v2/App.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { h } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
3
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
4
- import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
4
+ import { DemoBusinessQuoting } from "./Demo/DemoBusinessQuoting.js";
5
5
  const gmapApiKey = {}.VITE_GMAP_API_KEY;
6
6
  const gmapId = {}.VITE_GMAP_MAP_ID;
7
7
  const amapApiKey = {}.VITE_AMAP_API_KEY;
8
8
  const amapApiSecret = {}.VITE_AMAP_API_SECRET;
9
9
  const App = defineComponent({
10
10
  setup() {
11
- const supplierRef = ref("amap");
11
+ const supplierRef = ref("gmap");
12
12
  window.supplierRef = supplierRef;
13
13
  return () => h(MapProvider, {
14
14
  "attrs": {
@@ -21,6 +21,7 @@ const App = defineComponent({
21
21
  "gaodeRegeoProxyUrl": "/overseas/amap/regeo",
22
22
  "googleRegeoProxyUrl": "/overseas/maps/regeo",
23
23
  "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
24
+ "gaodeDirectionDrivingProxyUrl": "/overseas/amap/driveGuide",
24
25
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
25
26
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
26
27
  "themeVariables": {
@@ -52,7 +53,7 @@ const App = defineComponent({
52
53
  "fail": () => console.log(`${supplierRef.value} load failed`),
53
54
  "downloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`)
54
55
  }
55
- }, [h(DemoBusinessRecomendPlace)]);
56
+ }, [h(DemoBusinessQuoting)]);
56
57
  }
57
58
  });
58
59
  export {
@@ -18,11 +18,11 @@ const DemoBusinessQuoting = defineComponent({
18
18
  data() {
19
19
  return {
20
20
  from: {
21
- displayName: "my",
22
- name: "my",
23
- type: "gcj02",
24
- lat: 31.205478,
25
- lng: 121.409535
21
+ displayName: "铜锣湾花园",
22
+ name: "铜锣湾花园",
23
+ type: "wgs84",
24
+ lat: 22.283107097738952,
25
+ lng: 114.18577528478997
26
26
  }
27
27
  };
28
28
  },
@@ -51,8 +51,8 @@ const DemoBusinessQuoting = defineComponent({
51
51
  displayName: "CDG Engie Charging Station",
52
52
  name: "21 Kent Ridge Rd, Singapore 119220",
53
53
  type: "gcj02",
54
- lat: 31.207082,
55
- lng: 121.407967
54
+ lat: 22.244887,
55
+ lng: 114.294277
56
56
  },
57
57
  "fromDescription": "您将在此上车",
58
58
  "renderDescription": ({
@@ -17,7 +17,7 @@ const useADrivingRoute = (props) => {
17
17
  });
18
18
  const amapDriving = new AMap.Driving({ ferry: 1 });
19
19
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
20
- return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
20
+ return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl, "amap") : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
21
21
  };
22
22
  watchPostEffectForDeepOption(
23
23
  () => {
@@ -48,7 +48,7 @@ const useGDrivingRoute = (props) => {
48
48
  });
49
49
  const gmapDirectionsService = new google.maps.DirectionsService();
50
50
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
51
- return gaodeDirectionDrivingProxyUrl && !inTaiwan(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
51
+ return gaodeDirectionDrivingProxyUrl && !inTaiwan(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl, "gmap") : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
52
52
  };
53
53
  watchPostEffectForDeepOption(
54
54
  () => {
@@ -7,7 +7,7 @@ const GEO_TIMEOUT = 5e3;
7
7
  const singleGeoWatch = new SingleGeoWatch({
8
8
  timeout: GEO_TIMEOUT,
9
9
  maximumAge: 0,
10
- enableHighAccuracy: false
10
+ enableHighAccuracy: true
11
11
  });
12
12
  const useGeoLocation = (props) => {
13
13
  var _a, _b;
@@ -1,5 +1,5 @@
1
1
  import { e as exported } from "../chunks/gcoord.esm-bundler.3f2f1369.js";
2
- import { inChina, inHongkong, inMacau } from "./useMapInChina.js";
2
+ import { inChina, inDiffArea } from "./useMapInChina.js";
3
3
  import { useMapSupplier } from "./useMapSupplier.js";
4
4
  const useAmapGCJ02 = () => {
5
5
  const toCoordinateType = (p) => {
@@ -48,11 +48,11 @@ const useAmapGCJ02 = () => {
48
48
  };
49
49
  const useGmapGCJ02 = () => {
50
50
  const toCoordinateType = (p) => {
51
- return inChina(p) && !inHongkong(p) && !inMacau(p) ? "gcj02" : "wgs84";
51
+ return inChina(p) && !inDiffArea(p) ? "gcj02" : "wgs84";
52
52
  };
53
53
  const toLocalGcj02 = (point) => {
54
54
  try {
55
- if (!inChina(point) || inHongkong(point) || inMacau(point))
55
+ if (!inChina(point) || inDiffArea(point))
56
56
  return point;
57
57
  return exported.transform(point, exported.WGS84, exported.GCJ02);
58
58
  } catch (err) {
@@ -65,7 +65,7 @@ const useGmapGCJ02 = () => {
65
65
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
66
66
  const toLocalWgs84 = (point) => {
67
67
  try {
68
- if (inChina(point) && !inHongkong(point) && !inMacau(point))
68
+ if (inChina(point) && !inDiffArea(point))
69
69
  return point;
70
70
  return exported.transform(point, exported.GCJ02, exported.WGS1984);
71
71
  } catch (err) {
@@ -4,3 +4,4 @@ export declare const inHongkong: (point: Point) => boolean;
4
4
  export declare const inMacau: (point: Point) => boolean;
5
5
  export declare const inTaiwan: (point: Point) => boolean;
6
6
  export declare const inKorean: (point: Point) => boolean;
7
+ export declare const inDiffArea: (p: Point) => boolean;
@@ -2792,8 +2792,12 @@ const inTaiwan = (point) => {
2792
2792
  const inKorean = (point) => {
2793
2793
  return pointInPolygon(point, koreanBounds) >= 0;
2794
2794
  };
2795
+ const inDiffArea = (p) => {
2796
+ return inHongkong(p) || inMacau(p);
2797
+ };
2795
2798
  export {
2796
2799
  inChina,
2800
+ inDiffArea,
2797
2801
  inHongkong,
2798
2802
  inKorean,
2799
2803
  inMacau,
@@ -173,7 +173,7 @@ const useGmapPlace = (props) => {
173
173
  };
174
174
  console.log("==港府接口返回结果==", JSON.stringify(addressInfo));
175
175
  resolve(addressInfo);
176
- });
176
+ }).finally(() => clearTimeout(timer));
177
177
  await sleep(HK_GOVERN_API_TIMEOUT);
178
178
  if ((_a = props.findAttachedPlaceDone) == null ? void 0 : _a.value)
179
179
  return;
@@ -203,7 +203,7 @@ const useGmapPlace = (props) => {
203
203
  };
204
204
  console.log("==谷歌逆地理返回结果==", JSON.stringify(addressInfo));
205
205
  resolve(addressInfo);
206
- }).catch(handleFailed);
206
+ }).catch(handleFailed).finally(() => clearTimeout(timer));
207
207
  } else {
208
208
  const geocoder = new google.maps.Geocoder();
209
209
  geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
package/dist/v2/index.js CHANGED
@@ -32,7 +32,7 @@ import { useMapGeometry } from "./hooks/useMapGeometry.js";
32
32
  import { useMapPlace } from "./hooks/useMapPlace.js";
33
33
  import { useMapRecomendPlace } from "./hooks/useMapRecomendPlace.js";
34
34
  import { useWalkingRoute } from "./hooks/useWalkingRoute.js";
35
- import { inChina, inHongkong, inKorean, inMacau, inTaiwan } from "./hooks/useMapInChina.js";
35
+ import { inChina, inDiffArea, inHongkong, inKorean, inMacau, inTaiwan } from "./hooks/useMapInChina.js";
36
36
  import { CenterPlaceStatus, PointSource } from "./types/interface.js";
37
37
  import { MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT, patchMiniprogramRedirectTo } from "./utils/patchMiniprogram.js";
38
38
  export {
@@ -59,6 +59,7 @@ export {
59
59
  WalkingRoute,
60
60
  WaveCircle,
61
61
  inChina,
62
+ inDiffArea,
62
63
  inHongkong,
63
64
  inKorean,
64
65
  inMacau,
@@ -1,7 +1,8 @@
1
1
  /// <reference types="google.maps" />
2
+ import type { MapSupplier } from "../hooks/useMapLoader";
2
3
  import type { Point, Route } from "../types/interface";
3
4
  export declare function amapJsApiDrivingRoute(from: Point, to: Point, waypoints: Point[], amapDriving: AMap.Driving): Promise<Route>;
4
- export declare function gaodeServiceApiDrivingRoute(from: Point, to: Point, waypoints: Point[], proxyUrl: string): Promise<Route>;
5
+ export declare function gaodeServiceApiDrivingRoute(from: Point, to: Point, waypoints: Point[], proxyUrl: string, mapSupplier: MapSupplier): Promise<Route>;
5
6
  export declare function gmapJsApiDrivingRoute(from: Point, to: Point, waypoints: Point[], gmapDirectionsService: google.maps.DirectionsService): Promise<Route>;
6
7
  export declare function googleServiceApiDrivingDirection(from: Point, to: Point, waypoints: Point[], proxyUrl: string): Promise<Route>;
7
8
  export declare function googleServiceApiDrivingRoute(from: Point, to: Point, waypoints: Point[], proxyUrl: string): Promise<Route>;
@@ -1,7 +1,8 @@
1
1
  import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
2
2
  import { apiGoogleDirections } from "../api/googleDirections.js";
3
3
  import { apiGoogleRoutes } from "../api/googleRoutes.js";
4
- import { vec2lnglat, amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
4
+ import { inDiffArea } from "../hooks/useMapInChina.js";
5
+ import { toLocalWgs84Force, vec2lnglat, amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
5
6
  const amapTmcs2trafficJams = (tmcs) => {
6
7
  const trafficJams = {};
7
8
  let prevStatus = "UNKNOWN";
@@ -67,7 +68,7 @@ function amapJsApiDrivingRoute(from, to, waypoints, amapDriving) {
67
68
  );
68
69
  });
69
70
  }
70
- async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
71
+ async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl, mapSupplier) {
71
72
  const { status, routes, error_message } = await apiGaodeDirectionDriving({
72
73
  proxyUrl,
73
74
  origin: [from],
@@ -85,7 +86,12 @@ async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
85
86
  return { path: [], distance: 0, duration: 0, steps: [] };
86
87
  for (const step of firstRoute.steps) {
87
88
  const basicStep = step;
88
- const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
89
+ const stepPath = basicStep.path.map(({ lng, lat }) => {
90
+ const needTransform = mapSupplier === "gmap" && inDiffArea([lng, lat]);
91
+ if (needTransform)
92
+ return toLocalWgs84Force([lng, lat], "gcj02");
93
+ return [lng, lat];
94
+ });
89
95
  path = path.concat(stepPath);
90
96
  Object.assign(trafficJams, amapTmcs2trafficJams(basicStep.tmcs));
91
97
  routeSteps.push({
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.21.0-gmapCost2";
3
+ const pkgVersion = "2.21.0-gmapCost4";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
package/dist/v3/App.js CHANGED
@@ -1,14 +1,14 @@
1
1
  import { createVNode } from "vue";
2
2
  import { defineComponent, ref } from "vue-demi";
3
3
  import { MapProvider } from "./components/MapProvider/MapProvider.js";
4
- import { DemoBusinessRecomendPlace } from "./Demo/DemoBusinessRecomendPlace.js";
4
+ import { DemoBusinessQuoting } from "./Demo/DemoBusinessQuoting.js";
5
5
  const gmapApiKey = {}.VITE_GMAP_API_KEY;
6
6
  const gmapId = {}.VITE_GMAP_MAP_ID;
7
7
  const amapApiKey = {}.VITE_AMAP_API_KEY;
8
8
  const amapApiSecret = {}.VITE_AMAP_API_SECRET;
9
9
  const App = /* @__PURE__ */ defineComponent({
10
10
  setup() {
11
- const supplierRef = ref("amap");
11
+ const supplierRef = ref("gmap");
12
12
  window.supplierRef = supplierRef;
13
13
  return () => createVNode(MapProvider, {
14
14
  "amapKey": amapApiKey,
@@ -20,6 +20,7 @@ const App = /* @__PURE__ */ defineComponent({
20
20
  "gaodeRegeoProxyUrl": "/overseas/amap/regeo",
21
21
  "googleRegeoProxyUrl": "/overseas/maps/regeo",
22
22
  "hkGovernRegeoProxyUrl": "/overseas/gov/hk/identify",
23
+ "gaodeDirectionDrivingProxyUrl": "/overseas/amap/driveGuide",
23
24
  "googleSnapRoadProxyUrl": "/overseas/maps/snapToRoads",
24
25
  "googleRoutesProxyUrl": "/overseas/maps/routes/directions/v2",
25
26
  "themeVariables": {
@@ -49,7 +50,7 @@ const App = /* @__PURE__ */ defineComponent({
49
50
  "onDownloadOptimizeEnd": () => console.log(`${supplierRef.value} load download optimize end`),
50
51
  "reportLog": () => console.log("reportLog function is called")
51
52
  }, {
52
- default: () => [createVNode(DemoBusinessRecomendPlace, null, null)]
53
+ default: () => [createVNode(DemoBusinessQuoting, null, null)]
53
54
  });
54
55
  }
55
56
  });
@@ -18,11 +18,11 @@ const DemoBusinessQuoting = /* @__PURE__ */ defineComponent({
18
18
  data() {
19
19
  return {
20
20
  from: {
21
- displayName: "my",
22
- name: "my",
23
- type: "gcj02",
24
- lat: 31.205478,
25
- lng: 121.409535
21
+ displayName: "铜锣湾花园",
22
+ name: "铜锣湾花园",
23
+ type: "wgs84",
24
+ lat: 22.283107097738952,
25
+ lng: 114.18577528478997
26
26
  }
27
27
  };
28
28
  },
@@ -50,8 +50,8 @@ const DemoBusinessQuoting = /* @__PURE__ */ defineComponent({
50
50
  displayName: "CDG Engie Charging Station",
51
51
  name: "21 Kent Ridge Rd, Singapore 119220",
52
52
  type: "gcj02",
53
- lat: 31.207082,
54
- lng: 121.407967
53
+ lat: 22.244887,
54
+ lng: 114.294277
55
55
  },
56
56
  "fromDescription": "您将在此上车",
57
57
  "renderDescription": ({
@@ -17,7 +17,7 @@ const useADrivingRoute = (props) => {
17
17
  });
18
18
  const amapDriving = new AMap.Driving({ ferry: 1 });
19
19
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
20
- return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
20
+ return googleRoutesProxyUrl && inTaiwan(from) ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gaodeDirectionDrivingProxyUrl ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl, "amap") : amapJsApiDrivingRoute(from, to, waypoints, amapDriving);
21
21
  };
22
22
  watchPostEffectForDeepOption(
23
23
  () => {
@@ -48,7 +48,7 @@ const useGDrivingRoute = (props) => {
48
48
  });
49
49
  const gmapDirectionsService = new google.maps.DirectionsService();
50
50
  const apiMapDrivingRoute = (from, to, waypoints = []) => {
51
- return gaodeDirectionDrivingProxyUrl && !inTaiwan(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl) : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
51
+ return gaodeDirectionDrivingProxyUrl && !inTaiwan(from) ? gaodeServiceApiDrivingRoute(from, to, waypoints, gaodeDirectionDrivingProxyUrl, "gmap") : googleRoutesProxyUrl ? googleServiceApiDrivingRoute(from, to, waypoints, googleRoutesProxyUrl) : gmapJsApiDrivingRoute(from, to, waypoints, gmapDirectionsService);
52
52
  };
53
53
  watchPostEffectForDeepOption(
54
54
  () => {
@@ -7,7 +7,7 @@ const GEO_TIMEOUT = 5e3;
7
7
  const singleGeoWatch = new SingleGeoWatch({
8
8
  timeout: GEO_TIMEOUT,
9
9
  maximumAge: 0,
10
- enableHighAccuracy: false
10
+ enableHighAccuracy: true
11
11
  });
12
12
  const useGeoLocation = (props) => {
13
13
  var _a, _b;
@@ -1,5 +1,5 @@
1
1
  import { e as exported } from "../chunks/gcoord.esm-bundler.3f2f1369.js";
2
- import { inChina, inHongkong, inMacau } from "./useMapInChina.js";
2
+ import { inChina, inDiffArea } from "./useMapInChina.js";
3
3
  import { useMapSupplier } from "./useMapSupplier.js";
4
4
  const useAmapGCJ02 = () => {
5
5
  const toCoordinateType = (p) => {
@@ -48,11 +48,11 @@ const useAmapGCJ02 = () => {
48
48
  };
49
49
  const useGmapGCJ02 = () => {
50
50
  const toCoordinateType = (p) => {
51
- return inChina(p) && !inHongkong(p) && !inMacau(p) ? "gcj02" : "wgs84";
51
+ return inChina(p) && !inDiffArea(p) ? "gcj02" : "wgs84";
52
52
  };
53
53
  const toLocalGcj02 = (point) => {
54
54
  try {
55
- if (!inChina(point) || inHongkong(point) || inMacau(point))
55
+ if (!inChina(point) || inDiffArea(point))
56
56
  return point;
57
57
  return exported.transform(point, exported.WGS84, exported.GCJ02);
58
58
  } catch (err) {
@@ -65,7 +65,7 @@ const useGmapGCJ02 = () => {
65
65
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
66
66
  const toLocalWgs84 = (point) => {
67
67
  try {
68
- if (inChina(point) && !inHongkong(point) && !inMacau(point))
68
+ if (inChina(point) && !inDiffArea(point))
69
69
  return point;
70
70
  return exported.transform(point, exported.GCJ02, exported.WGS1984);
71
71
  } catch (err) {
@@ -4,3 +4,4 @@ export declare const inHongkong: (point: Point) => boolean;
4
4
  export declare const inMacau: (point: Point) => boolean;
5
5
  export declare const inTaiwan: (point: Point) => boolean;
6
6
  export declare const inKorean: (point: Point) => boolean;
7
+ export declare const inDiffArea: (p: Point) => boolean;
@@ -2792,8 +2792,12 @@ const inTaiwan = (point) => {
2792
2792
  const inKorean = (point) => {
2793
2793
  return pointInPolygon(point, koreanBounds) >= 0;
2794
2794
  };
2795
+ const inDiffArea = (p) => {
2796
+ return inHongkong(p) || inMacau(p);
2797
+ };
2795
2798
  export {
2796
2799
  inChina,
2800
+ inDiffArea,
2797
2801
  inHongkong,
2798
2802
  inKorean,
2799
2803
  inMacau,
@@ -173,7 +173,7 @@ const useGmapPlace = (props) => {
173
173
  };
174
174
  console.log("==港府接口返回结果==", JSON.stringify(addressInfo));
175
175
  resolve(addressInfo);
176
- });
176
+ }).finally(() => clearTimeout(timer));
177
177
  await sleep(HK_GOVERN_API_TIMEOUT);
178
178
  if ((_a = props.findAttachedPlaceDone) == null ? void 0 : _a.value)
179
179
  return;
@@ -203,7 +203,7 @@ const useGmapPlace = (props) => {
203
203
  };
204
204
  console.log("==谷歌逆地理返回结果==", JSON.stringify(addressInfo));
205
205
  resolve(addressInfo);
206
- }).catch(handleFailed);
206
+ }).catch(handleFailed).finally(() => clearTimeout(timer));
207
207
  } else {
208
208
  const geocoder = new google.maps.Geocoder();
209
209
  geocoder.geocode({ language, location: { lng, lat } }).finally(() => clearTimeout(timer)).then(({ results }) => {
package/dist/v3/index.js CHANGED
@@ -32,7 +32,7 @@ import { useMapGeometry } from "./hooks/useMapGeometry.js";
32
32
  import { useMapPlace } from "./hooks/useMapPlace.js";
33
33
  import { useMapRecomendPlace } from "./hooks/useMapRecomendPlace.js";
34
34
  import { useWalkingRoute } from "./hooks/useWalkingRoute.js";
35
- import { inChina, inHongkong, inKorean, inMacau, inTaiwan } from "./hooks/useMapInChina.js";
35
+ import { inChina, inDiffArea, inHongkong, inKorean, inMacau, inTaiwan } from "./hooks/useMapInChina.js";
36
36
  import { CenterPlaceStatus, PointSource } from "./types/interface.js";
37
37
  import { MINI_PROGRAM_WEB_VIEW_CLOSE_EVENT, MINI_PROGRAM_WEB_VIEW_CLOSE_TIMEOUT, patchMiniprogramRedirectTo } from "./utils/patchMiniprogram.js";
38
38
  export {
@@ -59,6 +59,7 @@ export {
59
59
  WalkingRoute,
60
60
  WaveCircle,
61
61
  inChina,
62
+ inDiffArea,
62
63
  inHongkong,
63
64
  inKorean,
64
65
  inMacau,
@@ -1,7 +1,8 @@
1
1
  /// <reference types="google.maps" />
2
+ import type { MapSupplier } from "../hooks/useMapLoader";
2
3
  import type { Point, Route } from "../types/interface";
3
4
  export declare function amapJsApiDrivingRoute(from: Point, to: Point, waypoints: Point[], amapDriving: AMap.Driving): Promise<Route>;
4
- export declare function gaodeServiceApiDrivingRoute(from: Point, to: Point, waypoints: Point[], proxyUrl: string): Promise<Route>;
5
+ export declare function gaodeServiceApiDrivingRoute(from: Point, to: Point, waypoints: Point[], proxyUrl: string, mapSupplier: MapSupplier): Promise<Route>;
5
6
  export declare function gmapJsApiDrivingRoute(from: Point, to: Point, waypoints: Point[], gmapDirectionsService: google.maps.DirectionsService): Promise<Route>;
6
7
  export declare function googleServiceApiDrivingDirection(from: Point, to: Point, waypoints: Point[], proxyUrl: string): Promise<Route>;
7
8
  export declare function googleServiceApiDrivingRoute(from: Point, to: Point, waypoints: Point[], proxyUrl: string): Promise<Route>;
@@ -1,7 +1,8 @@
1
1
  import { apiGaodeDirectionDriving } from "../api/gaodeDirectionDriving.js";
2
2
  import { apiGoogleDirections } from "../api/googleDirections.js";
3
3
  import { apiGoogleRoutes } from "../api/googleRoutes.js";
4
- import { vec2lnglat, amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
4
+ import { inDiffArea } from "../hooks/useMapInChina.js";
5
+ import { toLocalWgs84Force, vec2lnglat, amapTraffic2trafficStatus, stringifyPoint } from "./transform.js";
5
6
  const amapTmcs2trafficJams = (tmcs) => {
6
7
  const trafficJams = {};
7
8
  let prevStatus = "UNKNOWN";
@@ -67,7 +68,7 @@ function amapJsApiDrivingRoute(from, to, waypoints, amapDriving) {
67
68
  );
68
69
  });
69
70
  }
70
- async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
71
+ async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl, mapSupplier) {
71
72
  const { status, routes, error_message } = await apiGaodeDirectionDriving({
72
73
  proxyUrl,
73
74
  origin: [from],
@@ -85,7 +86,12 @@ async function gaodeServiceApiDrivingRoute(from, to, waypoints, proxyUrl) {
85
86
  return { path: [], distance: 0, duration: 0, steps: [] };
86
87
  for (const step of firstRoute.steps) {
87
88
  const basicStep = step;
88
- const stepPath = basicStep.path.map(({ lng, lat }) => [lng, lat]);
89
+ const stepPath = basicStep.path.map(({ lng, lat }) => {
90
+ const needTransform = mapSupplier === "gmap" && inDiffArea([lng, lat]);
91
+ if (needTransform)
92
+ return toLocalWgs84Force([lng, lat], "gcj02");
93
+ return [lng, lat];
94
+ });
89
95
  path = path.concat(stepPath);
90
96
  Object.assign(trafficJams, amapTmcs2trafficJams(basicStep.tmcs));
91
97
  routeSteps.push({
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.21.0-gmapCost2";
3
+ const pkgVersion = "2.21.0-gmapCost4";
4
4
  const spaceLogSessionKey = "wiajlf;jwiatitruiq3jrlw";
5
5
  const enableSessionLogKey = (key) => {
6
6
  const sessionParam = new URLSearchParams(sessionStorage.getItem(spaceLogSessionKey) || void 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heycar/heycars-map",
3
- "version": "2.21.0-gmapCost2",
3
+ "version": "2.21.0-gmapCost4",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",