gis-common 1.1.10 → 1.1.12

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.
@@ -756,38 +756,38 @@ Array.prototype.clear = function () {
756
756
  /* harmony default export */ var CoordsUtils = ({
757
757
  PI: 3.14159265358979324,
758
758
  XPI: 3.14159265358979324 * 3000.0 / 180.0,
759
- delta: function delta(lat, lon) {
759
+ delta: function delta(lat, lng) {
760
760
  var a = 6378245.0; // a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
761
761
  var ee = 0.00669342162296594323; // ee: 椭球的偏心率。
762
- var dLat = this.transformLat(lon - 105.0, lat - 35.0);
763
- var dLon = this.transformLon(lon - 105.0, lat - 35.0);
762
+ var dLat = this.transformLat(lng - 105.0, lat - 35.0);
763
+ var dLon = this.transformLon(lng - 105.0, lat - 35.0);
764
764
  var radLat = lat / 180.0 * this.PI;
765
765
  var magic = Math.sin(radLat);
766
766
  magic = 1 - ee * magic * magic;
767
767
  var sqrtMagic = Math.sqrt(magic);
768
768
  dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * this.PI);
769
769
  dLon = dLon * 180.0 / (a / sqrtMagic * Math.cos(radLat) * this.PI);
770
- return { lat: dLat, lon: dLon };
770
+ return { lat: dLat, lng: dLon };
771
771
  },
772
772
 
773
773
  // WGS-84 to GCJ-02
774
774
  gcjEncrypt: function gcjEncrypt(wgsLat, wgsLon) {
775
775
  if (this.outOfChina(wgsLat, wgsLon)) {
776
- return { lat: wgsLat, lon: wgsLon };
776
+ return { lat: wgsLat, lng: wgsLon };
777
777
  }
778
778
 
779
779
  var d = this.delta(wgsLat, wgsLon);
780
- return { lat: wgsLat + d.lat, lon: wgsLon + d.lon };
780
+ return { lat: wgsLat + d.lat, lng: wgsLon + d.lng };
781
781
  },
782
782
 
783
783
  // GCJ-02 to WGS-84
784
784
  gcjDecrypt: function gcjDecrypt(gcjLat, gcjLon) {
785
785
  if (this.outOfChina(gcjLat, gcjLon)) {
786
- return { lat: gcjLat, lon: gcjLon };
786
+ return { lat: gcjLat, lng: gcjLon };
787
787
  }
788
788
 
789
789
  var d = this.delta(gcjLat, gcjLon);
790
- return { lat: gcjLat - d.lat, lon: gcjLon - d.lon };
790
+ return { lat: gcjLat - d.lat, lng: gcjLon - d.lng };
791
791
  },
792
792
 
793
793
  // GCJ-02 to WGS-84 exactly
@@ -808,7 +808,7 @@ Array.prototype.clear = function () {
808
808
  wgsLon = (mLon + pLon) / 2;
809
809
  var tmp = this.gcj_encrypt(wgsLat, wgsLon);
810
810
  dLat = tmp.lat - gcjLat;
811
- dLon = tmp.lon - gcjLon;
811
+ dLon = tmp.lng - gcjLon;
812
812
  if (Math.abs(dLat) < threshold && Math.abs(dLon) < threshold) {
813
813
  break;
814
814
  }
@@ -819,7 +819,7 @@ Array.prototype.clear = function () {
819
819
  if (++i > 10000) break;
820
820
  }
821
821
  // console.log(i);
822
- return { lat: wgsLat, lon: wgsLon };
822
+ return { lat: wgsLat, lng: wgsLon };
823
823
  },
824
824
 
825
825
  // GCJ-02 to BD-09
@@ -830,7 +830,7 @@ Array.prototype.clear = function () {
830
830
  var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.XPI);
831
831
  var bdLon = z * Math.cos(theta) + 0.0065;
832
832
  var bdLat = z * Math.sin(theta) + 0.006;
833
- return { lat: bdLat, lon: bdLon };
833
+ return { lat: bdLat, lng: bdLon };
834
834
  },
835
835
 
836
836
  // BD-09 to GCJ-02
@@ -841,7 +841,7 @@ Array.prototype.clear = function () {
841
841
  var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.XPI);
842
842
  var gcjLon = z * Math.cos(theta);
843
843
  var gcjLat = z * Math.sin(theta);
844
- return { lat: gcjLat, lon: gcjLon };
844
+ return { lat: gcjLat, lng: gcjLon };
845
845
  },
846
846
 
847
847
  // WGS-84 to Web mercator
@@ -850,7 +850,7 @@ Array.prototype.clear = function () {
850
850
  var x = wgsLon * 20037508.34 / 180.0;
851
851
  var y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0);
852
852
  y = y * 20037508.34 / 180.0;
853
- return { lat: y, lon: x };
853
+ return { lat: y, lng: x };
854
854
  },
855
855
 
856
856
  // Web mercator to WGS-84
