gis-common 2.0.1 → 2.1.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/resource.min.js +631 -416
- package/package.json +1 -1
package/dist/resource.min.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
2
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
3
|
-
module.exports = factory(
|
|
3
|
+
module.exports = factory();
|
|
4
4
|
else if(typeof define === 'function' && define.amd)
|
|
5
|
-
define("Gis", [
|
|
5
|
+
define("Gis", [], factory);
|
|
6
6
|
else if(typeof exports === 'object')
|
|
7
|
-
exports["Gis"] = factory(
|
|
7
|
+
exports["Gis"] = factory();
|
|
8
8
|
else
|
|
9
|
-
root["Gis"] = factory(
|
|
10
|
-
})(window, function(
|
|
9
|
+
root["Gis"] = factory();
|
|
10
|
+
})(window, function() {
|
|
11
11
|
return /******/ (function(modules) { // webpackBootstrap
|
|
12
12
|
/******/ // The module cache
|
|
13
13
|
/******/ var installedModules = {};
|
|
@@ -91,17 +91,11 @@ return /******/ (function(modules) { // webpackBootstrap
|
|
|
91
91
|
/******/
|
|
92
92
|
/******/
|
|
93
93
|
/******/ // Load entry module and return exports
|
|
94
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
|
94
|
+
/******/ return __webpack_require__(__webpack_require__.s = 0);
|
|
95
95
|
/******/ })
|
|
96
96
|
/************************************************************************/
|
|
97
97
|
/******/ ([
|
|
98
98
|
/* 0 */
|
|
99
|
-
/***/ (function(module, exports) {
|
|
100
|
-
|
|
101
|
-
module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
|
|
102
|
-
|
|
103
|
-
/***/ }),
|
|
104
|
-
/* 1 */
|
|
105
99
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
106
100
|
|
|
107
101
|
"use strict";
|
|
@@ -125,14 +119,16 @@ __webpack_require__.d(__webpack_exports__, "Utils", function() { return /* reexp
|
|
|
125
119
|
__webpack_require__.d(__webpack_exports__, "EventType", function() { return /* reexport */ EventTypeConstant; });
|
|
126
120
|
__webpack_require__.d(__webpack_exports__, "ErrorType", function() { return /* reexport */ ErrorTypeConstant; });
|
|
127
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; });
|
|
128
124
|
__webpack_require__.d(__webpack_exports__, "AudioPlayer", function() { return /* reexport */ core_AudioPlayer; });
|
|
129
125
|
__webpack_require__.d(__webpack_exports__, "CanvasDrawer", function() { return /* reexport */ core_CanvasDrawer; });
|
|
130
126
|
__webpack_require__.d(__webpack_exports__, "ElQuery", function() { return /* reexport */ core_ElQuery; });
|
|
131
127
|
__webpack_require__.d(__webpack_exports__, "EventDispatcher", function() { return /* reexport */ core_EventDispatcher; });
|
|
132
128
|
__webpack_require__.d(__webpack_exports__, "HashMap", function() { return /* reexport */ core_HashMap; });
|
|
133
|
-
__webpack_require__.d(__webpack_exports__, "MqttClient", function() { return /* reexport */ core_MqttClient; });
|
|
134
129
|
__webpack_require__.d(__webpack_exports__, "WebSocketClient", function() { return /* reexport */ core_WebSocketClient; });
|
|
135
130
|
__webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /* reexport */ core_WebStorage; });
|
|
131
|
+
__webpack_require__.d(__webpack_exports__, "DevicePixelRatio", function() { return /* reexport */ core_DevicePixelRatio; });
|
|
136
132
|
|
|
137
133
|
// CONCATENATED MODULE: ./src/utils/AnimateUtils.js
|
|
138
134
|
/* harmony default export */ var AnimateUtils = ({
|
|
@@ -233,24 +229,24 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
233
229
|
});
|
|
234
230
|
// CONCATENATED MODULE: ./src/constant/ErrorTypeConstant.js
|
|
235
231
|
/* harmony default export */ var ErrorTypeConstant = ({
|
|
236
|
-
LOGIN_EXPIRED:
|
|
237
|
-
CROSS_ERROR:
|
|
238
|
-
UNEXIST_RESOURCE:
|
|
239
|
-
TIMEOUT:
|
|
240
|
-
INTERNAL_ERROR:
|
|
241
|
-
NETWORK_ERROR:
|
|
242
|
-
PROCESS_FAIL:
|
|
243
|
-
AUTH_VERIFY_ERROR:
|
|
244
|
-
NO_DATA_FOUND:
|
|
245
|
-
DUPLICATE_INSTANCE:
|
|
246
|
-
COORDINATE_ERROR:
|
|
247
|
-
JSON_PARSE_ERROR:
|
|
248
|
-
JSON_VALUE_ERROR:
|
|
249
|
-
PARAMETER_ERROR:
|
|
250
|
-
PARAMETER_ERROR_ARRAY:
|
|
251
|
-
PARAMETER_ERROR_STRING:
|
|
252
|
-
PARAMETER_ERROR_FUNCTION:
|
|
253
|
-
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: '参数缺失'
|
|
254
250
|
});
|
|
255
251
|
// CONCATENATED MODULE: ./src/constant/LayerType.js
|
|
256
252
|
/* harmony default export */ var LayerType = ({
|
|
@@ -262,10 +258,28 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
262
258
|
S3M_GROUP: "S3MGroup", // addS3MGroupLayer(url, options, index) 添加S3M分组图层。
|
|
263
259
|
TERRAIN_LAYER: "TerrainFileLayer" // 地形图层, 需要单独处理
|
|
264
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
|
+
};
|
|
265
278
|
// CONCATENATED MODULE: ./src/constant/index.js
|
|
266
279
|
|
|
267
280
|
|
|
268
281
|
|
|
282
|
+
|
|
269
283
|
// CONCATENATED MODULE: ./src/utils/CommUtils.js
|
|
270
284
|
|
|
271
285
|
|
|
@@ -316,7 +330,7 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
316
330
|
* @param {*} json
|
|
317
331
|
* @returns {*}
|
|
318
332
|
*/
|
|
319
|
-
|
|
333
|
+
json2Query: function json2Query(json) {
|
|
320
334
|
var tempArr = [];
|
|
321
335
|
for (var i in json) {
|
|
322
336
|
var key = i;
|
|
@@ -445,24 +459,39 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
445
459
|
* 异步加载script
|
|
446
460
|
*
|
|
447
461
|
* @param {*} url
|
|
448
|
-
* @param {function} callback
|
|
449
462
|
*/
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
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
|
+
};
|
|
457
478
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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
|
+
});
|
|
466
495
|
},
|
|
467
496
|
|
|
468
497
|
/**
|
|
@@ -484,6 +513,56 @@ __webpack_require__.d(__webpack_exports__, "WebStorage", function() { return /*
|
|
|
484
513
|
}
|
|
485
514
|
return value;
|
|
486
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
|
+
}
|
|
487
566
|
}
|
|
488
567
|
});
|
|
489
568
|
// CONCATENATED MODULE: ./src/utils/ArrayUtils.js
|
|
@@ -532,6 +611,9 @@ Array.prototype.sum = function () {
|
|
|
532
611
|
return prev + curr;
|
|
533
612
|
}) : 0;
|
|
534
613
|
};
|
|
614
|
+
Array.prototype.avg = function () {
|
|
615
|
+
return this.length ? this.sum() / this.length : 0;
|
|
616
|
+
};
|
|
535
617
|
Array.prototype.desc = function (f) {
|
|
536
618
|
return this.sort(function (n1, n2) {
|
|
537
619
|
return (f ? f(n2) : n2) - (f ? f(n1) : n1);
|
|
@@ -622,8 +704,8 @@ Array.prototype.clear = function () {
|
|
|
622
704
|
for (var i = 0; i < args.length; i++) {
|
|
623
705
|
var str = args[i];
|
|
624
706
|
if (str) {
|
|
625
|
-
var s = str.replace(/#|\//g,
|
|
626
|
-
var arr = s.split(
|
|
707
|
+
var s = str.replace(/#|\//g, '');
|
|
708
|
+
var arr = s.split('?');
|
|
627
709
|
if (arr.length > 1) {
|
|
628
710
|
for (var _i = 1; _i < arr.length; _i++) {
|
|
629
711
|
var res = void 0;
|
|
@@ -638,26 +720,35 @@ Array.prototype.clear = function () {
|
|
|
638
720
|
},
|
|
639
721
|
getExplorer: function getExplorer() {
|
|
640
722
|
var explorer = window.navigator.userAgent;
|
|
641
|
-
if (explorer.indexOf(
|
|
642
|
-
return
|
|
723
|
+
if (explorer.indexOf('MSIE') >= 0) {
|
|
724
|
+
return 'IE';
|
|
643
725
|
}
|
|
644
|
-
if (!!window.ActiveXObject ||
|
|
726
|
+
if (!!window.ActiveXObject || 'ActiveXObject' in window) {
|
|
645
727
|
// IE
|
|
646
|
-
return
|
|
647
|
-
} else if (explorer.indexOf(
|
|
728
|
+
return 'IE';
|
|
729
|
+
} else if (explorer.indexOf('Firefox') >= 0) {
|
|
648
730
|
// Firefox
|
|
649
|
-
return
|
|
650
|
-
} else if (explorer.indexOf(
|
|
731
|
+
return 'Firefox';
|
|
732
|
+
} else if (explorer.indexOf('Chrome') >= 0) {
|
|
651
733
|
// Chrome
|
|
652
|
-
return
|
|
653
|
-
} else if (explorer.indexOf(
|
|
734
|
+
return 'Chrome';
|
|
735
|
+
} else if (explorer.indexOf('Opera') >= 0) {
|
|
654
736
|
// Opera
|
|
655
|
-
return
|
|
656
|
-
} else if (explorer.indexOf(
|
|
737
|
+
return 'Opera';
|
|
738
|
+
} else if (explorer.indexOf('Safari') >= 0) {
|
|
657
739
|
// Safari
|
|
658
|
-
return
|
|
740
|
+
return 'Safari';
|
|
659
741
|
}
|
|
660
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
|
+
},
|
|
661
752
|
switchFullScreen: function switchFullScreen(status) {
|
|
662
753
|
if (status) {
|
|
663
754
|
var element = document.documentElement;
|
|
@@ -689,16 +780,16 @@ Array.prototype.clear = function () {
|
|
|
689
780
|
refreshScale: function refreshScale() {
|
|
690
781
|
var baseWidth = document.documentElement.clientWidth;
|
|
691
782
|
var baseHeight = document.documentElement.clientHeight;
|
|
692
|
-
var appStyle = document.getElementById(
|
|
783
|
+
var appStyle = document.getElementById('app').style;
|
|
693
784
|
var realRatio = baseWidth / baseHeight;
|
|
694
785
|
var designRatio = 16 / 9;
|
|
695
786
|
var scaleRate = baseWidth / 1920;
|
|
696
787
|
if (realRatio > designRatio) {
|
|
697
788
|
scaleRate = baseHeight / 1080;
|
|
698
789
|
}
|
|
699
|
-
appStyle.transformOrigin =
|
|
700
|
-
appStyle.transform =
|
|
701
|
-
appStyle.width = baseWidth / scaleRate +
|
|
790
|
+
appStyle.transformOrigin = 'left top';
|
|
791
|
+
appStyle.transform = 'scale(' + scaleRate + ') translateX(-49.99%)';
|
|
792
|
+
appStyle.width = baseWidth / scaleRate + 'px';
|
|
702
793
|
},
|
|
703
794
|
|
|
704
795
|
/**
|
|
@@ -706,8 +797,8 @@ Array.prototype.clear = function () {
|
|
|
706
797
|
*/
|
|
707
798
|
getHtmlFontSize: function getHtmlFontSize() {
|
|
708
799
|
var htmlwidth = document.documentElement.clientWidth || document.body.clientWidth;
|
|
709
|
-
var htmlDom = document.querySelector(
|
|
710
|
-
htmlDom.style.fontSize = htmlwidth / 192 +
|
|
800
|
+
var htmlDom = document.querySelector('html');
|
|
801
|
+
htmlDom.style.fontSize = htmlwidth / 192 + 'px';
|
|
711
802
|
}
|
|
712
803
|
});
|
|
713
804
|
// CONCATENATED MODULE: ./src/utils/Cookie.js
|
|
@@ -717,22 +808,22 @@ Array.prototype.clear = function () {
|
|
|
717
808
|
|
|
718
809
|
var exp = new Date();
|
|
719
810
|
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
|
|
720
|
-
document.cookie = name +
|
|
811
|
+
document.cookie = name + '=' + escape(value) + ';expires=' + exp.toGMTString();
|
|
721
812
|
},
|
|
722
813
|
remove: function remove(name) {
|
|
723
814
|
var exp = new Date();
|
|
724
815
|
exp.setTime(exp.getTime() - 1);
|
|
725
|
-
var cval =
|
|
816
|
+
var cval = this.get(name);
|
|
726
817
|
if (cval != null) {
|
|
727
|
-
document.cookie = name +
|
|
818
|
+
document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString();
|
|
728
819
|
}
|
|
729
820
|
},
|
|
730
821
|
get: function get(name) {
|
|
731
|
-
var arr = document.cookie.match(new RegExp(
|
|
822
|
+
var arr = document.cookie.match(new RegExp('(^| )' + name + '=([^;]*)(;|$)'));
|
|
732
823
|
if (arr != null) {
|
|
733
824
|
return arr[2];
|
|
734
825
|
} else {
|
|
735
|
-
return
|
|
826
|
+
return '';
|
|
736
827
|
}
|
|
737
828
|
}
|
|
738
829
|
});
|
|
@@ -740,38 +831,38 @@ Array.prototype.clear = function () {
|
|
|
740
831
|
/* harmony default export */ var CoordsUtils = ({
|
|
741
832
|
PI: 3.14159265358979324,
|
|
742
833
|
XPI: 3.14159265358979324 * 3000.0 / 180.0,
|
|
743
|
-
delta: function delta(lat,
|
|
834
|
+
delta: function delta(lat, lng) {
|
|
744
835
|
var a = 6378245.0; // a: 卫星椭球坐标投影到平面地图坐标系的投影因子。
|
|
745
836
|
var ee = 0.00669342162296594323; // ee: 椭球的偏心率。
|
|
746
|
-
var dLat = this.transformLat(
|
|
747
|
-
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);
|
|
748
839
|
var radLat = lat / 180.0 * this.PI;
|
|
749
840
|
var magic = Math.sin(radLat);
|
|
750
841
|
magic = 1 - ee * magic * magic;
|
|
751
842
|
var sqrtMagic = Math.sqrt(magic);
|
|
752
843
|
dLat = dLat * 180.0 / (a * (1 - ee) / (magic * sqrtMagic) * this.PI);
|
|
753
844
|
dLon = dLon * 180.0 / (a / sqrtMagic * Math.cos(radLat) * this.PI);
|
|
754
|
-
return { lat: dLat,
|
|
845
|
+
return { lat: dLat, lng: dLon };
|
|
755
846
|
},
|
|
756
847
|
|
|
757
848
|
// WGS-84 to GCJ-02
|
|
758
849
|
gcjEncrypt: function gcjEncrypt(wgsLat, wgsLon) {
|
|
759
850
|
if (this.outOfChina(wgsLat, wgsLon)) {
|
|
760
|
-
return { lat: wgsLat,
|
|
851
|
+
return { lat: wgsLat, lng: wgsLon };
|
|
761
852
|
}
|
|
762
853
|
|
|
763
854
|
var d = this.delta(wgsLat, wgsLon);
|
|
764
|
-
return { lat: wgsLat + d.lat,
|
|
855
|
+
return { lat: wgsLat + d.lat, lng: wgsLon + d.lng };
|
|
765
856
|
},
|
|
766
857
|
|
|
767
858
|
// GCJ-02 to WGS-84
|
|
768
859
|
gcjDecrypt: function gcjDecrypt(gcjLat, gcjLon) {
|
|
769
860
|
if (this.outOfChina(gcjLat, gcjLon)) {
|
|
770
|
-
return { lat: gcjLat,
|
|
861
|
+
return { lat: gcjLat, lng: gcjLon };
|
|
771
862
|
}
|
|
772
863
|
|
|
773
864
|
var d = this.delta(gcjLat, gcjLon);
|
|
774
|
-
return { lat: gcjLat - d.lat,
|
|
865
|
+
return { lat: gcjLat - d.lat, lng: gcjLon - d.lng };
|
|
775
866
|
},
|
|
776
867
|
|
|
777
868
|
// GCJ-02 to WGS-84 exactly
|
|
@@ -792,7 +883,7 @@ Array.prototype.clear = function () {
|
|
|
792
883
|
wgsLon = (mLon + pLon) / 2;
|
|
793
884
|
var tmp = this.gcj_encrypt(wgsLat, wgsLon);
|
|
794
885
|
dLat = tmp.lat - gcjLat;
|
|
795
|
-
dLon = tmp.
|
|
886
|
+
dLon = tmp.lng - gcjLon;
|
|
796
887
|
if (Math.abs(dLat) < threshold && Math.abs(dLon) < threshold) {
|
|
797
888
|
break;
|
|
798
889
|
}
|
|
@@ -803,7 +894,7 @@ Array.prototype.clear = function () {
|
|
|
803
894
|
if (++i > 10000) break;
|
|
804
895
|
}
|
|
805
896
|
// console.log(i);
|
|
806
|
-
return { lat: wgsLat,
|
|
897
|
+
return { lat: wgsLat, lng: wgsLon };
|
|
807
898
|
},
|
|
808
899
|
|
|
809
900
|
// GCJ-02 to BD-09
|
|
@@ -812,9 +903,9 @@ Array.prototype.clear = function () {
|
|
|
812
903
|
var y = gcjLat;
|
|
813
904
|
var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * this.XPI);
|
|
814
905
|
var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * this.XPI);
|
|
815
|
-
bdLon = z * Math.cos(theta) + 0.0065;
|
|
816
|
-
bdLat = z * Math.sin(theta) + 0.006;
|
|
817
|
-
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 };
|
|
818
909
|
},
|
|
819
910
|
|
|
820
911
|
// BD-09 to GCJ-02
|
|
@@ -825,7 +916,7 @@ Array.prototype.clear = function () {
|
|
|
825
916
|
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * this.XPI);
|
|
826
917
|
var gcjLon = z * Math.cos(theta);
|
|
827
918
|
var gcjLat = z * Math.sin(theta);
|
|
828
|
-
return { lat: gcjLat,
|
|
919
|
+
return { lat: gcjLat, lng: gcjLon };
|
|
829
920
|
},
|
|
830
921
|
|
|
831
922
|
// WGS-84 to Web mercator
|
|
@@ -834,16 +925,7 @@ Array.prototype.clear = function () {
|
|
|
834
925
|
var x = wgsLon * 20037508.34 / 180.0;
|
|
835
926
|
var y = Math.log(Math.tan((90.0 + wgsLat) * this.PI / 360.0)) / (this.PI / 180.0);
|
|
836
927
|
y = y * 20037508.34 / 180.0;
|
|
837
|
-
return { lat: y,
|
|
838
|
-
/*
|
|
839
|
-
if ((Math.abs(wgsLon) > 180 || Math.abs(wgsLat) > 90))
|
|
840
|
-
return null;
|
|
841
|
-
var x = 6378137.0 * wgsLon * 0.017453292519943295;
|
|
842
|
-
var a = wgsLat * 0.017453292519943295;
|
|
843
|
-
var y = 3189068.5 * Math.log((1.0 + Math.sin(a)) / (1.0 - Math.sin(a)));
|
|
844
|
-
return {'lat' : y, 'lon' : x};
|
|
845
|
-
// */
|
|
846
|
-
};
|
|
928
|
+
return { lat: y, lng: x };
|
|
847
929
|
},
|
|
848
930
|
|
|
849
931
|
// Web mercator to WGS-84
|
|
@@ -852,24 +934,13 @@ Array.prototype.clear = function () {
|
|
|
852
934
|
var x = mercatorLon / 20037508.34 * 180.0;
|
|
853
935
|
var y = mercatorLat / 20037508.34 * 180.0;
|
|
854
936
|
y = 180 / this.PI * (2 * Math.atan(Math.exp(y * this.PI / 180.0)) - this.PI / 2);
|
|
855
|
-
return { lat: y,
|
|
856
|
-
/*
|
|
857
|
-
if (Math.abs(mercatorLon) < 180 && Math.abs(mercatorLat) < 90)
|
|
858
|
-
return null;
|
|
859
|
-
if ((Math.abs(mercatorLon) > 20037508.3427892) || (Math.abs(mercatorLat) > 20037508.3427892))
|
|
860
|
-
return null;
|
|
861
|
-
var a = mercatorLon / 6378137.0 * 57.295779513082323;
|
|
862
|
-
var x = a - (Math.floor(((a + 180.0) / 360.0)) * 360.0);
|
|
863
|
-
var y = (1.5707963267948966 - (2.0 * Math.atan(Math.exp((-1.0 * mercatorLat) / 6378137.0)))) * 57.295779513082323;
|
|
864
|
-
return {'lat' : y, 'lon' : x};
|
|
865
|
-
// */
|
|
866
|
-
};
|
|
937
|
+
return { lat: y, lng: x };
|
|
867
938
|
},
|
|
868
939
|
|
|
869
940
|
// two point's distance
|
|
870
|
-
distance: function distance(latA,
|
|
941
|
+
distance: function distance(latA, lngA, latB, lngB) {
|
|
871
942
|
var earthR = 6371000.0;
|
|
872
|
-
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);
|
|
873
944
|
var y = Math.sin(latA * this.PI / 180.0) * Math.sin(latB * this.PI / 180.0);
|
|
874
945
|
var s = x + y;
|
|
875
946
|
if (s > 1) s = 1;
|
|
@@ -878,8 +949,8 @@ Array.prototype.clear = function () {
|
|
|
878
949
|
var distance = alpha * earthR;
|
|
879
950
|
return distance;
|
|
880
951
|
},
|
|
881
|
-
outOfChina: function outOfChina(lat,
|
|
882
|
-
if (
|
|
952
|
+
outOfChina: function outOfChina(lat, lng) {
|
|
953
|
+
if (lng < 72.004 || lng > 137.8347) {
|
|
883
954
|
return true;
|
|
884
955
|
}
|
|
885
956
|
if (lat < 0.8293 || lat > 55.8271) {
|
|
@@ -905,17 +976,17 @@ Array.prototype.clear = function () {
|
|
|
905
976
|
// CONCATENATED MODULE: ./src/utils/DateUtils.js
|
|
906
977
|
Date.prototype.format = function (fmt) {
|
|
907
978
|
var o = {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
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), // 季度
|
|
914
985
|
S: this.getMilliseconds() // 毫秒
|
|
915
986
|
};
|
|
916
|
-
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));
|
|
917
988
|
for (var k in o) {
|
|
918
|
-
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));
|
|
919
990
|
}
|
|
920
991
|
return fmt;
|
|
921
992
|
};
|
|
@@ -928,28 +999,28 @@ Date.prototype.format = function (fmt) {
|
|
|
928
999
|
Date.prototype.addDate = function (interval, number) {
|
|
929
1000
|
var date = new Date(this);
|
|
930
1001
|
switch (interval) {
|
|
931
|
-
case
|
|
1002
|
+
case 'y':
|
|
932
1003
|
date.setFullYear(this.getFullYear() + number);
|
|
933
1004
|
break;
|
|
934
|
-
case
|
|
1005
|
+
case 'q':
|
|
935
1006
|
date.setMonth(this.getMonth() + number * 3);
|
|
936
1007
|
break;
|
|
937
|
-
case
|
|
1008
|
+
case 'M':
|
|
938
1009
|
date.setMonth(this.getMonth() + number);
|
|
939
1010
|
break;
|
|
940
|
-
case
|
|
1011
|
+
case 'w':
|
|
941
1012
|
date.setDate(this.getDate() + number * 7);
|
|
942
1013
|
break;
|
|
943
|
-
case
|
|
1014
|
+
case 'd':
|
|
944
1015
|
date.setDate(this.getDate() + number);
|
|
945
1016
|
break;
|
|
946
|
-
case
|
|
1017
|
+
case 'h':
|
|
947
1018
|
date.setHours(this.getHours() + number);
|
|
948
1019
|
break;
|
|
949
|
-
case
|
|
1020
|
+
case 'm':
|
|
950
1021
|
date.setMinutes(this.getMinutes() + number);
|
|
951
1022
|
break;
|
|
952
|
-
case
|
|
1023
|
+
case 's':
|
|
953
1024
|
date.setSeconds(this.getSeconds() + number);
|
|
954
1025
|
break;
|
|
955
1026
|
default:
|
|
@@ -959,11 +1030,14 @@ Date.prototype.addDate = function (interval, number) {
|
|
|
959
1030
|
return date;
|
|
960
1031
|
};
|
|
961
1032
|
/* harmony default export */ var DateUtils = ({
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
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),
|
|
965
1039
|
parseDate: function parseDate(str) {
|
|
966
|
-
if (typeof str ==
|
|
1040
|
+
if (typeof str == 'string') {
|
|
967
1041
|
var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
|
|
968
1042
|
if (results && results.length > 3) return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]));
|
|
969
1043
|
results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
|
|
@@ -992,21 +1066,21 @@ Date.prototype.addDate = function (interval, number) {
|
|
|
992
1066
|
var minutes = Math.floor(leave2 / (60 * 1000));
|
|
993
1067
|
var leave3 = leave2 % (60 * 1000);
|
|
994
1068
|
var seconds = Math.round(leave3 / 1000);
|
|
995
|
-
var intervalDes =
|
|
1069
|
+
var intervalDes = '';
|
|
996
1070
|
if (days > 0) {
|
|
997
|
-
intervalDes += days +
|
|
1071
|
+
intervalDes += days + '天';
|
|
998
1072
|
}
|
|
999
1073
|
if (hours > 0) {
|
|
1000
|
-
intervalDes += hours +
|
|
1074
|
+
intervalDes += hours + '时';
|
|
1001
1075
|
}
|
|
1002
1076
|
if (minutes > 0) {
|
|
1003
|
-
intervalDes += minutes +
|
|
1077
|
+
intervalDes += minutes + '分';
|
|
1004
1078
|
}
|
|
1005
1079
|
if (seconds > 0) {
|
|
1006
|
-
intervalDes += seconds +
|
|
1080
|
+
intervalDes += seconds + '秒';
|
|
1007
1081
|
}
|
|
1008
1082
|
if (days === 0 && hours === 0 && minutes === 0 && seconds === 0) {
|
|
1009
|
-
intervalDes =
|
|
1083
|
+
intervalDes = '少于1秒';
|
|
1010
1084
|
}
|
|
1011
1085
|
return intervalDes;
|
|
1012
1086
|
},
|
|
@@ -1016,7 +1090,7 @@ Date.prototype.addDate = function (interval, number) {
|
|
|
1016
1090
|
});
|
|
1017
1091
|
// CONCATENATED MODULE: ./src/utils/DomUtils.js
|
|
1018
1092
|
function trim(str) {
|
|
1019
|
-
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g,
|
|
1093
|
+
return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
|
|
1020
1094
|
}
|
|
1021
1095
|
function splitWords(str) {
|
|
1022
1096
|
return trim(str).split(/\s+/);
|
|
@@ -1025,15 +1099,15 @@ function splitWords(str) {
|
|
|
1025
1099
|
getStyle: function getStyle(el, style) {
|
|
1026
1100
|
var value = el.style[style] || el.currentStyle && el.currentStyle[style];
|
|
1027
1101
|
|
|
1028
|
-
if ((!value || value ===
|
|
1102
|
+
if ((!value || value === 'auto') && document.defaultView) {
|
|
1029
1103
|
var css = document.defaultView.getComputedStyle(el, null);
|
|
1030
1104
|
value = css ? css[style] : null;
|
|
1031
1105
|
}
|
|
1032
|
-
return value ===
|
|
1106
|
+
return value === 'auto' ? null : value;
|
|
1033
1107
|
},
|
|
1034
1108
|
create: function create(tagName, className, container) {
|
|
1035
1109
|
var el = document.createElement(tagName);
|
|
1036
|
-
el.className = className ||
|
|
1110
|
+
el.className = className || '';
|
|
1037
1111
|
|
|
1038
1112
|
if (container) {
|
|
1039
1113
|
container.appendChild(el);
|
|
@@ -1074,7 +1148,7 @@ function splitWords(str) {
|
|
|
1074
1148
|
return el.classList.contains(name);
|
|
1075
1149
|
}
|
|
1076
1150
|
var className = this.getClass(el);
|
|
1077
|
-
return className.length > 0 && new RegExp(
|
|
1151
|
+
return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
|
|
1078
1152
|
},
|
|
1079
1153
|
addClass: function addClass(el, name) {
|
|
1080
1154
|
if (el.classList !== undefined) {
|
|
@@ -1084,7 +1158,7 @@ function splitWords(str) {
|
|
|
1084
1158
|
}
|
|
1085
1159
|
} else if (!this.hasClass(el, name)) {
|
|
1086
1160
|
var className = this.getClass(el);
|
|
1087
|
-
this.setClass(el, (className ? className +
|
|
1161
|
+
this.setClass(el, (className ? className + ' ' : '') + name);
|
|
1088
1162
|
}
|
|
1089
1163
|
},
|
|
1090
1164
|
removeClass: function removeClass(el, name) {
|
|
@@ -1094,7 +1168,7 @@ function splitWords(str) {
|
|
|
1094
1168
|
return el.classList.remove(name);
|
|
1095
1169
|
});
|
|
1096
1170
|
} else {
|
|
1097
|
-
this.setClass(el, trim((
|
|
1171
|
+
this.setClass(el, trim((' ' + this.getClass(el) + ' ').replace(' ' + name + ' ', ' ')));
|
|
1098
1172
|
}
|
|
1099
1173
|
},
|
|
1100
1174
|
setClass: function setClass(el, name) {
|
|
@@ -1104,10 +1178,74 @@ function splitWords(str) {
|
|
|
1104
1178
|
// in case of SVG element
|
|
1105
1179
|
el.className.baseVal = name;
|
|
1106
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);
|
|
1107
1242
|
}
|
|
1108
1243
|
});
|
|
1109
1244
|
// CONCATENATED MODULE: ./src/utils/GeoUtils.js
|
|
1245
|
+
|
|
1110
1246
|
/* harmony default export */ var GeoUtils = ({
|
|
1247
|
+
toRadian: Math.PI / 180,
|
|
1248
|
+
R: 6371393,
|
|
1111
1249
|
/**
|
|
1112
1250
|
* 验证经纬度坐标
|
|
1113
1251
|
*
|
|
@@ -1116,7 +1254,7 @@ function splitWords(str) {
|
|
|
1116
1254
|
* @returns {*} {boolean}
|
|
1117
1255
|
*/
|
|
1118
1256
|
isLnglat: function isLnglat(lng, lat) {
|
|
1119
|
-
return !!(+lat >
|
|
1257
|
+
return !!(+lat > -90 && +lat < 90 && +lng > -180 && +lng < 180);
|
|
1120
1258
|
},
|
|
1121
1259
|
|
|
1122
1260
|
/**
|
|
@@ -1132,14 +1270,8 @@ function splitWords(str) {
|
|
|
1132
1270
|
var a = parseFloat(value);
|
|
1133
1271
|
var degree = parseInt(a);
|
|
1134
1272
|
var min = parseInt((a - degree) * 60);
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
}
|
|
1138
|
-
var sec = parseInt((a - degree) * 3600 - min * 60);
|
|
1139
|
-
if (sec < 10) {
|
|
1140
|
-
sec = '0' + sec;
|
|
1141
|
-
}
|
|
1142
|
-
return degree + '°' + min + '′' + sec + '″';
|
|
1273
|
+
var sec = (a - degree) * 3600 - min * 60;
|
|
1274
|
+
return degree + '°' + min + '′' + sec.toFixed(2) + '″';
|
|
1143
1275
|
}
|
|
1144
1276
|
if (lng && lat) {
|
|
1145
1277
|
res = format(lng) + ',' + format(lat);
|
|
@@ -1147,6 +1279,33 @@ function splitWords(str) {
|
|
|
1147
1279
|
return res;
|
|
1148
1280
|
},
|
|
1149
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
|
+
|
|
1150
1309
|
/**
|
|
1151
1310
|
* 判断点是否在多边形内
|
|
1152
1311
|
*
|
|
@@ -1243,6 +1402,81 @@ function splitWords(str) {
|
|
|
1243
1402
|
var fwdAz = Math.atan2(cosU2 * sinLambda, cosU1 * sinU2 - sinU1 * cosU2 * cosLambda);
|
|
1244
1403
|
var revAz = Math.atan2(cosU1 * sinLambda, -sinU1 * cosU2 + cosU1 * sinU2 * cosLambda);
|
|
1245
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 lon = x / 20037508.34 * 180;
|
|
1470
|
+
var lat = y / 20037508.34 * 180;
|
|
1471
|
+
y = 180 / Math.PI * (2 * Math.atan(Math.exp(y * Math.PI / 180)) - Math.PI / 2);
|
|
1472
|
+
return { lon: lon, lat: lat };
|
|
1473
|
+
},
|
|
1474
|
+
lonlatToMercator: function lonlatToMercator(lon, lat) {
|
|
1475
|
+
var x = lon * 20037508.34 / 180;
|
|
1476
|
+
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180);
|
|
1477
|
+
|
|
1478
|
+
y = y * 20037508.34 / 180;
|
|
1479
|
+
return { x: x, y: y };
|
|
1246
1480
|
}
|
|
1247
1481
|
});
|
|
1248
1482
|
// CONCATENATED MODULE: ./src/utils/FileUtils.js
|
|
@@ -1256,8 +1490,8 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1256
1490
|
* @returns {*}
|
|
1257
1491
|
*/
|
|
1258
1492
|
convertBase64ToBlob: function convertBase64ToBlob(data) {
|
|
1259
|
-
var mimeString = data.split(
|
|
1260
|
-
var byteString = window.atob(data.split(
|
|
1493
|
+
var mimeString = data.split(',')[0].split(':')[1].split(';')[0];
|
|
1494
|
+
var byteString = window.atob(data.split(',')[1]);
|
|
1261
1495
|
var ab = new ArrayBuffer(byteString.length);
|
|
1262
1496
|
var ia = new Uint8Array(ab);
|
|
1263
1497
|
|
|
@@ -1289,19 +1523,19 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1289
1523
|
convertUrlToBase64: function convertUrlToBase64(url, width, height) {
|
|
1290
1524
|
return new Promise(function (resolve, reject) {
|
|
1291
1525
|
var img = new Image();
|
|
1292
|
-
img.crossOrigin =
|
|
1526
|
+
img.crossOrigin = 'Anonymous';
|
|
1293
1527
|
img.src = url;
|
|
1294
1528
|
img.onload = function () {
|
|
1295
|
-
var canvas = document.createElement(
|
|
1529
|
+
var canvas = document.createElement('canvas');
|
|
1296
1530
|
canvas.width = width || img.width;
|
|
1297
1531
|
canvas.height = height || img.height;
|
|
1298
|
-
var ctx = canvas.getContext(
|
|
1532
|
+
var ctx = canvas.getContext('2d');
|
|
1299
1533
|
ctx.drawImage(img, 0, 0, img.width, img.height);
|
|
1300
|
-
var ext = img.src.substring(img.src.lastIndexOf(
|
|
1301
|
-
var dataURL = canvas.toDataURL(
|
|
1534
|
+
var ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase();
|
|
1535
|
+
var dataURL = canvas.toDataURL('image/' + ext);
|
|
1302
1536
|
var base64 = {
|
|
1303
1537
|
dataURL: dataURL,
|
|
1304
|
-
type:
|
|
1538
|
+
type: 'image/' + ext,
|
|
1305
1539
|
ext: ext
|
|
1306
1540
|
};
|
|
1307
1541
|
resolve(base64);
|
|
@@ -1317,7 +1551,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1317
1551
|
* @returns {*}
|
|
1318
1552
|
*/
|
|
1319
1553
|
convertBase64ToFile: function convertBase64ToFile(dataurl, filename) {
|
|
1320
|
-
var arr = dataurl.split(
|
|
1554
|
+
var arr = dataurl.split(','),
|
|
1321
1555
|
mime = arr[0].match(/:(.*?);/)[1],
|
|
1322
1556
|
bstr = atob(arr[1]),
|
|
1323
1557
|
n = bstr.length,
|
|
@@ -1332,56 +1566,30 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1332
1566
|
/**
|
|
1333
1567
|
* 直接下载文件,支持blob类型和url类型
|
|
1334
1568
|
*
|
|
1335
|
-
* @param {*}
|
|
1569
|
+
* @param {*} data
|
|
1336
1570
|
* @param {*} saveName
|
|
1337
1571
|
*/
|
|
1338
|
-
downloadFromFile: function downloadFromFile(
|
|
1339
|
-
|
|
1340
|
-
|
|
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);
|
|
1341
1585
|
}
|
|
1342
|
-
var link = document.createElement(
|
|
1586
|
+
var link = document.createElement('a');
|
|
1343
1587
|
link.href = url;
|
|
1344
|
-
link.download = saveName ||
|
|
1588
|
+
link.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
|
|
1345
1589
|
link.click();
|
|
1346
1590
|
window.URL.revokeObjectURL(link.href);
|
|
1347
1591
|
}
|
|
1348
1592
|
});
|
|
1349
|
-
// CONCATENATED MODULE: ./src/utils/MathUtils.js
|
|
1350
|
-
/* harmony default export */ var MathUtils = ({
|
|
1351
|
-
DEG2RAD: Math.PI / 180,
|
|
1352
|
-
RAD2DEG: 180 / Math.PI,
|
|
1353
|
-
randInt: function randInt(low, high) {
|
|
1354
|
-
return low + Math.floor(Math.random() * (high - low + 1));
|
|
1355
|
-
},
|
|
1356
|
-
randFloat: function randFloat(low, high) {
|
|
1357
|
-
return low + Math.random() * (high - low);
|
|
1358
|
-
},
|
|
1359
|
-
|
|
1360
|
-
/**
|
|
1361
|
-
* 角度转弧度
|
|
1362
|
-
*
|
|
1363
|
-
* @param {*} degrees
|
|
1364
|
-
* @returns {*}
|
|
1365
|
-
*/
|
|
1366
|
-
degreesToRadians: function degreesToRadians(degrees) {
|
|
1367
|
-
return degrees * this.DEG2RAD;
|
|
1368
|
-
},
|
|
1369
|
-
|
|
1370
|
-
/**
|
|
1371
|
-
* 弧度转角度
|
|
1372
|
-
*
|
|
1373
|
-
* @param {*} radians
|
|
1374
|
-
* @returns {*}
|
|
1375
|
-
*/
|
|
1376
|
-
radiansToDegrees: function radiansToDegrees(radians) {
|
|
1377
|
-
return radians * this.RAD2DEG;
|
|
1378
|
-
},
|
|
1379
|
-
formatFloat: function formatFloat(value) {
|
|
1380
|
-
var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
|
1381
|
-
|
|
1382
|
-
return Math.round(value * Math.pow(10, n)) / Math.pow(10, n);
|
|
1383
|
-
}
|
|
1384
|
-
});
|
|
1385
1593
|
// CONCATENATED MODULE: ./src/utils/OptimizeUtils.js
|
|
1386
1594
|
/* harmony default export */ var OptimizeUtils = ({
|
|
1387
1595
|
/**
|
|
@@ -1448,9 +1656,9 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1448
1656
|
*/
|
|
1449
1657
|
throttle: function throttle(func, wait, type) {
|
|
1450
1658
|
if (type === 1) {
|
|
1451
|
-
var
|
|
1659
|
+
var previous = 0;
|
|
1452
1660
|
} else if (type === 2) {
|
|
1453
|
-
var
|
|
1661
|
+
var timeout;
|
|
1454
1662
|
}
|
|
1455
1663
|
return function () {
|
|
1456
1664
|
var context = this;
|
|
@@ -1493,6 +1701,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1493
1701
|
}
|
|
1494
1702
|
});
|
|
1495
1703
|
// CONCATENATED MODULE: ./src/utils/StringUtils.js
|
|
1704
|
+
|
|
1496
1705
|
/* harmony default export */ var StringUtils = ({
|
|
1497
1706
|
/**
|
|
1498
1707
|
* 常用正则验证
|
|
@@ -1610,17 +1819,62 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
|
|
1610
1819
|
return str;
|
|
1611
1820
|
}
|
|
1612
1821
|
},
|
|
1822
|
+
|
|
1823
|
+
/**
|
|
1824
|
+
* 处理字符串模板
|
|
1825
|
+
* eg: tag`${abc}`
|
|
1826
|
+
* @param {*} strArray
|
|
1827
|
+
* @param {*} args
|
|
1828
|
+
* @returns {*}
|
|
1829
|
+
*/
|
|
1613
1830
|
tag: function tag(strArray) {
|
|
1614
1831
|
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1615
1832
|
args[_key - 1] = arguments[_key];
|
|
1616
1833
|
}
|
|
1617
1834
|
|
|
1618
1835
|
args = args.map(function (val) {
|
|
1619
|
-
|
|
1836
|
+
switch (CommUtils.getDataType(val)) {
|
|
1837
|
+
case 'Object':
|
|
1838
|
+
return val || '{}';
|
|
1839
|
+
case 'Array':
|
|
1840
|
+
return val || '[]';
|
|
1841
|
+
default:
|
|
1842
|
+
return val || '';
|
|
1843
|
+
}
|
|
1620
1844
|
});
|
|
1621
1845
|
return strArray.reduce(function (prev, next, index) {
|
|
1622
1846
|
return '' + prev + args[index - 1] + next;
|
|
1623
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;
|
|
1624
1878
|
}
|
|
1625
1879
|
});
|
|
1626
1880
|
// CONCATENATED MODULE: ./src/utils/index.js
|
|
@@ -1853,6 +2107,9 @@ var ElQuery = function () {
|
|
|
1853
2107
|
var _this3 = this;
|
|
1854
2108
|
|
|
1855
2109
|
this.each(function (obj) {
|
|
2110
|
+
obj.removeEventListener(type, function (e) {
|
|
2111
|
+
callback.call(_this3, e);
|
|
2112
|
+
});
|
|
1856
2113
|
obj.addEventListener(type, function (e) {
|
|
1857
2114
|
callback.call(_this3, e);
|
|
1858
2115
|
});
|
|
@@ -2046,184 +2303,27 @@ var HashMap = function () {
|
|
|
2046
2303
|
}();
|
|
2047
2304
|
|
|
2048
2305
|
/* harmony default export */ var core_HashMap = (HashMap);
|
|
2049
|
-
// EXTERNAL MODULE: external "mqtt"
|
|
2050
|
-
var external_mqtt_ = __webpack_require__(0);
|
|
2051
|
-
|
|
2052
|
-
// CONCATENATED MODULE: ./src/core/MqttClient.js
|
|
2053
|
-
var MqttClient_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; }; }();
|
|
2054
|
-
|
|
2055
|
-
function MqttClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2056
|
-
|
|
2057
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
2058
|
-
|
|
2059
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
var MqttClient_MqttClient = function (_EventDispatcher) {
|
|
2068
|
-
_inherits(MqttClient, _EventDispatcher);
|
|
2069
|
-
|
|
2070
|
-
/**
|
|
2071
|
-
* Creates an instance of MqttClient.
|
|
2072
|
-
* @param {*} config mqtt实例参数
|
|
2073
|
-
*/
|
|
2074
|
-
function MqttClient() {
|
|
2075
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2076
|
-
|
|
2077
|
-
MqttClient_classCallCheck(this, MqttClient);
|
|
2078
|
-
|
|
2079
|
-
var _this = _possibleConstructorReturn(this, (MqttClient.__proto__ || Object.getPrototypeOf(MqttClient)).call(this));
|
|
2080
|
-
|
|
2081
|
-
_this.context = CommUtils.extend(MqttClient.defaultContext, config);
|
|
2082
|
-
_this.options = {
|
|
2083
|
-
connectTimeout: _this.context.MQTT_TIMEOUTM,
|
|
2084
|
-
clientId: CommUtils.generateGuid(),
|
|
2085
|
-
username: _this.context.MQTT_USERNAME,
|
|
2086
|
-
password: _this.context.MQTT_PASSWORD,
|
|
2087
|
-
clean: true
|
|
2088
|
-
};
|
|
2089
|
-
_this.client = Object(external_mqtt_["connect"])(_this.context.MQTT_SERVICE, _this.options);
|
|
2090
|
-
_this._onConnect();
|
|
2091
|
-
_this._onMessage();
|
|
2092
|
-
MqttClient.instance = _this;
|
|
2093
|
-
return _this;
|
|
2094
|
-
}
|
|
2095
|
-
|
|
2096
|
-
MqttClient_createClass(MqttClient, [{
|
|
2097
|
-
key: "_onConnect",
|
|
2098
|
-
value: function _onConnect() {
|
|
2099
|
-
var _this2 = this;
|
|
2100
|
-
|
|
2101
|
-
this.client.on("connect", function () {
|
|
2102
|
-
console.log("链接mqtt成功==>" + _this2.context.MQTT_SERVICE);
|
|
2103
|
-
_this2.dispatchEvent({ type: EventTypeConstant.MQTT_CONNECT, message: _this2 });
|
|
2104
|
-
});
|
|
2105
|
-
this.client.on("error", function (err) {
|
|
2106
|
-
console.log("链接mqtt报错", err);
|
|
2107
|
-
_this2.dispatchEvent({ type: EventTypeConstant.MQTT_ERROR, message: _this2 });
|
|
2108
|
-
_this2.client.end();
|
|
2109
|
-
_this2.client.reconnect();
|
|
2110
|
-
});
|
|
2111
|
-
}
|
|
2112
|
-
}, {
|
|
2113
|
-
key: "_onMessage",
|
|
2114
|
-
value: function _onMessage() {
|
|
2115
|
-
var _this3 = this;
|
|
2116
|
-
|
|
2117
|
-
this.client.on("message", function (topic, message) {
|
|
2118
|
-
var dataString = message;
|
|
2119
|
-
var data = "";
|
|
2120
|
-
if (message instanceof Uint8Array) {
|
|
2121
|
-
dataString = message.toString();
|
|
2122
|
-
}
|
|
2123
|
-
try {
|
|
2124
|
-
data = JSON.parse(dataString);
|
|
2125
|
-
} catch (error) {
|
|
2126
|
-
throw new Error(ErrorTypeConstant.JSON_PARSE_ERROR);
|
|
2127
|
-
}
|
|
2128
|
-
_this3.dispatchEvent({
|
|
2129
|
-
type: EventTypeConstant.MQTT_MESSAGE,
|
|
2130
|
-
message: { topic: topic, data: data }
|
|
2131
|
-
});
|
|
2132
|
-
});
|
|
2133
|
-
}
|
|
2134
|
-
}, {
|
|
2135
|
-
key: "sendMsg",
|
|
2136
|
-
value: function sendMsg(topic, msg) {
|
|
2137
|
-
if (!this.client.connected) {
|
|
2138
|
-
console.error("客户端未连接");
|
|
2139
|
-
return;
|
|
2140
|
-
}
|
|
2141
|
-
this.client.publish(topic, msg, { qos: 1, retain: true });
|
|
2142
|
-
}
|
|
2143
|
-
}, {
|
|
2144
|
-
key: "subscribe",
|
|
2145
|
-
value: function subscribe(topic) {
|
|
2146
|
-
this.client.subscribe(topic, { qos: 1 }, function (error, res) {
|
|
2147
|
-
if (error instanceof Error || res.length === 0) {
|
|
2148
|
-
console.error("\u8BA2\u9605\u5931\u8D25==>" + topic, error);
|
|
2149
|
-
} else {
|
|
2150
|
-
console.log("\u8BA2\u9605\u6210\u529F==>" + topic);
|
|
2151
|
-
}
|
|
2152
|
-
});
|
|
2153
|
-
return this;
|
|
2154
|
-
}
|
|
2155
|
-
}, {
|
|
2156
|
-
key: "unsubscribe",
|
|
2157
|
-
value: function unsubscribe(topic) {
|
|
2158
|
-
this.client.unsubscribe(topic, { qos: 1 }, function (error, res) {
|
|
2159
|
-
if (error instanceof Error || res.length === 0) {
|
|
2160
|
-
console.error("\u53D6\u6D88\u8BA2\u9605\u5931\u8D25==>" + topic, error);
|
|
2161
|
-
} else {
|
|
2162
|
-
console.log("\u53D6\u6D88\u8BA2\u9605\u6210\u529F==>" + topic);
|
|
2163
|
-
}
|
|
2164
|
-
});
|
|
2165
|
-
return this;
|
|
2166
|
-
}
|
|
2167
|
-
}, {
|
|
2168
|
-
key: "unconnect",
|
|
2169
|
-
value: function unconnect() {
|
|
2170
|
-
this.client.end();
|
|
2171
|
-
this.client = null;
|
|
2172
|
-
this.dispatchEvent({ type: EventTypeConstant.MQTT_CLOSE, message: null });
|
|
2173
|
-
console.log("断开mqtt成功==>" + this.context.MQTT_SERVICE);
|
|
2174
|
-
}
|
|
2175
|
-
/**
|
|
2176
|
-
* @description 获取并冻结mqtt实例
|
|
2177
|
-
* @static
|
|
2178
|
-
* @param {*} [config={}]
|
|
2179
|
-
* @returns {MqttClient}
|
|
2180
|
-
*/
|
|
2181
|
-
|
|
2182
|
-
}], [{
|
|
2183
|
-
key: "getInstance",
|
|
2184
|
-
value: function getInstance() {
|
|
2185
|
-
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2186
|
-
|
|
2187
|
-
if (MqttClient.instance) {
|
|
2188
|
-
return Object.freeze(MqttClient.instance);
|
|
2189
|
-
} else {
|
|
2190
|
-
return Object.freeze(new MqttClient(config));
|
|
2191
|
-
}
|
|
2192
|
-
}
|
|
2193
|
-
}]);
|
|
2194
|
-
|
|
2195
|
-
return MqttClient;
|
|
2196
|
-
}(core_EventDispatcher);
|
|
2197
|
-
|
|
2198
|
-
/* harmony default export */ var core_MqttClient = (MqttClient_MqttClient);
|
|
2199
|
-
|
|
2200
|
-
MqttClient_MqttClient.defaultContext = {
|
|
2201
|
-
MQTT_TIMEOUTM: 20000,
|
|
2202
|
-
MQTT_USERNAME: "iRVMS-WEB",
|
|
2203
|
-
MQTT_PASSWORD: "novasky888",
|
|
2204
|
-
MQTT_SERVICE: "ws://" + window.document.domain + ":20007/mqtt"
|
|
2205
|
-
};
|
|
2206
2306
|
// CONCATENATED MODULE: ./src/core/WebSocketClient.js
|
|
2207
2307
|
var WebSocketClient_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; }; }();
|
|
2208
2308
|
|
|
2209
2309
|
function WebSocketClient_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
2210
2310
|
|
|
2211
|
-
function
|
|
2311
|
+
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
2212
2312
|
|
|
2213
|
-
function
|
|
2313
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
2214
2314
|
|
|
2215
2315
|
|
|
2216
2316
|
|
|
2217
2317
|
|
|
2218
2318
|
var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
2219
|
-
|
|
2319
|
+
_inherits(WebSocketClient, _EventDispatcher);
|
|
2220
2320
|
|
|
2221
2321
|
function WebSocketClient() {
|
|
2222
|
-
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';
|
|
2223
2323
|
|
|
2224
2324
|
WebSocketClient_classCallCheck(this, WebSocketClient);
|
|
2225
2325
|
|
|
2226
|
-
var _this =
|
|
2326
|
+
var _this = _possibleConstructorReturn(this, (WebSocketClient.__proto__ || Object.getPrototypeOf(WebSocketClient)).call(this));
|
|
2227
2327
|
|
|
2228
2328
|
_this.maxCheckTimes = 10;
|
|
2229
2329
|
_this.url = url;
|
|
@@ -2237,40 +2337,37 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2237
2337
|
}
|
|
2238
2338
|
|
|
2239
2339
|
WebSocketClient_createClass(WebSocketClient, [{
|
|
2240
|
-
key:
|
|
2340
|
+
key: 'connect',
|
|
2241
2341
|
value: function connect() {
|
|
2242
|
-
var _this2 = this;
|
|
2243
|
-
|
|
2244
|
-
this.checkTimes++;
|
|
2245
2342
|
this.disconnect();
|
|
2246
2343
|
if (this.url) {
|
|
2247
2344
|
try {
|
|
2248
|
-
console.info(
|
|
2345
|
+
console.info('创建ws连接>>>' + this.url);
|
|
2249
2346
|
this.client = new WebSocket(this.url);
|
|
2250
2347
|
if (this.client) {
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
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) {
|
|
2272
2369
|
this.client.onerror = function (message) {
|
|
2273
|
-
|
|
2370
|
+
self.dispatchEvent({
|
|
2274
2371
|
type: EventTypeConstant.WEB_SOCKET_ERROR,
|
|
2275
2372
|
message: message
|
|
2276
2373
|
});
|
|
@@ -2278,16 +2375,16 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2278
2375
|
}
|
|
2279
2376
|
}
|
|
2280
2377
|
} catch (ex) {
|
|
2281
|
-
console.error(
|
|
2378
|
+
console.error('创建ws连接失败' + this.url + ':' + ex);
|
|
2282
2379
|
}
|
|
2283
2380
|
}
|
|
2284
2381
|
}
|
|
2285
2382
|
}, {
|
|
2286
|
-
key:
|
|
2383
|
+
key: 'disconnect',
|
|
2287
2384
|
value: function disconnect() {
|
|
2288
2385
|
if (this.client) {
|
|
2289
2386
|
try {
|
|
2290
|
-
console.log(
|
|
2387
|
+
console.log('ws断开连接' + this.url);
|
|
2291
2388
|
this.client.close();
|
|
2292
2389
|
this.client = null;
|
|
2293
2390
|
} catch (ex) {
|
|
@@ -2296,43 +2393,44 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2296
2393
|
}
|
|
2297
2394
|
}
|
|
2298
2395
|
}, {
|
|
2299
|
-
key:
|
|
2396
|
+
key: 'connCheckStatus',
|
|
2300
2397
|
value: function connCheckStatus(times) {
|
|
2301
|
-
var
|
|
2398
|
+
var _this2 = this;
|
|
2302
2399
|
|
|
2303
2400
|
if (this.checkTimes > times) return;
|
|
2304
2401
|
setTimeout(function () {
|
|
2305
|
-
|
|
2306
|
-
|
|
2402
|
+
_this2.checkTimes++;
|
|
2403
|
+
if (_this2.client && _this2.client.readyState !== 0 && _this2.client.readyState !== 1) {
|
|
2404
|
+
_this2.connect();
|
|
2307
2405
|
}
|
|
2308
|
-
|
|
2406
|
+
_this2.connCheckStatus(times);
|
|
2309
2407
|
}, 2000);
|
|
2310
2408
|
}
|
|
2311
2409
|
}, {
|
|
2312
|
-
key:
|
|
2410
|
+
key: 'send',
|
|
2313
2411
|
value: function send(message) {
|
|
2314
2412
|
if (this.client && this.client.readyState === 1) {
|
|
2315
2413
|
this.client.send(message);
|
|
2316
2414
|
return true;
|
|
2317
2415
|
}
|
|
2318
|
-
console.error(this.url +
|
|
2416
|
+
console.error(this.url + '消息发送失败:' + message);
|
|
2319
2417
|
return false;
|
|
2320
2418
|
}
|
|
2321
2419
|
}, {
|
|
2322
|
-
key:
|
|
2420
|
+
key: 'heartbeat',
|
|
2323
2421
|
value: function heartbeat() {
|
|
2324
|
-
var
|
|
2422
|
+
var _this3 = this;
|
|
2325
2423
|
|
|
2326
2424
|
setTimeout(function () {
|
|
2327
|
-
if (
|
|
2328
|
-
|
|
2425
|
+
if (_this3.client && _this3.client.readyState === 1) {
|
|
2426
|
+
_this3.send('HeartBeat');
|
|
2329
2427
|
}
|
|
2330
|
-
console.log(
|
|
2331
|
-
setTimeout(
|
|
2428
|
+
console.log('HeartBeat,' + _this3.url);
|
|
2429
|
+
setTimeout(_this3.heartbeat, 30000);
|
|
2332
2430
|
}, 1000);
|
|
2333
2431
|
}
|
|
2334
2432
|
}], [{
|
|
2335
|
-
key:
|
|
2433
|
+
key: 'getInstance',
|
|
2336
2434
|
value: function getInstance() {
|
|
2337
2435
|
if (WebSocketClient.instance) {
|
|
2338
2436
|
return WebSocketClient.instance;
|
|
@@ -2341,7 +2439,7 @@ var WebSocketClient_WebSocketClient = function (_EventDispatcher) {
|
|
|
2341
2439
|
}
|
|
2342
2440
|
}
|
|
2343
2441
|
}, {
|
|
2344
|
-
key:
|
|
2442
|
+
key: '_instance',
|
|
2345
2443
|
get: function get() {
|
|
2346
2444
|
return this.getInstance();
|
|
2347
2445
|
}
|
|
@@ -2454,6 +2552,122 @@ var WebStorage_WebStorage = function () {
|
|
|
2454
2552
|
}();
|
|
2455
2553
|
|
|
2456
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);
|
|
2457
2671
|
// CONCATENATED MODULE: ./src/index.js
|
|
2458
2672
|
|
|
2459
2673
|
|
|
@@ -2462,6 +2676,7 @@ var WebStorage_WebStorage = function () {
|
|
|
2462
2676
|
|
|
2463
2677
|
|
|
2464
2678
|
|
|
2679
|
+
// export { default as MqttClient } from './core/MqttClient' // vite不支持?
|
|
2465
2680
|
|
|
2466
2681
|
|
|
2467
2682
|
|