tg-map-vue3 3.3.8 → 3.3.9

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.
@@ -2,6 +2,7 @@
2
2
  /// <reference types="google.maps" />
3
3
  /// <reference types="heremaps" />
4
4
  import { type LngLatTuple } from 'coordtransform';
5
+ import { type StringEnumValue } from '../components';
5
6
  export declare enum CoordType {
6
7
  wgs84 = "wgs84",
7
8
  gcj02 = "gcj02",
@@ -29,17 +30,20 @@ export declare class LatLng {
29
30
  static fromLngLat(lng: number, lat: number, coord?: CoordType): LatLng;
30
31
  static create(lat: number, lng: number, coord?: CoordType): LatLng;
31
32
  constructor(lat: number, lng: number, coord: CoordType);
32
- to(coord: CoordType): LatLng;
33
+ /** 转换坐标到指定坐标系 */
34
+ to(coordType: StringEnumValue<typeof CoordType>): LatLng;
33
35
  toBaidu(coord: CoordType): BMap.Point;
34
36
  toGoogle(coord: CoordType): google.maps.LatLng;
35
37
  toHere(coord: CoordType): H.geo.Point;
36
38
  /**
37
39
  * 该方法之所以设计的这么不友好, 是为了防止不必要的开销(大概有点影响😅)
38
40
  *
41
+ * 私有方法, 外部需要转换坐标系, 请使用{@link to}/toBaidu/Google/Here, 之所以不添加private关键字, 是因为设成私有后, 有的地方会报类型错误...
42
+ *
39
43
  * @returns `[lng, lat]` 注意不要取错顺序
40
44
  * @throws 若当前coord和targetCoord相同, 会抛异常, 故请在外部判断
41
45
  */
42
- convert(targetCoord: CoordType): LngLatTuple;
46
+ _convert(targetCoord: CoordType): LngLatTuple;
43
47
  equals(other: LatLng): boolean;
44
48
  toString(): string;
45
49
  }
package/dist/tg-map.js CHANGED
@@ -167,33 +167,36 @@ const ze = "wgs84", A = class {
167
167
  static create(e, t, r = ze) {
168
168
  return new A(e, t, r);
169
169
  }
170
+ /** 转换坐标到指定坐标系 */
170
171
  to(e) {
171
- if (this.coord === e)
172
+ const t = e;
173
+ if (this.coord === t)
172
174
  return this;
173
- const [t, r] = this.convert(e);
174
- return new A(r, t, e);
175
+ const [r, s] = this._convert(t);
176
+ return new A(s, r, t);
175
177
  }
176
178
  toBaidu(e) {
177
179
  let t = this.lat, r = this.lng;
178
- return this.coord !== e && ([r, t] = this.convert(e)), new BMap.Point(r, t);
180
+ return this.coord !== e && ([r, t] = this._convert(e)), new BMap.Point(r, t);
179
181
  }
180
182
  toGoogle(e) {
181
183
  let t = this.lat, r = this.lng;
182
- return this.coord !== e && ([r, t] = this.convert(e)), new google.maps.LatLng(t, r);
184
+ return this.coord !== e && ([r, t] = this._convert(e)), new google.maps.LatLng(t, r);
183
185
  }
184
186
  toHere(e) {
185
187
  let t = this.lat, r = this.lng;
186
- return this.coord !== e && ([r, t] = this.convert(e)), new H.geo.Point(t, r);
188
+ return this.coord !== e && ([r, t] = this._convert(e)), new H.geo.Point(t, r);
187
189
  }
188
190
  /**
189
191
  * 该方法之所以设计的这么不友好, 是为了防止不必要的开销(大概有点影响😅)
190
192
  *
193
+ * 私有方法, 外部需要转换坐标系, 请使用{@link to}/toBaidu/Google/Here, 之所以不添加private关键字, 是因为设成私有后, 有的地方会报类型错误...
194
+ *
191
195
  * @returns `[lng, lat]` 注意不要取错顺序
192
196
  * @throws 若当前coord和targetCoord相同, 会抛异常, 故请在外部判断
193
197
  */
194
- // TODO: 2023/03/14 ipcjs 这里设成private, 有些地方会报类型错误...
195
198
  /* private */
196
- convert(e) {
199
+ _convert(e) {
197
200
  switch (this.coord) {
198
201
  case "bd09":
199
202
  return e === "gcj02" ? re.bd09ToGcj02(this.lng, this.lat) : re.bd09ToWgs84(this.lng, this.lat);