gis-common 2.0.2 → 2.1.2
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/resource.min.js +622 -243
- package/package.json +1 -1
package/dist/resource.min.js
CHANGED
|
@@ -119,6 +119,8 @@ __webpack_require__.d(__webpack_exports__, "Utils", function() { return /* reexp
|
|
|
119
119
|
__webpack_require__.d(__webpack_exports__, "EventType", function() { return /* reexport */ EventTypeConstant; });
|
|
120
120
|
__webpack_require__.d(__webpack_exports__, "ErrorType", function() { return /* reexport */ ErrorTypeConstant; });
|
|
121
121
|
__webpack_require__.d(__webpack_exports__, "LayerType", function() { return /* reexport */ LayerType; });
|
|
122
|
+
__webpack_require__.d(__webpack_exports__, "GraphicType", function() { return /* reexport */ GraphicType; });
|
|
123
|
+
__webpack_require__.d(__webpack_exports__, "MeasureMode", function() { return /* reexport */ MeasureMode; });
|
|
122
124
|
__webpack_require__.d(__webpack_exports__, "AudioPlayer", function() { return /* reexport */ core_AudioPlayer; });
|
|
123
125
|
__webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /* reexport */ core_CanvasDrawer; });
|
|
124
126
|
__webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
|
|
@@ -126,6 +128,7 @@ __webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { retur
|
|
|
126
128
|
__webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
|
|
127
129
|
__webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
|
|
128
130
|
__webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
|
|
131
|
+
__webpack_require__.d(__webpack_exports__, "DevicePixelRatio", function() { return /* reexport */ core_DevicePixelRatio; });
|
|
129
132
|
|
|
130
133
|
// CONCATENATED MODULE: ./src/utils/AnimateUtils.js
|
|
131
134
|
/* harmony default export */ var AnimateUtils = ({
|
|
@@ -226,24 +229,24 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
226
229
|
});
|
|
227
230
|
// CONCATENATED MODULE: ./src/constant/ErrorTypeConstant.js
|
|
228
231
|
/* harmony default export */ var ErrorTypeConstant = ({
|
|
229
|
-
LOGIN_EXPIRED:
|
|
230
|
-
CROSS_ERROR:
|
|
231
|
-
UNEXIST_RESOURCE:
|
|
232
|
-
TIMEOUT:
|
|
233
|
-
INTERNAL_ERROR:
|
|
234
|
-
NETWORK_ERROR:
|
|
235
|
-
PROCESS_FAIL:
|
|
236
|
-
AUTH_VERIFY_ERROR:
|
|
237
|
-
NO_DATA_FOUND:
|
|
238
|
-
DUPLICATE_INSTANCE:
|
|
239
|
-
COORDINATE_ERROR:
|
|
240
|
-
JSON_PARSE_ERROR:
|
|
241
|
-
JSON_VALUE_ERROR:
|
|
242
|
-
PARAMETER_ERROR:
|
|
243
|
-
PARAMETER_ERROR_ARRAY:
|
|
244
|
-
PARAMETER_ERROR_STRING:
|
|
245
|
-
PARAMETER_ERROR_FUNCTION:
|
|
246
|
-
PARAMETER_ERROR_LACK:
|
|
232
|
+
LOGIN_EXPIRED: '登录信息过期,请重新登录',
|
|
233
|
+
CROSS_ERROR: '跨域访问',
|
|
234
|
+
UNEXIST_RESOURCE: '资源不存在',
|
|
235
|
+
TIMEOUT: '请求超时',
|
|
236
|
+
INTERNAL_ERROR: '内部错误',
|
|
237
|
+
NETWORK_ERROR: '请求失败,请检查网络是否已连接',
|
|
238
|
+
PROCESS_FAIL: '处理失败',
|
|
239
|
+
AUTH_VERIFY_ERROR: '权限验证失败',
|
|
240
|
+
NO_DATA_FOUND: '未找到数据',
|
|
241
|
+
DUPLICATE_INSTANCE: '实例为单例模式,不允许重复构建',
|
|
242
|
+
COORDINATE_ERROR: '坐标验证失败',
|
|
243
|
+
JSON_PARSE_ERROR: 'JSON解析失败,格式有误',
|
|
244
|
+
JSON_VALUE_ERROR: 'JSON无此键',
|
|
245
|
+
PARAMETER_ERROR: '参数验证失败',
|
|
246
|
+
PARAMETER_ERROR_ARRAY: '参数格式验证失败:必须是数组',
|
|
247
|
+
PARAMETER_ERROR_STRING: '参数格式验证失败:必须是字符',
|
|
248
|
+
PARAMETER_ERROR_FUNCTION: '参数格式验证失败:必须是函数',
|
|
249
|
+
PARAMETER_ERROR_LACK: '参数缺失'
|
|
247
250
|
});
|
|
248
251
|
// CONCATENATED MODULE: ./src/constant/LayerType.js
|
|
249
252
|
/* harmony default export */ var LayerType = ({
|
|
@@ -255,10 +258,28 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
255
258
|
S3M_GROUP: "S3MGroup", // addS3MGroupLayer(url, options, index) 添加S3M分组图层。
|
|
256
259
|
TERRAIN_LAYER: "TerrainFileLayer" // 地形图层, 需要单独处理
|
|
257
260
|
});
|
|
261
|
+
// CONCATENATED MODULE: ./src/constant/GraphicConstant.js
|
|
262
|
+
var GraphicType = {
|
|
263
|
+
POINT: 'point',
|
|
264
|
+
POLYLINE: 'polyline',
|
|
265
|
+
POLYGON: 'polygon',
|
|
266
|
+
BILLBOARD: 'billboard',
|
|
267
|
+
CYLINDER: 'cylinder',
|
|
268
|
+
ELLIPSOID: 'ellipsoid',
|
|
269
|
+
LABEL: 'label',
|
|
270
|
+
MODEL: 'model',
|
|
271
|
+
WALL: 'wall'
|
|
272
|
+
};
|
|
273
|
+
var MeasureMode = {
|
|
274
|
+
DISTANCE: 'distance',
|
|
275
|
+
AREA: 'area',
|
|
276
|
+
HEIGHT: 'height'
|
|
277
|
+
};
|
|
258
278
|
// CONCATENATED MODULE: ./src/constant/index.js
|
|
259
279
|
|
|
260
280
|
|
|
261
281
|
|
|
282
|
+
|
|
262
283
|
// CONCATENATED MODULE: ./src/utils/CommUtils.js
|
|
263
284
|
|
|
264
285
|
|
|
@@ -309,7 +330,7 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
309
330
|
* @param {*} json
|
|
310
331
|
* @returns {*}
|
|
311
332
|
*/
|
|
312
|
-
|
|
333
|
+
json2Query: function json2Query(json) {
|
|
313
334
|
var tempArr = [];
|
|
314
335
|
for (var i in json) {
|
|
315
336
|
var key = i;
|
|
@@ -438,24 +459,39 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
438
459
|
* 异步加载script
|
|
439
460
|
*
|
|
440
461
|
* @param {*} url
|
|
441
|
-
* @param {function} callback
|
|
442
462
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
463
|
+
asyncLoadScript: function asyncLoadScript(url) {
|
|
464
|
+
return new Promise(function (resolve, reject) {
|
|
465
|
+
try {
|
|
466
|
+
var oscript = document.createElement('script');
|
|
467
|
+
if (oscript.readyState) {
|
|
468
|
+
// ie8及以下版本
|
|
469
|
+
oscript.onreadystatechange = function () {
|
|
470
|
+
if (oscript.readyState === 'complete' || oscript.readyState === 'loaded') {
|
|
471
|
+
resolve(oscript);
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
} else {
|
|
475
|
+
oscript.onload = function () {
|
|
476
|
+
resolve(oscript);
|
|
477
|
+
};
|
|
450
478
|
}
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
479
|
+
oscript.type = 'text/javascript';
|
|
480
|
+
oscript.src = url;
|
|
481
|
+
document.body.appendChild(oscript);
|
|
482
|
+
} catch (error) {
|
|
483
|
+
reject(error);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
},
|
|
487
|
+
loadStyle: function loadStyle(urls) {
|
|
488
|
+
urls.forEach(function (url) {
|
|
489
|
+
var css = document.createElement('link');
|
|
490
|
+
css.href = url;
|
|
491
|
+
css.rel = 'stylesheet';
|
|
492
|
+
css.type = 'text/css';
|
|
493
|
+
document.head.appendChild(css);
|
|
494
|
+
});
|
|
459
495
|
},
|
|
460
496
|
|
|
461
497
|
/**
|
|
@@ -477,6 +513,56 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
477
513
|
}
|
|
478
514
|
return value;
|
|
479
515
|
});
|
|
516
|
+
},
|
|
517
|
+
deleteEmptyProperty: function deleteEmptyProperty(data) {
|
|
518
|
+
var _this = this;
|
|
519
|
+
|
|
520
|
+
return Object.fromEntries(Object.keys(data).filter(function (d) {
|
|
521
|
+
return !_this.isEmpty(data[d]);
|
|
522
|
+
}).map(function (i) {
|
|
523
|
+
return [i, data[i]];
|
|
524
|
+
}));
|
|
525
|
+
},
|
|
526
|
+
deepAssign: function deepAssign() {
|
|
527
|
+
var len = arguments.length,
|
|
528
|
+
target = arguments[0];
|
|
529
|
+
if (this.getDataType(target) !== 'Object') {
|
|
530
|
+
target = {};
|
|
531
|
+
}
|
|
532
|
+
for (var i = 1; i < len; i++) {
|
|
533
|
+
var source = arguments[i];
|
|
534
|
+
if (this.getDataType(source) === 'Object') {
|
|
535
|
+
for (var s in source) {
|
|
536
|
+
if (s === '__proto__' || target === source[s]) {
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
if (this.getDataType(source[s]) === 'Object') {
|
|
540
|
+
target[s] = this.deepAssign(target[s], source[s]);
|
|
541
|
+
} else {
|
|
542
|
+
target[s] = source[s];
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
return target;
|
|
548
|
+
},
|
|
549
|
+
handleCopyValue: function handleCopyValue(text) {
|
|
550
|
+
if (!navigator.clipboard && window.isSecureContext) {
|
|
551
|
+
return navigator.clipboard.writeText(text);
|
|
552
|
+
} else {
|
|
553
|
+
var textArea = document.createElement('textarea');
|
|
554
|
+
textArea.style.position = 'fixed';
|
|
555
|
+
textArea.style.top = textArea.style.left = '-100vh';
|
|
556
|
+
textArea.style.opacity = '0';
|
|
557
|
+
textArea.value = text;
|
|
558
|
+
document.body.appendChild(textArea);
|
|
559
|
+
textArea.focus();
|
|
560
|
+
textArea.select();
|
|
561
|
+
return new Promise(function (resolve, reject) {
|
|
562
|
+
document.execCommand('copy') ? resolve() : reject(new Error('copy failed'));
|
|
563
|
+
textArea.remove();
|
|
564
|
+
});
|
|
565
|
+
}
|
|
480
566
|
}
|
|
481
567
|
});
|
|
482
568
|
// CONCATENATED MODULE: ./src/utils/ArrayUtils.js
|
|
@@ -525,6 +611,9 @@ Array.prototype.sum = function () {
|
|
|
525
611
|
return prev + curr;
|
|
526
612
|
}) : 0;
|
|
527
613
|
};
|
|
614
|
+
Array.prototype.avg = function () {
|
|
615
|
+
return this.length ? this.sum() / this.length : 0;
|
|
616
|
+
};
|
|
528
617
|
Array.prototype.desc = function (f) {
|
|
529
618
|
return this.sort(function (n1, n2) {
|
|
530
619
|
return (f ? f(n2) : n2) - (f ? f(n1) : n1);
|
|
@@ -615,8 +704,8 @@ Array.prototype.clear = function () {
|
|
|
615
704
|
for (var i = 0; i < args.length; i++) {
|
|
616
705
|
var str = args[i];
|
|
617
706
|
if (str) {
|
|
618
|
-
var s = str.replace(/#|\//g,
|
|
619
|
-
var arr = s.split(
|
|
707
|
+
var s = str.replace(/#|\//g, '');
|
|
708
|
+
var arr = s.split('?');
|
|
620
709
|
if (arr.length > 1) {
|
|
621
710
|
for (var _i = 1; _i < arr.length; _i++) {
|
|
622
711
|
var res = void 0;
|
|
@@ -631,26 +720,35 @@ Array.prototype.clear = function () {
|
|
|
631
720
|
},
|
|
632
721
|
getExplorer: function getExplorer() {
|
|
633
722
|
var explorer = window.navigator.userAgent;
|
|
634
|
-
if (explorer.indexOf(
|
|
635
|
-
return
|
|
723
|
+
if (explorer.indexOf('MSIE') >= 0) {
|
|
724
|
+
return 'IE';
|
|
636
725
|
}
|
|
637
|
-
if (!!window.ActiveXObject ||
|
|
726
|
+
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
|
|
638
727
|
// IE
|
|
639
|
-
return
|
|
640
|
-
} else if (explorer.indexOf(
|
|
728
|
+
return 'IE';
|
|
729
|
+
} else if (explorer.indexOf('Firefox') >= 0) {
|
|
641
730
|
// Firefox
|
|
642
|
-
return
|
|
643
|
-
} else if (explorer.indexOf(
|
|
731
|
+
return 'Firefox';
|
|
732
|
+
} else if (explorer.indexOf('Chrome') >= 0) {
|
|
644
733
|
// Chrome
|
|
645
|
-
return
|
|
646
|
-
} else if (explorer.indexOf(
|
|
734
|
+
return 'Chrome';
|
|
735
|
+
} else if (explorer.indexOf('Opera') >= 0) {
|
|
647
736
|
// Opera
|
|
648
|
-
return
|
|
649
|
-
} else if (explorer.indexOf(
|
|
737
|
+
return 'Opera';
|
|
738
|
+
} else if (explorer.indexOf('Safari') >= 0) {
|
|
650
739
|
// Safari
|
|
651
|
-
return
|
|
740
|
+
return 'Safari';
|
|
652
741
|
}
|
|
653
742
|
},
|
|
743
|
+
detectOS: function detectOS() {
|
|
744
|
+
var os_type = '';
|
|
745
|
+
var windows = navigator.userAgent.indexOf('Windows', 0) != -1 ? 1 : 0;
|
|
746
|
+
var mac = navigator.userAgent.indexOf('mac', 0) != -1 ? 1 : 0;
|
|
747
|
+
var linux = navigator.userAgent.indexOf('Linux', 0) != -1 ? 1 : 0;
|
|
748
|
+
var unix = navigator.userAgent.indexOf('X11', 0) != -1 ? 1 : 0;
|
|
749
|
+
if (windows) os_type = 'MS Windows';else if (mac) os_type = 'Apple mac';else if (linux) os_type = 'Linux';else if (unix) os_type = 'Unix';
|
|
750
|
+
return os_type;
|
|
751
|
+
},
|
|
654
752
|
switchFullScreen: function switchFullScreen(status) {
|
|
655
753
|
if (status) {
|
|
656
754
|
var element = document.documentElement;
|
|
@@ -682,16 +780,16 @@ Array.prototype.clear = function () {
|
|
|
682
780
|
refreshScale: function refreshScale() {
|
|
683
781
|
var baseWidth = document.documentElement.clientWidth;
|
|
684
782
|
var baseHeight = document.documentElement.clientHeight;
|
|
685
|
-
var appStyle = document.getElementById(
|
|
783
|
+
var appStyle = document.getElementById('app').style;
|
|
686
784
|
var realRatio = baseWidth / baseHeight;
|
|
687
785
|
var designRatio = 16 / 9;
|
|
688
786
|
var scaleRate = baseWidth / 1920;
|
|
689
787
|
if (realRatio > designRatio) {
|
|
690
788
|
scaleRate = baseHeight / 1080;
|
|
691
789
|
}
|
|
692
|
-
appStyle.transformOrigin =
|
|
693
|
-
appStyle.transform =
|
|
694
|
-
appStyle.width = baseWidth / scaleRate +
|
|
790
|
+
appStyle.transformOrigin = 'left top';
|
|
791
|
+
appStyle.transform = 'scale(' + scaleRate + ') translateX(-49.99%)';
|
|
792
|
+
appStyle.width = baseWidth / scaleRate + 'px';
|
|
695
793
|
},
|
|
696
794
|
|
|
697
795
|
/**
|
|
@@ -699,8 +797,8 @@ Array.prototype.clear = function () {
|
|
|
699
797
|
*/
|
|
700
798
|
getHtmlFontSize: function getHtmlFontSize() {
|
|
701
799
|
var htmlwidth = document.documentElement.clientWidth || document.body.clientWidth;
|
|
702
|
-
var htmlDom = document.querySelector(
|
|
703
|
-
htmlDom.style.fontSize = htmlwidth / 192 +
|
|
800
|
+
var htmlDom = document.querySelector('html');
|
|
801
|
+
htmlDom.style.fontSize = htmlwidth / 192 + 'px';
|
|
704
802
|
}
|
|
705
803
|
});
|
|
706
804
|
// CONCATENATED MODULE: ./src/utils/Cookie.js
|
|
@@ -710,22 +808,22 @@ Array.prototype.clear = function () {
|
|
|
710
808
|
|
|
711
809
|
var exp = new Date();
|
|
712
810
|
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
|
|
713
|
-
document.cookie = name +
|
|
811
|
+
document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString();
|
|
714
812
|
},
|
|
715
813
|
remove: function remove(name) {
|
|
716
814
|
var exp = new Date();
|
|
717
815
|
exp.setTime(exp.getTime() - 1);
|
|
718
|
-
var cval =
|
|
816
|
+
var cval = this.get(name);
|
|
719
817
|
if (cval != null) {
|
|
720
|
-
document.cookie = name +
|
|
818
|
+
document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString();
|
|
721
819
|
}
|
|
722
820
|
},
|
|
723
821
|
get: function get(name) {
|
|
724
|
-
var arr = document.cookie.match(new RegExp(
|
|
822
|
+
var arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
|
|
725
823
|
if (arr != null) {
|
|
726
824
|
return arr[2];
|
|
727
825
|
} else {
|
|
728
|
-
return
|
|
826
|
+
return '';
|
|
729
827
|
}
|
|
730
828
|
}
|
|
731
829
|
});
|
|
@@ -733,38 +831,38 @@ Array.prototype.clear = function () {
|
|
|
733
831
|
/* harmony default export */ var CoordsUtils = ({
|
|
734
832
|
PI: 3.14159265358979324,
|
|
735
833
|
XPI: 3.14159265358979324 * 3000.0 / 180.0,
|
|
736
|
-
delta: function delta(lat,
|
|
834
|
+
delta: function delta(lat, lng) {
|
|
737
835
|
var a = 6378245.0; // a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
|
|
738
836
|
var ee = 0.00669342162296594323; // ee: 椭球的偏心率。
|
|
739
|
-
var dLat = this.transformLat(
|
|
740
|
-
var dLon = this.transformLon(
|
|
837
|
+
var dLat = this.transformLat(lng - 105.0, lat - 35.0);
|
|
838
|
+
var dLon = this.transformLon(lng - 105.0, lat - 35.0);
|
|
741
839
|
var radLat = lat / 180.0 * this.PI;
|
|
742
840
|
var magic = Math.sin(radLat);
|
|
743
841
|
magic = 1 - ee * magic * magic;
|
|
744
842
|
var sqrtMagic = Math.sqrt(magic);
|
|
745
843
|
dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * this.PI);
|
|
746
844
|
dLon = dLon * 180.0 / (a / sqrtMagic * Math.cos(radLat) * this.PI);
|
|
747
|
-
return { lat: dLat,
|
|
845
|
+
return { lat: dLat, lng: dLon };
|
|
748
846
|
},
|
|
749
847
|
|
|
750
848
|
// WGS-84 to GCJ-02
|
|
751
849
|
gcjEncrypt: function gcjEncrypt(wgsLat, wgsLon) {
|
|
752
850
|
if (this.outOfChina(wgsLat, wgsLon)) {
|
|
753
|
-
return { lat: wgsLat,
|
|
851
|
+
return { lat: wgsLat, lng: wgsLon };
|
|
754
852
|
}
|
|
755
853
|
|
|
756
854
|
var d = this.delta(wgsLat, wgsLon);
|
|
757
|
-
return { lat: wgsLat + d.lat,
|
|
855
|
+
return { lat: wgsLat + d.lat, lng: wgsLon + d.lng };
|
|
758
856
|
},
|
|
759
857
|
|
|
760
858
|
// GCJ-02 to WGS-84
|
|
761
859
|
gcjDecrypt: function gcjDecrypt(gcjLat, gcjLon) {
|
|
762
860
|
if (this.outOfChina(gcjLat, gcjLon)) {
|
|
763
|
-
return { lat: gcjLat,
|
|
861
|
+
return { lat: gcjLat, lng: gcjLon };
|
|
764
862
|
}
|
|
765
863
|
|
|
766
864
|
var d = this.delta(gcjLat, gcjLon);
|
|
767
|
-
return { lat: gcjLat - d.lat,
|
|
865
|
+
return { lat: gcjLat - d.lat, lng: gcjLon - d.lng };
|
|
768
866
|
},
|
|
769
867
|
|
|
770
868
|
// GCJ-02 to WGS-84 exactly
|
|
@@ -785,7 +883,7 @@ Array.prototype.clear = function () {
|
|
|
785
883
|
wgsLon = (mLon + pLon) / 2;
|
|
786
884
|
var tmp = this.gcj_encrypt(wgsLat, wgsLon);
|
|
787
885
|
dLat = tmp.lat - gcjLat;
|
|
788
|
-
dLon = tmp.
|
|
886
|
+
dLon = tmp.lng - gcjLon;
|
|
789
887
|
if (Math.abs(dLat) < threshold && Math.abs(dLon) < threshold) {
|
|
790
888
|
break;
|
|
791
889
|
}
|
|
@@ -796,7 +894,7 @@ Array.prototype.clear = function () {
|
|
|
796
894
|
if (++i > 10000) break;
|
|
797
895
|
}
|
|
798
896
|
// console.log(i);
|
|
799
|
-
return { lat: wgsLat,
|
|
897
|
+
return { lat: wgsLat, lng: wgsLon };
|
|
800
898
|
},
|
|
801
899
|
|
|
802
900
|
// GCJ-02 to BD-09
|
|
@@ -805,9 +903,9 @@ Array.prototype.clear = function () {
|
|
|
805
903
|
var y = gcjLat;
|
|
806
904
|
var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.XPI);
|
|
807
905
|
var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.XPI);
|
|
808
|
-
bdLon = z * Math.cos(theta) + 0.0065;
|
|
809
|
-
bdLat = z * Math.sin(theta) + 0.006;
|
|
810
|
-
return { lat: bdLat,
|
|
906
|
+
var bdLon = z * Math.cos(theta) + 0.0065;
|
|
907
|
+
var bdLat = z * Math.sin(theta) + 0.006;
|
|
908
|
+
return { lat: bdLat, lng: bdLon };
|
|
811
909
|
},
|
|
812
910
|
|
|
813
911
|
// BD-09 to GCJ-02
|
|
@@ -818,7 +916,7 @@ Array.prototype.clear = function () {
|
|
|
818
916
|
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.XPI);
|
|
819
917
|
var gcjLon = z * Math.cos(theta);
|
|
820
918
|
var gcjLat = z * Math.sin(theta);
|
|
821
|
-
return { lat: gcjLat,
|
|
919
|
+
return { lat: gcjLat, lng: gcjLon };
|
|
822
920
|
},
|
|
823
921
|
|
|
824
922
|
// WGS-84 to Web mercator
|
|
@@ -827,16 +925,7 @@ Array.prototype.clear = function () {
|
|
|
827
925
|
var x = wgsLon * 20037508.34 / 180.0;
|
|
828
926
|
var y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0);
|
|
829
927
|
y = y * 20037508.34 / 180.0;
|
|
830
|
-
return { lat: y,
|
|
831
|
-
/*
|
|
832
|
-
if ((Math.abs(wgsLon) > 180 || Math.abs(wgsLat) > 90))
|
|
833
|
-
return null;
|
|
834
|
-
var x = 6378137.0 * wgsLon * 0.017453292519943295;
|
|
835
|
-
var a = wgsLat * 0.017453292519943295;
|
|
836
|
-
var y = 3189068.5 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
|
|
837
|
-
return {'lat' : y, 'lon' : x};
|
|
838
|
-
// */
|
|
839
|
-
};
|
|
928
|
+
return { lat: y, lng: x };
|
|
840
929
|
},
|
|
841
930
|
|
|
842
931
|
// Web mercator to WGS-84
|
|
@@ -845,24 +934,13 @@ Array.prototype.clear = function () {
|
|
|
845
934
|
var x = mercatorLon / 20037508.34 * 180.0;
|
|
846
935
|
var y = mercatorLat / 20037508.34 * 180.0;
|
|
847
936
|
y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2);
|
|
848
|
-
return { lat: y,
|
|
849
|
-
/*
|
|
850
|
-
if (Math.abs(mercatorLon) < 180 && Math.abs(mercatorLat) < 90)
|
|
851
|
-
return null;
|
|
852
|
-
if ((Math.abs(mercatorLon) > 20037508.3427892) || (Math.abs(mercatorLat) > 20037508.3427892))
|
|
853
|
-
return null;
|
|
854
|
-
var a = mercatorLon / 6378137.0 * 57.295779513082323;
|
|
855
|
-
var x = a - (Math.floor(((a + 180.0) / 360.0)) * 360.0);
|
|
856
|
-
var y = (1.5707963267948966 - (2.0 * Math.atan(Math.exp((-1.0 * mercatorLat) / 6378137.0)))) * 57.295779513082323;
|
|
857
|
-
return {'lat' : y, 'lon' : x};
|
|
858
|
-
// */
|
|
859
|
-
};
|
|
937
|
+
return { lat: y, lng: x };
|
|
860
938
|
},
|
|
861
939
|
|
|
862
940
|
// two point's distance
|
|
863
|
-
distance: function distance(latA,
|
|
941
|
+
distance: function distance(latA, lngA, latB, lngB) {
|
|
864
942
|
var earthR = 6371000.0;
|
|
865
|
-
var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((
|
|
943
|
+
var x = Math.cos(latA * this.PI / 180.0) * Math.cos(latB * this.PI / 180.0) * Math.cos((lngA - lngB) * this.PI / 180);
|
|
866
944
|
var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0);
|
|
867
945
|
var s = x + y;
|
|
868
946
|
if (s > 1) s = 1;
|
|
@@ -871,8 +949,8 @@ Array.prototype.clear = function () {
|
|
|
871
949
|
var distance = alpha * earthR;
|
|
872
950
|
return distance;
|
|
873
951
|
},
|
|
874
|
-
outOfChina: function outOfChina(lat,
|
|
875
|
-
if (
|
|
952
|
+
outOfChina: function outOfChina(lat, lng) {
|
|
953
|
+
if (lng < 72.004 || lng > 137.8347) {
|
|
876
954
|
return true;
|
|
877
955
|
}
|
|
878
956
|
if (lat < 0.8293 || lat > 55.8271) {
|
|
@@ -898,17 +976,17 @@ Array.prototype.clear = function () {
|
|
|
898
976
|
// CONCATENATED MODULE: ./src/utils/DateUtils.js
|
|
899
977
|
Date.prototype.format = function (fmt) {
|
|
900
978
|
var o = {
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
979
|
+
'M+': this.getMonth() + 1, // 月份
|
|
980
|
+
'd+': this.getDate(), // 日
|
|
981
|
+
'h+': this.getHours(), // 小时
|
|
982
|
+
'm+': this.getMinutes(), // 分
|
|
983
|
+
's+': this.getSeconds(), // 秒
|
|
984
|
+
'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
|
|
907
985
|
S: this.getMilliseconds() // 毫秒
|
|
908
986
|
};
|
|
909
|
-
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() +
|
|
987
|
+
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
|
|
910
988
|
for (var k in o) {
|
|
911
|
-
if (new RegExp(
|
|
989
|
+
if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length));
|
|
912
990
|
}
|
|
913
991
|
return fmt;
|
|
914
992
|
};
|
|
@@ -921,28 +999,28 @@ Date.prototype.format = function (fmt) {
|
|
|
921
999
|
Date.prototype.addDate = function (interval, number) {
|
|
922
1000
|
var date = new Date(this);
|
|
923
1001
|
switch (interval) {
|
|
924
|
-
case
|
|
1002
|
+
case 'y':
|
|
925
1003
|
date.setFullYear(this.getFullYear() + number);
|
|
926
1004
|
break;
|
|
927
|
-
case
|
|
1005
|
+
case 'q':
|
|
928
1006
|
date.setMonth(this.getMonth() + number * 3);
|
|
929
1007
|
break;
|
|
930
|
-
case
|
|
1008
|
+
case 'M':
|
|
931
1009
|
date.setMonth(this.getMonth() + number);
|
|
932
1010
|
break;
|
|
933
|
-
case
|
|
1011
|
+
case 'w':
|
|
934
1012
|
date.setDate(this.getDate() + number * 7);
|
|
935
1013
|
break;
|
|
936
|
-
case
|
|
1014
|
+
case 'd':
|
|
937
1015
|
date.setDate(this.getDate() + number);
|
|
938
1016
|
break;
|
|
939
|
-
case
|
|
1017
|
+
case 'h':
|
|
940
1018
|
date.setHours(this.getHours() + number);
|
|
941
1019
|
break;
|
|
942
|
-
case
|
|
1020
|
+
case 'm':
|
|
943
1021
|
date.setMinutes(this.getMinutes() + number);
|
|
944
1022
|
break;
|
|
945
|
-
case
|
|
1023
|
+
case 's':
|
|
946
1024
|
date.setSeconds(this.getSeconds() + number);
|
|
947
1025
|
break;
|
|
948
1026
|
default:
|
|
@@ -952,11 +1030,14 @@ Date.prototype.addDate = function (interval, number) {
|
|
|
952
1030
|
return date;
|
|
953
1031
|
};
|
|
954
1032
|
/* harmony default export */ var DateUtils = ({
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
1033
|
+
lastMonthDate: new Date(new Date().getFullYear(), new Date().getMonth() - 1, 1),
|
|
1034
|
+
thisMonthDate: new Date(new Date().getFullYear(), new Date().getMonth(), 1),
|
|
1035
|
+
nextMonthDate: new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1),
|
|
1036
|
+
lastDayDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1),
|
|
1037
|
+
thisDayDate: new Date(new Date().setHours(0, 0, 0, 0)),
|
|
1038
|
+
nextDayDate: new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1),
|
|
958
1039
|
parseDate: function parseDate(str) {
|
|
959
|
-
if (typeof str ==
|
|
1040
|
+
if (typeof str == 'string') {
|
|
960
1041
|
var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
|
|
961
1042
|
if (results && results.length > 3) return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]));
|
|
962
1043
|
results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
|
|
@@ -985,21 +1066,21 @@ Date.prototype.addDate = function (interval, number) {
|
|
|
985
1066
|
var minutes = Math.floor(leave2 / (60 * 1000));
|
|
986
1067
|
var leave3 = leave2 % (60 * 1000);
|
|
987
1068
|
var seconds = Math.round(leave3 / 1000);
|
|
988
|
-
var intervalDes =
|
|
1069
|
+
var intervalDes = '';
|
|
989
1070
|
if (days > 0) {
|
|
990
|
-
intervalDes += days +
|
|
1071
|
+
intervalDes += days + '天';
|
|
991
1072
|
}
|
|
992
1073
|
if (hours > 0) {
|
|
993
|
-
intervalDes += hours +
|
|
1074
|
+
intervalDes += hours + '时';
|
|
994
1075
|
}
|
|
995
1076
|
if (minutes > 0) {
|
|
996
|
-
intervalDes += minutes +
|
|
1077
|
+
intervalDes += minutes + '分';
|
|
997
1078
|
}
|
|
998
1079
|
if (seconds > 0) {
|
|
999
|
-
intervalDes += seconds +
|
|
1080
|
+
intervalDes += seconds + '秒';
|
|
1000
1081
|
}
|
|
1001
1082
|
if (days === 0 && hours === 0 && minutes === 0 && seconds === 0) {
|
|
1002
|
-
intervalDes =
|
|
1083
|
+
intervalDes = '少于1秒';
|
|
1003
1084
|
}
|
|
1004
1085
|
return intervalDes;
|
|
1005
1086
|
},
|
|
@@ -1009,7 +1090,7 @@ Date.prototype.addDate = function (interval, number) {
|
|
|
1009
1090
|
});
|
|
1010
1091
|
// CONCATENATED MODULE: ./src/utils/DomUtils.js
|
|
1011
1092
|
function trim(str) {
|
|
1012
|
-
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,
|
|
1093
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
|
1013
1094
|
}
|
|
1014
1095
|
function splitWords(str) {
|
|
1015
1096
|
return trim(str).split(/\s+/);
|
|
@@ -1018,15 +1099,15 @@ function splitWords(str) {
|
|
|
1018
1099
|
getStyle: function getStyle(el, style) {
|
|
1019
1100
|
var value = el.style[style] || el.currentStyle && el.currentStyle[style];
|
|
1020
1101
|
|
|
1021
|
-
if ((!value || value ===
|
|
1102
|
+
if ((!value || value === 'auto') && document.defaultView) {
|
|
1022
1103
|
var css = document.defaultView.getComputedStyle(el, null);
|
|
1023
1104
|
value = css ? css[style] : null;
|
|
1024
1105
|
}
|
|
1025
|
-
return value ===
|
|
1106
|
+
return value === 'auto' ? null : value;
|
|
1026
1107
|
},
|
|
1027
1108
|
create: function create(tagName, className, container) {
|
|
1028
1109
|
var el = document.createElement(tagName);
|
|
1029
|
-
el.className = className ||
|
|
1110
|
+
el.className = className || '';
|
|
1030
1111
|
|
|
1031
1112
|
if (container) {
|
|
1032
1113
|
container.appendChild(el);
|
|
@@ -1067,7 +1148,7 @@ function splitWords(str) {
|
|
|
1067
1148
|
return el.classList.contains(name);
|
|
1068
1149
|
}
|
|
1069
1150
|
var className = this.getClass(el);
|
|
1070
|
-
return className.length > 0 && new RegExp(
|
|
1151
|
+
return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
|
|
1071
1152
|
},
|
|
1072
1153
|
addClass: function addClass(el, name) {
|
|
1073
1154
|
if (el.classList !== undefined) {
|
|
@@ -1077,7 +1158,7 @@ function splitWords(str) {
|
|
|
1077
1158
|
}
|
|
1078
1159
|
} else if (!this.hasClass(el, name)) {
|
|
1079
1160
|
var className = this.getClass(el);
|
|
1080
|
-
this.setClass(el, (className ? className +
|
|
1161
|
+
this.setClass(el, (className ? className + ' ' : '') + name);
|
|
1081
1162
|
}
|
|
1082
1163
|
},
|
|
1083
1164
|
removeClass: function removeClass(el, name) {
|
|
@@ -1087,7 +1168,7 @@ function splitWords(str) {
|
|
|
1087
1168
|
return el.classList.remove(name);
|
|
1088
1169
|
});
|
|
1089
1170
|
} else {
|
|
1090
|
-
this.setClass(el, trim((
|
|
1171
|
+
this.setClass(el, trim((' ' + this.getClass(el) + ' ').replace(' ' + name + ' ', ' ')));
|
|
1091
1172
|
}
|
|
1092
1173
|
},
|
|
1093
1174
|
setClass: function setClass(el, name) {
|
|
@@ -1097,10 +1178,74 @@ function splitWords(str) {
|
|
|
1097
1178
|
// in case of SVG element
|
|
1098
1179
|
el.className.baseVal = name;
|
|
1099
1180
|
}
|
|
1181
|
+
},
|
|
1182
|
+
parseFromString: function parseFromString(str) {
|
|
1183
|
+
var parser = new DOMParser();
|
|
1184
|
+
var doc = parser.parseFromString(str, 'text/xml');
|
|
1185
|
+
return doc.children[0];
|
|
1186
|
+
}
|
|
1187
|
+
});
|
|
1188
|
+
// CONCATENATED MODULE: ./src/utils/MathUtils.js
|
|
1189
|
+
/* harmony default export */ var MathUtils = ({
|
|
1190
|
+
DEG2RAD: Math.PI / 180,
|
|
1191
|
+
RAD2DEG: 180 / Math.PI,
|
|
1192
|
+
randInt: function randInt(low, high) {
|
|
1193
|
+
return low + Math.floor(Math.random() * (high - low + 1));
|
|
1194
|
+
},
|
|
1195
|
+
randFloat: function randFloat(low, high) {
|
|
1196
|
+
return low + Math.random() * (high - low);
|
|
1197
|
+
},
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* 角度转弧度
|
|
1201
|
+
*
|
|
1202
|
+
* @param {*} degrees
|
|
1203
|
+
* @returns {*}
|
|
1204
|
+
*/
|
|
1205
|
+
degreesToRadians: function degreesToRadians(degrees) {
|
|
1206
|
+
return degrees * this.DEG2RAD;
|
|
1207
|
+
},
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* 角度转弧度
|
|
1211
|
+
*
|
|
1212
|
+
* @param {*} degrees
|
|
1213
|
+
* @returns {*}
|
|
1214
|
+
*/
|
|
1215
|
+
toRadians: function toRadians(degrees) {
|
|
1216
|
+
return degrees * this.DEG2RAD;
|
|
1217
|
+
},
|
|
1218
|
+
|
|
1219
|
+
/**
|
|
1220
|
+
* 弧度转角度
|
|
1221
|
+
*
|
|
1222
|
+
* @param {*} radians
|
|
1223
|
+
* @returns {*}
|
|
1224
|
+
*/
|
|
1225
|
+
radiansToDegrees: function radiansToDegrees(radians) {
|
|
1226
|
+
return radians * this.RAD2DEG;
|
|
1227
|
+
},
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* 弧度转角度
|
|
1231
|
+
*
|
|
1232
|
+
* @param {*} radians
|
|
1233
|
+
* @returns {*}
|
|
1234
|
+
*/
|
|
1235
|
+
toDegrees: function toDegrees(radians) {
|
|
1236
|
+
return radians * this.RAD2DEG;
|
|
1237
|
+
},
|
|
1238
|
+
formatFloat: function formatFloat(value) {
|
|
1239
|
+
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
1240
|
+
|
|
1241
|
+
return Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
|
|
1100
1242
|
}
|
|
1101
1243
|
});
|
|
1102
1244
|
// CONCATENATED MODULE: ./src/utils/GeoUtils.js
|
|
1245
|
+
|
|
1103
1246
|
/* harmony default export */ var GeoUtils = ({
|
|
1247
|
+
toRadian: Math.PI / 180,
|
|
1248
|
+
R: 6371393,
|
|
1104
1249
|
/**
|
|
1105
1250
|
* 验证经纬度坐标
|
|
1106
1251
|
*
|
|
@@ -1109,7 +1254,7 @@ function splitWords(str) {
|
|
|
1109
1254
|
* @returns {*} {boolean}
|
|
1110
1255
|
*/
|
|
1111
1256
|
isLnglat: function isLnglat(lng, lat) {
|
|
1112
|
-
return !!(+lat >
|
|
1257
|
+
return !!(+lat > -90 && +lat < 90 && +lng > -180 && +lng < 180);
|
|
1113
1258
|
},
|
|
1114
1259
|
|
|
1115
1260
|
/**
|
|
@@ -1125,14 +1270,8 @@ function splitWords(str) {
|
|
|
1125
1270
|
var a = parseFloat(value);
|
|
1126
1271
|
var degree = parseInt(a);
|
|
1127
1272
|
var min = parseInt((a - degree) * 60);
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
}
|
|
1131
|
-
var sec = parseInt((a - degree) * 3600 - min * 60);
|
|
1132
|
-
if (sec < 10) {
|
|
1133
|
-
sec = '0' + sec;
|
|
1134
|
-
}
|
|
1135
|
-
return degree + '°' + min + '′' + sec + '″';
|
|
1273
|
+
var sec = (a - degree) * 3600 - min * 60;
|
|
1274
|
+
return degree + '°' + min + '′' + sec.toFixed(2) + '″';
|
|
1136
1275
|
}
|
|
1137
1276
|
if (lng && lat) {
|
|
1138
1277
|
res = format(lng) + ',' + format(lat);
|
|
@@ -1140,6 +1279,33 @@ function splitWords(str) {
|
|
|
1140
1279
|
return res;
|
|
1141
1280
|
},
|
|
1142
1281
|
|
|
1282
|
+
/**
|
|
1283
|
+
* 度分秒转十进制
|
|
1284
|
+
*
|
|
1285
|
+
* @param {*} lng
|
|
1286
|
+
* @param {*} lat
|
|
1287
|
+
* @returns {*}
|
|
1288
|
+
*/
|
|
1289
|
+
transformLnglat: function transformLnglat(lng, lat) {
|
|
1290
|
+
function dms2deg(s) {
|
|
1291
|
+
var sw = /[sw]/i.test(s);
|
|
1292
|
+
var f = sw ? -1 : 1;
|
|
1293
|
+
var bits = s.match(/[\d.]+/g);
|
|
1294
|
+
var result = 0;
|
|
1295
|
+
for (var i = 0, iLen = bits.length; i < iLen; i++) {
|
|
1296
|
+
result += bits[i] / f;
|
|
1297
|
+
f *= 60;
|
|
1298
|
+
}
|
|
1299
|
+
return result;
|
|
1300
|
+
}
|
|
1301
|
+
if (lng && lat) {
|
|
1302
|
+
return {
|
|
1303
|
+
lng: dms2deg(lng),
|
|
1304
|
+
lat: dms2deg(lat)
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1307
|
+
},
|
|
1308
|
+
|
|
1143
1309
|
/**
|
|
1144
1310
|
* 判断点是否在多边形内
|
|
1145
1311
|
*
|
|
@@ -1236,6 +1402,81 @@ function splitWords(str) {
|
|
|
1236
1402
|
var fwdAz = Math.atan2(cosU2 * sinLambda, cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
|
|
1237
1403
|
var revAz = Math.atan2(cosU1 * sinLambda, -sinU1 * cosU2 + cosU1 * sinU2 * cosLambda);
|
|
1238
1404
|
return s;
|
|
1405
|
+
},
|
|
1406
|
+
|
|
1407
|
+
/**
|
|
1408
|
+
* P1绕一个坐标点P2旋转θ角度后,新的坐标的计算公式
|
|
1409
|
+
*
|
|
1410
|
+
* @param {*} p1
|
|
1411
|
+
* @param {*} p2
|
|
1412
|
+
* @param {*} θ 旋转角度,正:表示顺时针,负:表示逆时针
|
|
1413
|
+
*/
|
|
1414
|
+
rotatePoint: function rotatePoint(p1, p2, θ) {
|
|
1415
|
+
var x = (p1.x - p2.x) * Math.cos(Math.PI / 180 * -θ) - (p1.y - p2.y) * Math.sin(Math.PI / 180 * -θ) + p2.x;
|
|
1416
|
+
var y = (p1.x - p2.x) * Math.sin(Math.PI / 180 * -θ) + (p1.y - p2.y) * Math.cos(Math.PI / 180 * -θ) + p2.y;
|
|
1417
|
+
return { x: x, y: y };
|
|
1418
|
+
},
|
|
1419
|
+
|
|
1420
|
+
/**
|
|
1421
|
+
* 计算latlng2相对于latlng1的方位角和距离
|
|
1422
|
+
*
|
|
1423
|
+
* @param {*} latlng1
|
|
1424
|
+
* @param {*} latlng2
|
|
1425
|
+
* @returns {*} {boolean}
|
|
1426
|
+
*/
|
|
1427
|
+
calcBearAndDisByPoints: function calcBearAndDisByPoints(latlng1, latlng2) {
|
|
1428
|
+
var f1 = parseFloat(latlng1.lat),
|
|
1429
|
+
l1 = parseFloat(latlng1.lng),
|
|
1430
|
+
f2 = parseFloat(latlng2.lat),
|
|
1431
|
+
l2 = parseFloat(latlng2.lng);
|
|
1432
|
+
var y = Math.sin((l2 - l1) * this.toRadian) * Math.cos(f2 * this.toRadian);
|
|
1433
|
+
var x = Math.cos(f1 * this.toRadian) * Math.sin(f2 * this.toRadian) - Math.sin(f1 * this.toRadian) * Math.cos(f2 * this.toRadian) * Math.cos((l2 - l1) * this.toRadian);
|
|
1434
|
+
var angle = Math.atan2(y, x) * (180 / Math.PI);
|
|
1435
|
+
var deltaF = (f2 - f1) * this.toRadian;
|
|
1436
|
+
var deltaL = (l2 - l1) * this.toRadian;
|
|
1437
|
+
var a = Math.sin(deltaF / 2) * Math.sin(deltaF / 2) + Math.cos(f1 * this.toRadian) * Math.cos(f2 * this.toRadian) * Math.sin(deltaL / 2) * Math.sin(deltaL / 2);
|
|
1438
|
+
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
|
1439
|
+
var distance = this.R * c;
|
|
1440
|
+
return {
|
|
1441
|
+
angle: angle,
|
|
1442
|
+
distance: distance
|
|
1443
|
+
};
|
|
1444
|
+
},
|
|
1445
|
+
|
|
1446
|
+
/**
|
|
1447
|
+
* 根据方位角和距离生成新的坐标
|
|
1448
|
+
*
|
|
1449
|
+
* @param {*} latlng
|
|
1450
|
+
* @param {*} angle
|
|
1451
|
+
* @param {*} distance
|
|
1452
|
+
* @returns {*}
|
|
1453
|
+
*/
|
|
1454
|
+
calcPointByBearAndDis: function calcPointByBearAndDis(latlng, angle, distance) {
|
|
1455
|
+
var sLat = MathUtils.toRadians(parseFloat(latlng.lat));
|
|
1456
|
+
var sLng = MathUtils.toRadians(parseFloat(latlng.lng));
|
|
1457
|
+
angle = parseFloat(angle);
|
|
1458
|
+
distance = parseFloat(distance);
|
|
1459
|
+
var d = distance / this.R;
|
|
1460
|
+
angle = MathUtils.toRadians(angle);
|
|
1461
|
+
var lat = Math.asin(Math.sin(sLat) * Math.cos(d) + Math.cos(sLat) * Math.sin(d) * Math.cos(angle));
|
|
1462
|
+
var lon = sLng + Math.atan2(Math.sin(angle) * Math.sin(d) * Math.cos(sLat), Math.cos(d) - Math.sin(sLat) * Math.sin(lat));
|
|
1463
|
+
return {
|
|
1464
|
+
lat: MathUtils.toDegrees(lat),
|
|
1465
|
+
lng: MathUtils.toDegrees(lon)
|
|
1466
|
+
};
|
|
1467
|
+
},
|
|
1468
|
+
mercatorTolonlat: function mercatorTolonlat(x, y) {
|
|
1469
|
+
var lng = x / 20037508.34 * 180;
|
|
1470
|
+
var mmy = y / 20037508.34 * 180;
|
|
1471
|
+
var lat = 180 / Math.PI * (2 * Math.atan(Math.exp(mmy * Math.PI / 180)) - Math.PI / 2);
|
|
1472
|
+
return { lng: lng, lat: lat };
|
|
1473
|
+
},
|
|
1474
|
+
lonlatToMercator: function lonlatToMercator(lng, lat) {
|
|
1475
|
+
var earthRad = 6378137.0;
|
|
1476
|
+
var x = lng * Math.PI / 180 * earthRad;
|
|
1477
|
+
var a = lat * Math.PI / 180;
|
|
1478
|
+
var y = earthRad / 2 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
|
|
1479
|
+
return { x: x, y: y };
|
|
1239
1480
|
}
|
|
1240
1481
|
});
|
|
1241
1482
|
// CONCATENATED MODULE: ./src/utils/FileUtils.js
|
|
@@ -1249,8 +1490,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1249
1490
|
* @returns {*}
|
|
1250
1491
|
*/
|
|
1251
1492
|
convertBase64ToBlob: function convertBase64ToBlob(data) {
|
|
1252
|
-
var mimeString = data.split(
|
|
1253
|
-
var byteString = window.atob(data.split(
|
|
1493
|
+
var mimeString = data.split(',')[0].split(':')[1].split(';')[0];
|
|
1494
|
+
var byteString = window.atob(data.split(',')[1]);
|
|
1254
1495
|
var ab = new ArrayBuffer(byteString.length);
|
|
1255
1496
|
var ia = new Uint8Array(ab);
|
|
1256
1497
|
|
|
@@ -1282,19 +1523,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1282
1523
|
convertUrlToBase64: function convertUrlToBase64(url, width, height) {
|
|
1283
1524
|
return new Promise(function (resolve, reject) {
|
|
1284
1525
|
var img = new Image();
|
|
1285
|
-
img.crossOrigin =
|
|
1526
|
+
img.crossOrigin = 'Anonymous';
|
|
1286
1527
|
img.src = url;
|
|
1287
1528
|
img.onload = function () {
|
|
1288
|
-
var canvas = document.createElement(
|
|
1529
|
+
var canvas = document.createElement('canvas');
|
|
1289
1530
|
canvas.width = width || img.width;
|
|
1290
1531
|
canvas.height = height || img.height;
|
|
1291
|
-
var ctx = canvas.getContext(
|
|
1532
|
+
var ctx = canvas.getContext('2d');
|
|
1292
1533
|
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
1293
|
-
var ext = img.src.substring(img.src.lastIndexOf(
|
|
1294
|
-
var dataURL = canvas.toDataURL(
|
|
1534
|
+
var ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase();
|
|
1535
|
+
var dataURL = canvas.toDataURL('image/' + ext);
|
|
1295
1536
|
var base64 = {
|
|
1296
1537
|
dataURL: dataURL,
|
|
1297
|
-
type:
|
|
1538
|
+
type: 'image/' + ext,
|
|
1298
1539
|
ext: ext
|
|
1299
1540
|
};
|
|
1300
1541
|
resolve(base64);
|
|
@@ -1310,7 +1551,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1310
1551
|
* @returns {*}
|
|
1311
1552
|
*/
|
|
1312
1553
|
convertBase64ToFile: function convertBase64ToFile(dataurl, filename) {
|
|
1313
|
-
var arr = dataurl.split(
|
|
1554
|
+
var arr = dataurl.split(','),
|
|
1314
1555
|
mime = arr[0].match(/:(.*?);/)[1],
|
|
1315
1556
|
bstr = atob(arr[1]),
|
|
1316
1557
|
n = bstr.length,
|
|
@@ -1325,56 +1566,30 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1325
1566
|
/**
|
|
1326
1567
|
* 直接下载文件,支持blob类型和url类型
|
|
1327
1568
|
*
|
|
1328
|
-
* @param {*}
|
|
1569
|
+
* @param {*} data
|
|
1329
1570
|
* @param {*} saveName
|
|
1330
1571
|
*/
|
|
1331
|
-
downloadFromFile: function downloadFromFile(
|
|
1332
|
-
|
|
1333
|
-
|
|
1572
|
+
downloadFromFile: function downloadFromFile(data, saveName) {
|
|
1573
|
+
var url = void 0;
|
|
1574
|
+
if ((typeof data === 'undefined' ? 'undefined' : _typeof(data)) == 'object') {
|
|
1575
|
+
if (data instanceof Blob) {
|
|
1576
|
+
url = URL.createObjectURL(data); // 创建blob地址
|
|
1577
|
+
} else {
|
|
1578
|
+
var str = JSON.stringify(data);
|
|
1579
|
+
var blob = new Blob([str], { type: 'text/json' }); // json对象
|
|
1580
|
+
url = window.URL.createObjectURL(blob);
|
|
1581
|
+
}
|
|
1582
|
+
} else if (typeof data == 'string') {
|
|
1583
|
+
var _blob = new Blob([data], { type: 'text/json' }); //json文本
|
|
1584
|
+
url = window.URL.createObjectURL(_blob);
|
|
1334
1585
|
}
|
|
1335
|
-
var link = document.createElement(
|
|
1586
|
+
var link = document.createElement('a');
|
|
1336
1587
|
link.href = url;
|
|
1337
|
-
link.download = saveName ||
|
|
1588
|
+
link.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
|
|
1338
1589
|
link.click();
|
|
1339
1590
|
window.URL.revokeObjectURL(link.href);
|
|
1340
1591
|
}
|
|
1341
1592
|
});
|
|
1342
|
-
// CONCATENATED MODULE: ./src/utils/MathUtils.js
|
|
1343
|
-
/* harmony default export */ var MathUtils = ({
|
|
1344
|
-
DEG2RAD: Math.PI / 180,
|
|
1345
|
-
RAD2DEG: 180 / Math.PI,
|
|
1346
|
-
randInt: function randInt(low, high) {
|
|
1347
|
-
return low + Math.floor(Math.random() * (high - low + 1));
|
|
1348
|
-
},
|
|
1349
|
-
randFloat: function randFloat(low, high) {
|
|
1350
|
-
return low + Math.random() * (high - low);
|
|
1351
|
-
},
|
|
1352
|
-
|
|
1353
|
-
/**
|
|
1354
|
-
* 角度转弧度
|
|
1355
|
-
*
|
|
1356
|
-
* @param {*} degrees
|
|
1357
|
-
* @returns {*}
|
|
1358
|
-
*/
|
|
1359
|
-
degreesToRadians: function degreesToRadians(degrees) {
|
|
1360
|
-
return degrees * this.DEG2RAD;
|
|
1361
|
-
},
|
|
1362
|
-
|
|
1363
|
-
/**
|
|
1364
|
-
* 弧度转角度
|
|
1365
|
-
*
|
|
1366
|
-
* @param {*} radians
|
|
1367
|
-
* @returns {*}
|
|
1368
|
-
*/
|
|
1369
|
-
radiansToDegrees: function radiansToDegrees(radians) {
|
|
1370
|
-
return radians * this.RAD2DEG;
|
|
1371
|
-
},
|
|
1372
|
-
formatFloat: function formatFloat(value) {
|
|
1373
|
-
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
1374
|
-
|
|
1375
|
-
return Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
|
|
1376
|
-
}
|
|
1377
|
-
});
|
|
1378
1593
|
// CONCATENATED MODULE: ./src/utils/OptimizeUtils.js
|
|
1379
1594
|
/* harmony default export */ var OptimizeUtils = ({
|
|
1380
1595
|
/**
|
|
@@ -1441,9 +1656,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1441
1656
|
*/
|
|
1442
1657
|
throttle: function throttle(func, wait, type) {
|
|
1443
1658
|
if (type === 1) {
|
|
1444
|
-
var
|
|
1659
|
+
var previous = 0;
|
|
1445
1660
|
} else if (type === 2) {
|
|
1446
|
-
var
|
|
1661
|
+
var timeout;
|
|
1447
1662
|
}
|
|
1448
1663
|
return function () {
|
|
1449
1664
|
var context = this;
|
|
@@ -1486,6 +1701,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1486
1701
|
}
|
|
1487
1702
|
});
|
|
1488
1703
|
// CONCATENATED MODULE: ./src/utils/StringUtils.js
|
|
1704
|
+
|
|
1489
1705
|
/* harmony default export */ var StringUtils = ({
|
|
1490
1706
|
/**
|
|
1491
1707
|
* 常用正则验证
|
|
@@ -1603,17 +1819,62 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1603
1819
|
return str;
|
|
1604
1820
|
}
|
|
1605
1821
|
},
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* 处理字符串模板
|
|
1825
|
+
* eg: tag`${abc}`
|
|
1826
|
+
* @param {*} strArray
|
|
1827
|
+
* @param {*} args
|
|
1828
|
+
* @returns {*}
|
|
1829
|
+
*/
|
|
1606
1830
|
tag: function tag(strArray) {
|
|
1607
1831
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1608
1832
|
args[_key - 1] = arguments[_key];
|
|
1609
1833
|
}
|
|
1610
1834
|
|
|
1611
1835
|
args = args.map(function (val) {
|
|
1612
|
-
|
|
1836
|
+
switch (CommUtils.getDataType(val)) {
|
|
1837
|
+
case 'Object':
|
|
1838
|
+
return val || '{}';
|
|
1839
|
+
case 'Array':
|
|
1840
|
+
return val || '[]';
|
|
1841
|
+
default:
|
|
1842
|
+
return val || '';
|
|
1843
|
+
}
|
|
1613
1844
|
});
|
|
1614
1845
|
return strArray.reduce(function (prev, next, index) {
|
|
1615
1846
|
return '' + prev + args[index - 1] + next;
|
|
1616
1847
|
});
|
|
1848
|
+
},
|
|
1849
|
+
|
|
1850
|
+
/**
|
|
1851
|
+
* 获取字符串字节长度
|
|
1852
|
+
* @param {*} str
|
|
1853
|
+
* @returns {*}
|
|
1854
|
+
*/
|
|
1855
|
+
getByteLength: function getByteLength(str) {
|
|
1856
|
+
return str.replace(/[\u0391-\uFFE5]/g, 'aa').length;
|
|
1857
|
+
},
|
|
1858
|
+
|
|
1859
|
+
/**
|
|
1860
|
+
* 根据字节长度截取字符串
|
|
1861
|
+
* @param {*} str
|
|
1862
|
+
* @param {*} n
|
|
1863
|
+
* @returns {*}
|
|
1864
|
+
*/
|
|
1865
|
+
subStringByte: function subStringByte(str, start, n) {
|
|
1866
|
+
var r = /[^\x00-\xff]/g;
|
|
1867
|
+
if (str.replace(r, 'mm').length <= n) {
|
|
1868
|
+
return str;
|
|
1869
|
+
}
|
|
1870
|
+
var m = Math.floor(n / 2);
|
|
1871
|
+
for (var i = m; i < str.length; i++) {
|
|
1872
|
+
var sub = str.substring(start, i);
|
|
1873
|
+
if (sub.replace(r, 'mm').length >= n) {
|
|
1874
|
+
return sub;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
return str;
|
|
1617
1878
|
}
|
|
1618
1879
|
});
|
|
1619
1880
|
// CONCATENATED MODULE: ./src/utils/index.js
|
|
@@ -1846,6 +2107,9 @@ var ElQuery = function () {
|
|
|
1846
2107
|
var _this3 = this;
|
|
1847
2108
|
|
|
1848
2109
|
this.each(function (obj) {
|
|
2110
|
+
obj.removeEventListener(type, function (e) {
|
|
2111
|
+
callback.call(_this3, e);
|
|
2112
|
+
});
|
|
1849
2113
|
obj.addEventListener(type, function (e) {
|
|
1850
2114
|
callback.call(_this3, e);
|
|
1851
2115
|
});
|
|
@@ -2055,7 +2319,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2055
2319
|
_inherits(WebSocketClient, _EventDispatcher);
|
|
2056
2320
|
|
|
2057
2321
|
function WebSocketClient() {
|
|
2058
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] :
|
|
2322
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'ws://127.0.0.1:10088';
|
|
2059
2323
|
|
|
2060
2324
|
WebSocketClient_classCallCheck(this, WebSocketClient);
|
|
2061
2325
|
|
|
@@ -2073,40 +2337,37 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2073
2337
|
}
|
|
2074
2338
|
|
|
2075
2339
|
WebSocketClient_createClass(WebSocketClient, [{
|
|
2076
|
-
key:
|
|
2340
|
+
key: 'connect',
|
|
2077
2341
|
value: function connect() {
|
|
2078
|
-
var _this2 = this;
|
|
2079
|
-
|
|
2080
|
-
this.checkTimes++;
|
|
2081
2342
|
this.disconnect();
|
|
2082
2343
|
if (this.url) {
|
|
2083
2344
|
try {
|
|
2084
|
-
console.info(
|
|
2345
|
+
console.info('创建ws连接>>>' + this.url);
|
|
2085
2346
|
this.client = new WebSocket(this.url);
|
|
2086
2347
|
if (this.client) {
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2348
|
+
var self = this;
|
|
2349
|
+
this.client.onopen = function (message) {
|
|
2350
|
+
self.dispatchEvent({
|
|
2351
|
+
type: EventTypeConstant.WEB_SOCKET_CONNECT,
|
|
2352
|
+
message: message
|
|
2353
|
+
});
|
|
2354
|
+
};
|
|
2355
|
+
this.client.onmessage = function (message) {
|
|
2356
|
+
self.connectStatus = true;
|
|
2357
|
+
self.dispatchEvent({
|
|
2358
|
+
type: EventTypeConstant.WEB_SOCKET_MESSAGE,
|
|
2359
|
+
message: message
|
|
2360
|
+
});
|
|
2361
|
+
};
|
|
2362
|
+
this.client.onclose = function (message) {
|
|
2363
|
+
self.dispatchEvent({
|
|
2364
|
+
type: EventTypeConstant.WEB_SOCKET_CLOSE,
|
|
2365
|
+
message: message
|
|
2366
|
+
});
|
|
2367
|
+
};
|
|
2368
|
+
if (this.checkTimes === this.maxCheckTimes) {
|
|
2108
2369
|
this.client.onerror = function (message) {
|
|
2109
|
-
|
|
2370
|
+
self.dispatchEvent({
|
|
2110
2371
|
type: EventTypeConstant.WEB_SOCKET_ERROR,
|
|
2111
2372
|
message: message
|
|
2112
2373
|
});
|
|
@@ -2114,16 +2375,16 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2114
2375
|
}
|
|
2115
2376
|
}
|
|
2116
2377
|
} catch (ex) {
|
|
2117
|
-
console.error(
|
|
2378
|
+
console.error('创建ws连接失败' + this.url + ':' + ex);
|
|
2118
2379
|
}
|
|
2119
2380
|
}
|
|
2120
2381
|
}
|
|
2121
2382
|
}, {
|
|
2122
|
-
key:
|
|
2383
|
+
key: 'disconnect',
|
|
2123
2384
|
value: function disconnect() {
|
|
2124
2385
|
if (this.client) {
|
|
2125
2386
|
try {
|
|
2126
|
-
console.log(
|
|
2387
|
+
console.log('ws断开连接' + this.url);
|
|
2127
2388
|
this.client.close();
|
|
2128
2389
|
this.client = null;
|
|
2129
2390
|
} catch (ex) {
|
|
@@ -2132,43 +2393,44 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2132
2393
|
}
|
|
2133
2394
|
}
|
|
2134
2395
|
}, {
|
|
2135
|
-
key:
|
|
2396
|
+
key: 'connCheckStatus',
|
|
2136
2397
|
value: function connCheckStatus(times) {
|
|
2137
|
-
var
|
|
2398
|
+
var _this2 = this;
|
|
2138
2399
|
|
|
2139
2400
|
if (this.checkTimes > times) return;
|
|
2140
2401
|
setTimeout(function () {
|
|
2141
|
-
|
|
2142
|
-
|
|
2402
|
+
_this2.checkTimes++;
|
|
2403
|
+
if (_this2.client && _this2.client.readyState !== 0 && _this2.client.readyState !== 1) {
|
|
2404
|
+
_this2.connect();
|
|
2143
2405
|
}
|
|
2144
|
-
|
|
2406
|
+
_this2.connCheckStatus(times);
|
|
2145
2407
|
}, 2000);
|
|
2146
2408
|
}
|
|
2147
2409
|
}, {
|
|
2148
|
-
key:
|
|
2410
|
+
key: 'send',
|
|
2149
2411
|
value: function send(message) {
|
|
2150
2412
|
if (this.client && this.client.readyState === 1) {
|
|
2151
2413
|
this.client.send(message);
|
|
2152
2414
|
return true;
|
|
2153
2415
|
}
|
|
2154
|
-
console.error(this.url +
|
|
2416
|
+
console.error(this.url + '消息发送失败:' + message);
|
|
2155
2417
|
return false;
|
|
2156
2418
|
}
|
|
2157
2419
|
}, {
|
|
2158
|
-
key:
|
|
2420
|
+
key: 'heartbeat',
|
|
2159
2421
|
value: function heartbeat() {
|
|
2160
|
-
var
|
|
2422
|
+
var _this3 = this;
|
|
2161
2423
|
|
|
2162
2424
|
setTimeout(function () {
|
|
2163
|
-
if (
|
|
2164
|
-
|
|
2425
|
+
if (_this3.client && _this3.client.readyState === 1) {
|
|
2426
|
+
_this3.send('HeartBeat');
|
|
2165
2427
|
}
|
|
2166
|
-
console.log(
|
|
2167
|
-
setTimeout(
|
|
2428
|
+
console.log('HeartBeat,' + _this3.url);
|
|
2429
|
+
setTimeout(_this3.heartbeat, 30000);
|
|
2168
2430
|
}, 1000);
|
|
2169
2431
|
}
|
|
2170
2432
|
}], [{
|
|
2171
|
-
key:
|
|
2433
|
+
key: 'getInstance',
|
|
2172
2434
|
value: function getInstance() {
|
|
2173
2435
|
if (WebSocketClient.instance) {
|
|
2174
2436
|
return WebSocketClient.instance;
|
|
@@ -2177,7 +2439,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2177
2439
|
}
|
|
2178
2440
|
}
|
|
2179
2441
|
}, {
|
|
2180
|
-
key:
|
|
2442
|
+
key: '_instance',
|
|
2181
2443
|
get: function get() {
|
|
2182
2444
|
return this.getInstance();
|
|
2183
2445
|
}
|
|
@@ -2290,6 +2552,122 @@ var WebStorage_WebStorage = function () {
|
|
|
2290
2552
|
}();
|
|
2291
2553
|
|
|
2292
2554
|
/* harmony default export */ var core_WebStorage = (WebStorage_WebStorage);
|
|
2555
|
+
// CONCATENATED MODULE: ./src/core/DevicePixelRatio.js
|
|
2556
|
+
var DevicePixelRatio_createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
2557
|
+
|
|
2558
|
+
function DevicePixelRatio_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2559
|
+
|
|
2560
|
+
var DevicePixelRatio = function () {
|
|
2561
|
+
function DevicePixelRatio() {
|
|
2562
|
+
var magnification = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
2563
|
+
|
|
2564
|
+
DevicePixelRatio_classCallCheck(this, DevicePixelRatio);
|
|
2565
|
+
|
|
2566
|
+
this.magnification = magnification;
|
|
2567
|
+
}
|
|
2568
|
+
// 获取系统类型
|
|
2569
|
+
|
|
2570
|
+
|
|
2571
|
+
DevicePixelRatio_createClass(DevicePixelRatio, [{
|
|
2572
|
+
key: '_getSystem',
|
|
2573
|
+
value: function _getSystem() {
|
|
2574
|
+
// let flag = false;
|
|
2575
|
+
var agent = navigator.userAgent.toLowerCase();
|
|
2576
|
+
// var isMac = /macintosh|mac os x/i.test(navigator.userAgent);
|
|
2577
|
+
// if(isMac) {
|
|
2578
|
+
// return false;
|
|
2579
|
+
// }
|
|
2580
|
+
// 现只针对windows处理,其它系统暂无该情况,如有,继续在此添加
|
|
2581
|
+
if (agent.indexOf('windows') >= 0) {
|
|
2582
|
+
return true;
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
// 获取页面缩放比例
|
|
2586
|
+
// _getDevicePixelRatio() {
|
|
2587
|
+
// let t = this;
|
|
2588
|
+
// }
|
|
2589
|
+
// 监听方法兼容写法
|
|
2590
|
+
|
|
2591
|
+
}, {
|
|
2592
|
+
key: '_addHandler',
|
|
2593
|
+
value: function _addHandler(element, type, handler) {
|
|
2594
|
+
if (element.addEventListener) {
|
|
2595
|
+
element.addEventListener(type, handler, false);
|
|
2596
|
+
} else if (element.attachEvent) {
|
|
2597
|
+
element.attachEvent('on' + type, handler);
|
|
2598
|
+
} else {
|
|
2599
|
+
element['on' + type] = handler;
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
// 校正浏览器缩放比例
|
|
2603
|
+
|
|
2604
|
+
}, {
|
|
2605
|
+
key: '_correct',
|
|
2606
|
+
value: function _correct() {
|
|
2607
|
+
// 配合px2rem插件进行自适应布局
|
|
2608
|
+
var pageWidth = window.innerWidth;
|
|
2609
|
+
//为了ie也能拿到可视窗口宽度
|
|
2610
|
+
if (typeof pageWidth != 'number') {
|
|
2611
|
+
//标准模式
|
|
2612
|
+
if (document.compatMode == 'CSS1Compat') {
|
|
2613
|
+
pageWidth = document.documentElement.clientWidth;
|
|
2614
|
+
//怪异模式
|
|
2615
|
+
} else {
|
|
2616
|
+
pageWidth = document.body.clientWidth;
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
if (pageWidth <= 750) {
|
|
2620
|
+
var baseSize = 75;
|
|
2621
|
+
// 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
|
|
2622
|
+
var scale = document.documentElement.clientWidth / pageWidth;
|
|
2623
|
+
// 设置页面根节点字体大小
|
|
2624
|
+
document.documentElement.style.fontSize = this.magnification * baseSize * Math.min(scale, 2) + 'px';
|
|
2625
|
+
} else if (pageWidth > 750 && pageWidth <= 1200) {
|
|
2626
|
+
var _baseSize = 85;
|
|
2627
|
+
// 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
|
|
2628
|
+
var _scale = document.documentElement.clientWidth / pageWidth;
|
|
2629
|
+
// 设置页面根节点字体大小
|
|
2630
|
+
document.documentElement.style.fontSize = this.magnification * _baseSize * Math.min(_scale, 2) + 'px';
|
|
2631
|
+
} else {
|
|
2632
|
+
var _baseSize2 = 100;
|
|
2633
|
+
// 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
|
|
2634
|
+
var _scale2 = document.documentElement.clientWidth / 1920;
|
|
2635
|
+
// 设置页面根节点字体大小
|
|
2636
|
+
document.documentElement.style.fontSize = this.magnification * _baseSize2 * Math.min(_scale2, 2) + 'px';
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
// 监听页面缩放
|
|
2640
|
+
|
|
2641
|
+
}, {
|
|
2642
|
+
key: '_watch',
|
|
2643
|
+
value: function _watch() {
|
|
2644
|
+
var t = this;
|
|
2645
|
+
t._addHandler(window, 'resize', function () {
|
|
2646
|
+
// 注意这个方法是解决全局有两个window.resize
|
|
2647
|
+
// 重新校正
|
|
2648
|
+
t._correct();
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
// 初始化页面比例
|
|
2652
|
+
|
|
2653
|
+
}, {
|
|
2654
|
+
key: 'init',
|
|
2655
|
+
value: function init() {
|
|
2656
|
+
var t = this;
|
|
2657
|
+
if (t._getSystem()) {
|
|
2658
|
+
// 判断设备,目前只在windows系统下校正浏览器缩放比例
|
|
2659
|
+
// 初始化页面校正浏览器缩放比例
|
|
2660
|
+
t._correct();
|
|
2661
|
+
// 开启监听页面缩放
|
|
2662
|
+
t._watch();
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}]);
|
|
2666
|
+
|
|
2667
|
+
return DevicePixelRatio;
|
|
2668
|
+
}();
|
|
2669
|
+
|
|
2670
|
+
/* harmony default export */ var core_DevicePixelRatio = (DevicePixelRatio);
|
|
2293
2671
|
// CONCATENATED MODULE: ./src/index.js
|
|
2294
2672
|
|
|
2295
2673
|
|
|
@@ -2298,7 +2676,8 @@ var WebStorage_WebStorage = function () {
|
|
|
2298
2676
|
|
|
2299
2677
|
|
|
2300
2678
|
|
|
2301
|
-
// export { default as MqttClient } from './core/MqttClient' vite不支持?
|
|
2679
|
+
// export { default as MqttClient } from './core/MqttClient' // vite不支持?
|
|
2680
|
+
|
|
2302
2681
|
|
|
2303
2682
|
|
|
2304
2683
|
|