xy-map 1.1.44 → 1.1.46

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "xy-map",
3
- "version": "1.1.44",
3
+ "version": "1.1.46",
4
4
  "description": "雄越地图",
5
5
  "main": "xy-map.umd.min.js",
6
6
  "scripts": {
7
- "pub": "npm publish --registry=https://registry.npmjs.org/"
7
+ "pub": "npm publish --force --registry=https://registry.npm.taobao.org/"
8
8
  },
9
9
  "keywords": [],
10
10
  "author": "hanjing",
package/xy-map.common.js CHANGED
@@ -70755,6 +70755,11 @@ function closeMeasureArea(map) {
70755
70755
 
70756
70756
 
70757
70757
 
70758
+ // 常量定义
70759
+ const PI = Math.PI;
70760
+ const a = 6378245.0; // 长半轴
70761
+ const ee = 0.00669342162296594323; // 偏心率平方
70762
+
70758
70763
  // list转geoJson
70759
70764
  const toGeoJson = (list, type, props = 'position') => {
70760
70765
  let pointsData = list.map((item, index) => {
@@ -70808,6 +70813,36 @@ const geometryCollectionToFeatureCollection = geometryCollection => {
70808
70813
  return featureCollection;
70809
70814
  };
70810
70815
 
70816
+ // WGS84转高德坐标系
70817
+ const wgs84ToGcj02 = coord => {
70818
+ // 输入检查
70819
+ if (!Array.isArray(coord) || coord.length !== 2) {
70820
+ throw new Error('Input must be an array with [longitude, latitude]');
70821
+ }
70822
+ let [lng, lat] = coord.map(Number);
70823
+
70824
+ // 检查输入是否为有效数字
70825
+ if (isNaN(lng) || isNaN(lat)) {
70826
+ throw new Error('Coordinates must be valid numbers');
70827
+ }
70828
+
70829
+ // 如果不在中国范围内,直接返回原坐标
70830
+ if (outOfChina(lng, lat)) {
70831
+ return [lng, lat];
70832
+ }
70833
+ let dLat = transformLat(lng - 105.0, lat - 35.0);
70834
+ let dLng = transformLng(lng - 105.0, lat - 35.0);
70835
+ let radLat = lat / 180.0 * PI;
70836
+ let magic = Math.sin(radLat);
70837
+ magic = 1 - ee * magic * magic;
70838
+ let sqrtMagic = Math.sqrt(magic);
70839
+ dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * PI);
70840
+ dLng = dLng * 180.0 / (a / sqrtMagic * Math.cos(radLat) * PI);
70841
+ let gcjLat = lat + dLat;
70842
+ let gcjLng = lng + dLng;
70843
+ return [gcjLng, gcjLat];
70844
+ };
70845
+
70811
70846
  // 3857墨卡托坐标系转换为4326 (WGS84)经纬度坐标
70812
70847
  const mercatorTolonlat = Json => {
70813
70848
  Json.features.forEach(item => {
@@ -70829,6 +70864,28 @@ const mercatorTolonlat = Json => {
70829
70864
  return coord;
70830
70865
  }
70831
70866
  };
70867
+ // 判断坐标是否在中国范围内
70868
+ function outOfChina(lng, lat) {
70869
+ return lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271;
70870
+ }
70871
+
70872
+ // 变换纬度
70873
+ function transformLat(x, y) {
70874
+ let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
70875
+ ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
70876
+ ret += (20.0 * Math.sin(y * PI) + 40.0 * Math.sin(y / 3.0 * PI)) * 2.0 / 3.0;
70877
+ ret += (160.0 * Math.sin(y / 12.0 * PI) + 320 * Math.sin(y * PI / 30.0)) * 2.0 / 3.0;
70878
+ return ret;
70879
+ }
70880
+
70881
+ // 变换经度
70882
+ function transformLng(x, y) {
70883
+ let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
70884
+ ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
70885
+ ret += (20.0 * Math.sin(x * PI) + 40.0 * Math.sin(x / 3.0 * PI)) * 2.0 / 3.0;
70886
+ ret += (150.0 * Math.sin(x / 12.0 * PI) + 300.0 * Math.sin(x / 30.0 * PI)) * 2.0 / 3.0;
70887
+ return ret;
70888
+ }
70832
70889
 
70833
70890
  /**
70834
70891
  * 加载图片
@@ -81507,10 +81564,10 @@ function esm_assert_assert(condition, message) {
81507
81564
 
81508
81565
 
81509
81566
 
81510
- const PI = Math.PI;
81511
- const PI_4 = PI / 4;
81512
- const DEGREES_TO_RADIANS = PI / 180;
81513
- const RADIANS_TO_DEGREES = 180 / PI;
81567
+ const web_mercator_utils_PI = Math.PI;
81568
+ const PI_4 = web_mercator_utils_PI / 4;
81569
+ const DEGREES_TO_RADIANS = web_mercator_utils_PI / 180;
81570
+ const RADIANS_TO_DEGREES = 180 / web_mercator_utils_PI;
81514
81571
  const TILE_SIZE = 512;
81515
81572
  const EARTH_CIRCUMFERENCE = 40.03e6;
81516
81573
  const MAX_LATITUDE = 85.051129;
@@ -81527,14 +81584,14 @@ function web_mercator_utils_lngLatToWorld(lngLat) {
81527
81584
  esm_assert_assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, 'invalid latitude');
81528
81585
  const lambda2 = lng * DEGREES_TO_RADIANS;
81529
81586
  const phi2 = lat * DEGREES_TO_RADIANS;
81530
- const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
81531
- const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
81587
+ const x = TILE_SIZE * (lambda2 + web_mercator_utils_PI) / (2 * web_mercator_utils_PI);
81588
+ const y = TILE_SIZE * (web_mercator_utils_PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * web_mercator_utils_PI);
81532
81589
  return [x, y];
81533
81590
  }
81534
81591
  function web_mercator_utils_worldToLngLat(xy) {
81535
81592
  const [x, y] = xy;
81536
- const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
81537
- const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
81593
+ const lambda2 = x / TILE_SIZE * (2 * web_mercator_utils_PI) - web_mercator_utils_PI;
81594
+ const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * web_mercator_utils_PI) - web_mercator_utils_PI)) - PI_4);
81538
81595
  return [lambda2 * RADIANS_TO_DEGREES, phi2 * RADIANS_TO_DEGREES];
81539
81596
  }
81540
81597
  function getMeterZoom(options) {
@@ -104624,7 +104681,7 @@ function getWebGLContext() {
104624
104681
  ;// CONCATENATED MODULE: ./node_modules/ktx-parse/dist/ktx-parse.modern.js
104625
104682
  const t = new Uint8Array([0]),
104626
104683
  e = (/* unused pure expression or super */ null && ([171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10]));
104627
- var n, i, s, a, r, o, l, f;
104684
+ var n, i, s, ktx_parse_modern_a, r, o, l, f;
104628
104685
  !function (t) {
104629
104686
  t[t.NONE = 0] = "NONE", t[t.BASISLZ = 1] = "BASISLZ", t[t.ZSTD = 2] = "ZSTD", t[t.ZLIB = 3] = "ZLIB";
104630
104687
  }(n || (n = {})), function (t) {
@@ -104633,7 +104690,7 @@ var n, i, s, a, r, o, l, f;
104633
104690
  t[t.UNSPECIFIED = 0] = "UNSPECIFIED", t[t.ETC1S = 163] = "ETC1S", t[t.UASTC = 166] = "UASTC";
104634
104691
  }(s || (s = {})), function (t) {
104635
104692
  t[t.UNSPECIFIED = 0] = "UNSPECIFIED", t[t.SRGB = 1] = "SRGB";
104636
- }(a || (a = {})), function (t) {
104693
+ }(ktx_parse_modern_a || (ktx_parse_modern_a = {})), function (t) {
104637
104694
  t[t.UNSPECIFIED = 0] = "UNSPECIFIED", t[t.LINEAR = 1] = "LINEAR", t[t.SRGB = 2] = "SRGB", t[t.ITU = 3] = "ITU", t[t.NTSC = 4] = "NTSC", t[t.SLOG = 5] = "SLOG", t[t.SLOG2 = 6] = "SLOG2";
104638
104695
  }(r || (r = {})), function (t) {
104639
104696
  t[t.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t[t.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
@@ -104650,8 +104707,8 @@ class U {
104650
104707
  versionNumber: 2,
104651
104708
  descriptorBlockSize: 40,
104652
104709
  colorModel: s.UNSPECIFIED,
104653
- colorPrimaries: a.SRGB,
104654
- transferFunction: a.SRGB,
104710
+ colorPrimaries: ktx_parse_modern_a.SRGB,
104711
+ transferFunction: ktx_parse_modern_a.SRGB,
104655
104712
  flags: o.ALPHA_STRAIGHT,
104656
104713
  texelBlockDimension: {
104657
104714
  x: 4,
@@ -118474,9 +118531,19 @@ const mapHoverHtml = (arr, e, beforeHtml, afterHtml) => {
118474
118531
  ;// CONCATENATED MODULE: ./src/package/util/gaodeApi.js
118475
118532
 
118476
118533
 
118477
- // 获取浏览器定位
118478
- function GeoAddress(lnglat) {
118534
+
118535
+ /**
118536
+ * 获取浏览器定位
118537
+ * @description 通过高德地图API获取当前浏览器的地理位置信息
118538
+ * @property {number} lnglat - [经度,纬度 ]
118539
+ * @property {Boolean} changeCoordinate - 是否将坐标从wgs84转gcj02
118540
+
118541
+ */
118542
+ function GeoAddress(lnglat, changeCoordinate = true) {
118479
118543
  return new Promise(resolve => {
118544
+ if (changeCoordinate) {
118545
+ lnglat = wgs84ToGcj02(lnglat);
118546
+ }
118480
118547
  node_modules_axios.get(`https://restapi.amap.com/v3/geocode/regeo?key=39d46e3fcb4c9740d08e8ecb1f15ff8c&location=${lnglat[0]},${lnglat[1]}&extensions=all`).then(({
118481
118548
  data
118482
118549
  }) => {
package/xy-map.umd.js CHANGED
@@ -70773,6 +70773,11 @@ function closeMeasureArea(map) {
70773
70773
 
70774
70774
 
70775
70775
 
70776
+ // 常量定义
70777
+ const PI = Math.PI;
70778
+ const a = 6378245.0; // 长半轴
70779
+ const ee = 0.00669342162296594323; // 偏心率平方
70780
+
70776
70781
  // list转geoJson
70777
70782
  const toGeoJson = (list, type, props = 'position') => {
70778
70783
  let pointsData = list.map((item, index) => {
@@ -70826,6 +70831,36 @@ const geometryCollectionToFeatureCollection = geometryCollection => {
70826
70831
  return featureCollection;
70827
70832
  };
70828
70833
 
70834
+ // WGS84转高德坐标系
70835
+ const wgs84ToGcj02 = coord => {
70836
+ // 输入检查
70837
+ if (!Array.isArray(coord) || coord.length !== 2) {
70838
+ throw new Error('Input must be an array with [longitude, latitude]');
70839
+ }
70840
+ let [lng, lat] = coord.map(Number);
70841
+
70842
+ // 检查输入是否为有效数字
70843
+ if (isNaN(lng) || isNaN(lat)) {
70844
+ throw new Error('Coordinates must be valid numbers');
70845
+ }
70846
+
70847
+ // 如果不在中国范围内,直接返回原坐标
70848
+ if (outOfChina(lng, lat)) {
70849
+ return [lng, lat];
70850
+ }
70851
+ let dLat = transformLat(lng - 105.0, lat - 35.0);
70852
+ let dLng = transformLng(lng - 105.0, lat - 35.0);
70853
+ let radLat = lat / 180.0 * PI;
70854
+ let magic = Math.sin(radLat);
70855
+ magic = 1 - ee * magic * magic;
70856
+ let sqrtMagic = Math.sqrt(magic);
70857
+ dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * PI);
70858
+ dLng = dLng * 180.0 / (a / sqrtMagic * Math.cos(radLat) * PI);
70859
+ let gcjLat = lat + dLat;
70860
+ let gcjLng = lng + dLng;
70861
+ return [gcjLng, gcjLat];
70862
+ };
70863
+
70829
70864
  // 3857墨卡托坐标系转换为4326 (WGS84)经纬度坐标
70830
70865
  const mercatorTolonlat = Json => {
70831
70866
  Json.features.forEach(item => {
@@ -70847,6 +70882,28 @@ const mercatorTolonlat = Json => {
70847
70882
  return coord;
70848
70883
  }
70849
70884
  };
70885
+ // 判断坐标是否在中国范围内
70886
+ function outOfChina(lng, lat) {
70887
+ return lng < 72.004 || lng > 137.8347 || lat < 0.8293 || lat > 55.8271;
70888
+ }
70889
+
70890
+ // 变换纬度
70891
+ function transformLat(x, y) {
70892
+ let ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x));
70893
+ ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
70894
+ ret += (20.0 * Math.sin(y * PI) + 40.0 * Math.sin(y / 3.0 * PI)) * 2.0 / 3.0;
70895
+ ret += (160.0 * Math.sin(y / 12.0 * PI) + 320 * Math.sin(y * PI / 30.0)) * 2.0 / 3.0;
70896
+ return ret;
70897
+ }
70898
+
70899
+ // 变换经度
70900
+ function transformLng(x, y) {
70901
+ let ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1 * Math.sqrt(Math.abs(x));
70902
+ ret += (20.0 * Math.sin(6.0 * x * PI) + 20.0 * Math.sin(2.0 * x * PI)) * 2.0 / 3.0;
70903
+ ret += (20.0 * Math.sin(x * PI) + 40.0 * Math.sin(x / 3.0 * PI)) * 2.0 / 3.0;
70904
+ ret += (150.0 * Math.sin(x / 12.0 * PI) + 300.0 * Math.sin(x / 30.0 * PI)) * 2.0 / 3.0;
70905
+ return ret;
70906
+ }
70850
70907
 
70851
70908
  /**
70852
70909
  * 加载图片
@@ -81525,10 +81582,10 @@ function esm_assert_assert(condition, message) {
81525
81582
 
81526
81583
 
81527
81584
 
81528
- const PI = Math.PI;
81529
- const PI_4 = PI / 4;
81530
- const DEGREES_TO_RADIANS = PI / 180;
81531
- const RADIANS_TO_DEGREES = 180 / PI;
81585
+ const web_mercator_utils_PI = Math.PI;
81586
+ const PI_4 = web_mercator_utils_PI / 4;
81587
+ const DEGREES_TO_RADIANS = web_mercator_utils_PI / 180;
81588
+ const RADIANS_TO_DEGREES = 180 / web_mercator_utils_PI;
81532
81589
  const TILE_SIZE = 512;
81533
81590
  const EARTH_CIRCUMFERENCE = 40.03e6;
81534
81591
  const MAX_LATITUDE = 85.051129;
@@ -81545,14 +81602,14 @@ function web_mercator_utils_lngLatToWorld(lngLat) {
81545
81602
  esm_assert_assert(Number.isFinite(lat) && lat >= -90 && lat <= 90, 'invalid latitude');
81546
81603
  const lambda2 = lng * DEGREES_TO_RADIANS;
81547
81604
  const phi2 = lat * DEGREES_TO_RADIANS;
81548
- const x = TILE_SIZE * (lambda2 + PI) / (2 * PI);
81549
- const y = TILE_SIZE * (PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * PI);
81605
+ const x = TILE_SIZE * (lambda2 + web_mercator_utils_PI) / (2 * web_mercator_utils_PI);
81606
+ const y = TILE_SIZE * (web_mercator_utils_PI + Math.log(Math.tan(PI_4 + phi2 * 0.5))) / (2 * web_mercator_utils_PI);
81550
81607
  return [x, y];
81551
81608
  }
81552
81609
  function web_mercator_utils_worldToLngLat(xy) {
81553
81610
  const [x, y] = xy;
81554
- const lambda2 = x / TILE_SIZE * (2 * PI) - PI;
81555
- const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * PI) - PI)) - PI_4);
81611
+ const lambda2 = x / TILE_SIZE * (2 * web_mercator_utils_PI) - web_mercator_utils_PI;
81612
+ const phi2 = 2 * (Math.atan(Math.exp(y / TILE_SIZE * (2 * web_mercator_utils_PI) - web_mercator_utils_PI)) - PI_4);
81556
81613
  return [lambda2 * RADIANS_TO_DEGREES, phi2 * RADIANS_TO_DEGREES];
81557
81614
  }
81558
81615
  function getMeterZoom(options) {
@@ -104642,7 +104699,7 @@ function getWebGLContext() {
104642
104699
  ;// CONCATENATED MODULE: ./node_modules/ktx-parse/dist/ktx-parse.modern.js
104643
104700
  const t = new Uint8Array([0]),
104644
104701
  e = (/* unused pure expression or super */ null && ([171, 75, 84, 88, 32, 50, 48, 187, 13, 10, 26, 10]));
104645
- var n, i, s, a, r, o, l, f;
104702
+ var n, i, s, ktx_parse_modern_a, r, o, l, f;
104646
104703
  !function (t) {
104647
104704
  t[t.NONE = 0] = "NONE", t[t.BASISLZ = 1] = "BASISLZ", t[t.ZSTD = 2] = "ZSTD", t[t.ZLIB = 3] = "ZLIB";
104648
104705
  }(n || (n = {})), function (t) {
@@ -104651,7 +104708,7 @@ var n, i, s, a, r, o, l, f;
104651
104708
  t[t.UNSPECIFIED = 0] = "UNSPECIFIED", t[t.ETC1S = 163] = "ETC1S", t[t.UASTC = 166] = "UASTC";
104652
104709
  }(s || (s = {})), function (t) {
104653
104710
  t[t.UNSPECIFIED = 0] = "UNSPECIFIED", t[t.SRGB = 1] = "SRGB";
104654
- }(a || (a = {})), function (t) {
104711
+ }(ktx_parse_modern_a || (ktx_parse_modern_a = {})), function (t) {
104655
104712
  t[t.UNSPECIFIED = 0] = "UNSPECIFIED", t[t.LINEAR = 1] = "LINEAR", t[t.SRGB = 2] = "SRGB", t[t.ITU = 3] = "ITU", t[t.NTSC = 4] = "NTSC", t[t.SLOG = 5] = "SLOG", t[t.SLOG2 = 6] = "SLOG2";
104656
104713
  }(r || (r = {})), function (t) {
104657
104714
  t[t.ALPHA_STRAIGHT = 0] = "ALPHA_STRAIGHT", t[t.ALPHA_PREMULTIPLIED = 1] = "ALPHA_PREMULTIPLIED";
@@ -104668,8 +104725,8 @@ class U {
104668
104725
  versionNumber: 2,
104669
104726
  descriptorBlockSize: 40,
104670
104727
  colorModel: s.UNSPECIFIED,
104671
- colorPrimaries: a.SRGB,
104672
- transferFunction: a.SRGB,
104728
+ colorPrimaries: ktx_parse_modern_a.SRGB,
104729
+ transferFunction: ktx_parse_modern_a.SRGB,
104673
104730
  flags: o.ALPHA_STRAIGHT,
104674
104731
  texelBlockDimension: {
104675
104732
  x: 4,
@@ -118492,9 +118549,19 @@ const mapHoverHtml = (arr, e, beforeHtml, afterHtml) => {
118492
118549
  ;// CONCATENATED MODULE: ./src/package/util/gaodeApi.js
118493
118550
 
118494
118551
 
118495
- // 获取浏览器定位
118496
- function GeoAddress(lnglat) {
118552
+
118553
+ /**
118554
+ * 获取浏览器定位
118555
+ * @description 通过高德地图API获取当前浏览器的地理位置信息
118556
+ * @property {number} lnglat - [经度,纬度 ]
118557
+ * @property {Boolean} changeCoordinate - 是否将坐标从wgs84转gcj02
118558
+
118559
+ */
118560
+ function GeoAddress(lnglat, changeCoordinate = true) {
118497
118561
  return new Promise(resolve => {
118562
+ if (changeCoordinate) {
118563
+ lnglat = wgs84ToGcj02(lnglat);
118564
+ }
118498
118565
  node_modules_axios.get(`https://restapi.amap.com/v3/geocode/regeo?key=39d46e3fcb4c9740d08e8ecb1f15ff8c&location=${lnglat[0]},${lnglat[1]}&extensions=all`).then(({
118499
118566
  data
118500
118567
  }) => {