@heycar/heycars-map 2.4.0 → 2.4.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.
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from "./v3"
1
+ export * from "./v2"
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export * from "./v3"
1
+ export * from "./v2"
@@ -14,7 +14,6 @@ export declare const useCacheCenterPlace: (props: UseDefaultCenterPlaceProps) =>
14
14
  };
15
15
  geoDefaultPosition: Point;
16
16
  defaultCenterPlace: {
17
- type?: import("../../types/interface").CoordinateType | undefined;
18
17
  lng: number;
19
18
  lat: number;
20
19
  name: string;
@@ -1,18 +1,21 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { apiGetCenterPlaceFromCache } from "../../api/browser.js";
3
3
  import { apiMemoryShouldSkipByKey } from "../../api/memory.js";
4
+ import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
4
5
  import { maybeFunctionToFunction, lnglat2point } from "../../utils/transform.js";
5
6
  const IS_FIRST_LOAD_KEY = "IS_FIRST_LOAD_KEY";
6
7
  const useCacheCenterPlace = (props) => {
7
8
  const { geoLoadingTitle, emptyTitle } = props;
8
9
  const isFirstLoad = !apiMemoryShouldSkipByKey(IS_FIRST_LOAD_KEY);
9
10
  const getDefaultCenterPlace = maybeFunctionToFunction(props.defaultCenterPlace);
11
+ const { unCoordinatifyPlace } = useMapCoordinatify();
12
+ const inputDefaultCenterPlace = getDefaultCenterPlace == null ? void 0 : getDefaultCenterPlace(apiGetCenterPlaceFromCache());
10
13
  const defaultCenterPlace = {
11
14
  lng: 0,
12
15
  lat: 0,
13
16
  name: emptyTitle,
14
17
  displayName: emptyTitle,
15
- ...getDefaultCenterPlace == null ? void 0 : getDefaultCenterPlace(apiGetCenterPlaceFromCache())
18
+ ...inputDefaultCenterPlace ? unCoordinatifyPlace(inputDefaultCenterPlace) : void 0
16
19
  };
17
20
  const geoDefaultPosition = defaultCenterPlace ? lnglat2point(defaultCenterPlace) : [0, 0];
18
21
  const centerPlace = reactive({
@@ -1,6 +1,7 @@
1
1
  import { useMapGCJ02 } from "./useMapGCJ02.js";
2
+ import { inChina } from "./useMapInChina.js";
2
3
  function useMapCoordinatify() {
3
- const { toCoordinateType, toLocalGcj02 } = useMapGCJ02();
4
+ const { toCoordinateType, toLocalGcj02, toLocalWgs84 } = useMapGCJ02();
4
5
  const coordinatifyPoint = (value) => {
5
6
  const [lng, lat] = value;
6
7
  return { lng, lat, type: toCoordinateType(value) };
@@ -11,7 +12,9 @@ function useMapCoordinatify() {
11
12
  if (type === inputType)
12
13
  return [lng, lat];
13
14
  if (type === "wgs84") {
14
- throw new Error(`国外经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
15
+ if (!inChina([lng, lat]))
16
+ throw new Error(`国外经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
17
+ return toLocalWgs84([lng, lat]);
15
18
  }
16
19
  return toLocalGcj02([lng, lat]);
17
20
  };
@@ -5,6 +5,7 @@ export declare const useAmapGCJ02: () => {
5
5
  toGcj02Points: (points: Point[]) => Promise<Point[]>;
6
6
  toLocalGcj02: (point: Point) => Point;
7
7
  toLocalGcj02Points: (points: Point[]) => Point[];
8
+ toLocalWgs84: (point: Point) => Point;
8
9
  };
9
10
  export declare const useGmapGCJ02: () => {
10
11
  toCoordinateType: (p: Point) => CoordinateType;
@@ -12,6 +13,7 @@ export declare const useGmapGCJ02: () => {
12
13
  toGcj02Points: (points: Point[]) => Promise<Point[]>;
13
14
  toLocalGcj02: (point: Point) => Point;
14
15
  toLocalGcj02Points: (points: Point[]) => Point[];
16
+ toLocalWgs84: (point: Point) => Point;
15
17
  };
16
18
  export declare const useMapGCJ02: () => {
17
19
  toCoordinateType: (p: Point) => CoordinateType;
@@ -19,4 +21,5 @@ export declare const useMapGCJ02: () => {
19
21
  toGcj02Points: (points: Point[]) => Promise<Point[]>;
20
22
  toLocalGcj02: (point: Point) => Point;
21
23
  toLocalGcj02Points: (points: Point[]) => Point[];
24
+ toLocalWgs84: (point: Point) => Point;
22
25
  };
@@ -528,13 +528,23 @@ const useAmapGCJ02 = () => {
528
528
  }
529
529
  };
530
530
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
531
+ const toLocalWgs84 = (point) => {
532
+ throw new Error(`高德地图为什么要转 wgs84: ${JSON.stringify(point)}`);
533
+ };
531
534
  const toGcj02Points = async (points) => {
532
535
  return toLocalGcj02Points(points);
533
536
  };
534
537
  function toGcj02(point) {
535
538
  return toGcj02Points([point]).then(([result]) => result);
536
539
  }
537
- return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
540
+ return {
541
+ toCoordinateType,
542
+ toGcj02,
543
+ toGcj02Points,
544
+ toLocalGcj02,
545
+ toLocalGcj02Points,
546
+ toLocalWgs84
547
+ };
538
548
  };
539
549
  const useGmapGCJ02 = () => {
540
550
  const toCoordinateType = (p) => {
@@ -553,13 +563,32 @@ const useGmapGCJ02 = () => {
553
563
  }
554
564
  };
555
565
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
566
+ const toLocalWgs84 = (point) => {
567
+ try {
568
+ if (inChina(point) && !inHongkong(point) && !inMacau(point))
569
+ return point;
570
+ return exported.transform(point, exported.GCJ02, exported.WGS1984);
571
+ } catch (err) {
572
+ const error = err;
573
+ console.error(`本地转换WGS84失败: ${error.message}
574
+ ${error.stack}`);
575
+ return point;
576
+ }
577
+ };
556
578
  const toGcj02 = async (point) => {
557
579
  return toLocalGcj02Points([point])[0];
558
580
  };
559
581
  const toGcj02Points = async (points) => {
560
582
  return toLocalGcj02Points(points);
561
583
  };
562
- return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
584
+ return {
585
+ toCoordinateType,
586
+ toGcj02,
587
+ toGcj02Points,
588
+ toLocalGcj02,
589
+ toLocalGcj02Points,
590
+ toLocalWgs84
591
+ };
563
592
  };
564
593
  const useMapGCJ02 = () => {
565
594
  const { supplier } = useMapSupplier();
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.4.0";
3
+ const pkgVersion = "2.4.1";
4
4
  const isEnableLog = (name) => {
5
5
  const searchParam = new URLSearchParams(location.search);
6
6
  return searchParam.has(`log-${name}`);
@@ -14,7 +14,6 @@ export declare const useCacheCenterPlace: (props: UseDefaultCenterPlaceProps) =>
14
14
  };
15
15
  geoDefaultPosition: Point;
16
16
  defaultCenterPlace: {
17
- type?: import("../../types/interface").CoordinateType | undefined;
18
17
  lng: number;
19
18
  lat: number;
20
19
  name: string;
@@ -1,18 +1,21 @@
1
1
  import { reactive } from "vue-demi";
2
2
  import { apiGetCenterPlaceFromCache } from "../../api/browser.js";
3
3
  import { apiMemoryShouldSkipByKey } from "../../api/memory.js";
4
+ import { useMapCoordinatify } from "../../hooks/useMapCoordinatify.js";
4
5
  import { maybeFunctionToFunction, lnglat2point } from "../../utils/transform.js";
5
6
  const IS_FIRST_LOAD_KEY = "IS_FIRST_LOAD_KEY";
6
7
  const useCacheCenterPlace = (props) => {
7
8
  const { geoLoadingTitle, emptyTitle } = props;
8
9
  const isFirstLoad = !apiMemoryShouldSkipByKey(IS_FIRST_LOAD_KEY);
9
10
  const getDefaultCenterPlace = maybeFunctionToFunction(props.defaultCenterPlace);
11
+ const { unCoordinatifyPlace } = useMapCoordinatify();
12
+ const inputDefaultCenterPlace = getDefaultCenterPlace == null ? void 0 : getDefaultCenterPlace(apiGetCenterPlaceFromCache());
10
13
  const defaultCenterPlace = {
11
14
  lng: 0,
12
15
  lat: 0,
13
16
  name: emptyTitle,
14
17
  displayName: emptyTitle,
15
- ...getDefaultCenterPlace == null ? void 0 : getDefaultCenterPlace(apiGetCenterPlaceFromCache())
18
+ ...inputDefaultCenterPlace ? unCoordinatifyPlace(inputDefaultCenterPlace) : void 0
16
19
  };
17
20
  const geoDefaultPosition = defaultCenterPlace ? lnglat2point(defaultCenterPlace) : [0, 0];
18
21
  const centerPlace = reactive({
@@ -1,6 +1,7 @@
1
1
  import { useMapGCJ02 } from "./useMapGCJ02.js";
2
+ import { inChina } from "./useMapInChina.js";
2
3
  function useMapCoordinatify() {
3
- const { toCoordinateType, toLocalGcj02 } = useMapGCJ02();
4
+ const { toCoordinateType, toLocalGcj02, toLocalWgs84 } = useMapGCJ02();
4
5
  const coordinatifyPoint = (value) => {
5
6
  const [lng, lat] = value;
6
7
  return { lng, lat, type: toCoordinateType(value) };
@@ -11,7 +12,9 @@ function useMapCoordinatify() {
11
12
  if (type === inputType)
12
13
  return [lng, lat];
13
14
  if (type === "wgs84") {
14
- throw new Error(`国外经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
15
+ if (!inChina([lng, lat]))
16
+ throw new Error(`国外经纬度收到火星坐标系数据: ${JSON.stringify(value)}`);
17
+ return toLocalWgs84([lng, lat]);
15
18
  }
16
19
  return toLocalGcj02([lng, lat]);
17
20
  };
@@ -5,6 +5,7 @@ export declare const useAmapGCJ02: () => {
5
5
  toGcj02Points: (points: Point[]) => Promise<Point[]>;
6
6
  toLocalGcj02: (point: Point) => Point;
7
7
  toLocalGcj02Points: (points: Point[]) => Point[];
8
+ toLocalWgs84: (point: Point) => Point;
8
9
  };
9
10
  export declare const useGmapGCJ02: () => {
10
11
  toCoordinateType: (p: Point) => CoordinateType;
@@ -12,6 +13,7 @@ export declare const useGmapGCJ02: () => {
12
13
  toGcj02Points: (points: Point[]) => Promise<Point[]>;
13
14
  toLocalGcj02: (point: Point) => Point;
14
15
  toLocalGcj02Points: (points: Point[]) => Point[];
16
+ toLocalWgs84: (point: Point) => Point;
15
17
  };
16
18
  export declare const useMapGCJ02: () => {
17
19
  toCoordinateType: (p: Point) => CoordinateType;
@@ -19,4 +21,5 @@ export declare const useMapGCJ02: () => {
19
21
  toGcj02Points: (points: Point[]) => Promise<Point[]>;
20
22
  toLocalGcj02: (point: Point) => Point;
21
23
  toLocalGcj02Points: (points: Point[]) => Point[];
24
+ toLocalWgs84: (point: Point) => Point;
22
25
  };
@@ -528,13 +528,23 @@ const useAmapGCJ02 = () => {
528
528
  }
529
529
  };
530
530
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
531
+ const toLocalWgs84 = (point) => {
532
+ throw new Error(`高德地图为什么要转 wgs84: ${JSON.stringify(point)}`);
533
+ };
531
534
  const toGcj02Points = async (points) => {
532
535
  return toLocalGcj02Points(points);
533
536
  };
534
537
  function toGcj02(point) {
535
538
  return toGcj02Points([point]).then(([result]) => result);
536
539
  }
537
- return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
540
+ return {
541
+ toCoordinateType,
542
+ toGcj02,
543
+ toGcj02Points,
544
+ toLocalGcj02,
545
+ toLocalGcj02Points,
546
+ toLocalWgs84
547
+ };
538
548
  };
539
549
  const useGmapGCJ02 = () => {
540
550
  const toCoordinateType = (p) => {
@@ -553,13 +563,32 @@ const useGmapGCJ02 = () => {
553
563
  }
554
564
  };
555
565
  const toLocalGcj02Points = (points) => points.map(toLocalGcj02);
566
+ const toLocalWgs84 = (point) => {
567
+ try {
568
+ if (inChina(point) && !inHongkong(point) && !inMacau(point))
569
+ return point;
570
+ return exported.transform(point, exported.GCJ02, exported.WGS1984);
571
+ } catch (err) {
572
+ const error = err;
573
+ console.error(`本地转换WGS84失败: ${error.message}
574
+ ${error.stack}`);
575
+ return point;
576
+ }
577
+ };
556
578
  const toGcj02 = async (point) => {
557
579
  return toLocalGcj02Points([point])[0];
558
580
  };
559
581
  const toGcj02Points = async (points) => {
560
582
  return toLocalGcj02Points(points);
561
583
  };
562
- return { toCoordinateType, toGcj02, toGcj02Points, toLocalGcj02, toLocalGcj02Points };
584
+ return {
585
+ toCoordinateType,
586
+ toGcj02,
587
+ toGcj02Points,
588
+ toLocalGcj02,
589
+ toLocalGcj02Points,
590
+ toLocalWgs84
591
+ };
563
592
  };
564
593
  const useMapGCJ02 = () => {
565
594
  const { supplier } = useMapSupplier();
@@ -1,6 +1,6 @@
1
1
  const availableLogKeys = /* @__PURE__ */ new Set();
2
2
  const pkgName = "@heycar/heycars-map";
3
- const pkgVersion = "2.4.0";
3
+ const pkgVersion = "2.4.1";
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.4.0",
3
+ "version": "2.4.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "checkVersion": "./bin/checkVersion.js",