@@ -859,13 +859,13 @@ Array.prototype.clear = function () {
859
859
  var x = mercatorLon / 20037508.34 * 180.0;
860
860
  var y = mercatorLat / 20037508.34 * 180.0;
861
861
  y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2);
862
- return { lat: y, lon: x };
862
+ return { lat: y, lng: x };
863
863
  },
864
864
 
865
865
  // two point's distance
866
- distance: function distance(latA, lonA, latB, lonB) {
866
+ distance: function distance(latA, lngA, latB, lngB) {
867
867
  var earthR = 6371000.0;
868
- var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lonA - lonB) * this.PI / 180);
868
+ var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lngA - lngB) * this.PI / 180);
869
869
  var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0);
870
870
  var s = x + y;
871
871
  if (s > 1) s = 1;
@@ -874,8 +874,8 @@ Array.prototype.clear = function () {
874
874
  var distance = alpha * earthR;
875
875
  return distance;
876
876
  },
877
- outOfChina: function outOfChina(lat, lon) {
878
- if (lon < 72.004 || lon > 137.8347) {
877
+ outOfChina: function outOfChina(lat, lng) {
878
+ if (lng < 72.004 || lng > 137.8347) {
879
879
  return true;
880
880
  }
881
881
  if (lat < 0.8293 || lat > 55.8271) {
@@ -1015,7 +1015,7 @@ Date.prototype.addDate = function (interval, number) {
1015
1015
  });
1016
1016
  // CONCATENATED MODULE: ./src/utils/DomUtils.js
1017
1017
  function trim(str) {
1018
- return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, "");
1018
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
1019
1019
  }
1020
1020
  function splitWords(str) {
1021
1021
  return trim(str).split(/\s+/);
@@ -1024,15 +1024,15 @@ function splitWords(str) {
1024
1024
  getStyle: function getStyle(el, style) {
1025
1025
  var value = el.style[style] || el.currentStyle && el.currentStyle[style];
1026
1026
 
1027
- if ((!value || value === "auto") && document.defaultView) {
1027
+ if ((!value || value === 'auto') && document.defaultView) {
1028
1028
  var css = document.defaultView.getComputedStyle(el, null);
1029
1029
  value = css ? css[style] : null;
1030
1030
  }
1031
- return value === "auto" ? null : value;
1031
+ return value === 'auto' ? null : value;
1032
1032
  },
1033
1033
  create: function create(tagName, className, container) {
1034
1034
  var el = document.createElement(tagName);
1035
- el.className = className || "";
1035
+ el.className = className || '';
1036
1036
 
1037
1037
  if (container) {
1038
1038
  container.appendChild(el);
@@ -1073,7 +1073,7 @@ function splitWords(str) {
1073
1073
  return el.classList.contains(name);
1074
1074
  }
1075
1075
  var className = this.getClass(el);
1076
- return className.length > 0 && new RegExp("(^|\\s)" + name + "(\\s|$)").test(className);
1076
+ return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
1077
1077
  },
1078
1078
  addClass: function addClass(el, name) {
1079
1079
  if (el.classList !== undefined) {
@@ -1083,7 +1083,7 @@ function splitWords(str) {
1083
1083
  }
1084
1084
  } else if (!this.hasClass(el, name)) {
1085
1085
  var className = this.getClass(el);
1086
- this.setClass(el, (className ? className + " " : "") + name);
1086
+ this.setClass(el, (className ? className + ' ' : '') + name);
1087
1087
  }
1088
1088
  },
1089
1089
  removeClass: function removeClass(el, name) {
@@ -1093,7 +1093,7 @@ function splitWords(str) {
1093
1093
  return el.classList.remove(name);
1094
1094
  });
1095
1095
  } else {
1096
- this.setClass(el, trim((" " + this.getClass(el) + " ").replace(" " + name + " ", " ")));
1096
+ this.setClass(el, trim((' ' + this.getClass(el) + ' ').replace(' ' + name + ' ', ' ')));
1097
1097
  }
1098
1098
  },
1099
1099
  setClass: function setClass(el, name) {
@@ -1103,6 +1103,11 @@ function splitWords(str) {
1103
1103
  // in case of SVG element
1104
1104
  el.className.baseVal = name;
1105
1105
  }
1106
+ },
1107
+ parseFromString: function parseFromString(str) {
1108
+ var parser = new DOMParser();
1109
+ var doc = parser.parseFromString(str, 'text/xml');
1110
+ return doc.children[0];
1106
1111
  }
1107
1112
  });
1108
1113
  // CONCATENATED MODULE: ./src/utils/GeoUtils.js
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "gis-common",
3
3
  "description": "gis-common",
4
4
  "main": "dist/resource.min.js",
5
- "version": "1.1.10",
5
+ "version": "1.1.12",
6
6
  "author": "Guo.Yan <luv02@vip.qq.com>",
7
7
  "license": "MIT",
8
8
  "private": false,