gis-common 1.1.17 → 1.1.19

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.
@@ -459,24 +459,37 @@ var MeasureMode = {
459
459
  * 异步加载script
460
460
  *
461
461
  * @param {*} url
462
- * @param {function} callback
463
462
  */
464
- loadScript: function loadScript(url, callback) {
465
- var oscript = document.createElement('script');
466
- if (oscript.readyState) {
467
- // ie8及以下版本
468
- oscript.onreadystatechange = function () {
469
- if (oscript.readyState === 'complete' || oscript.readyState === 'loaded') {
470
- callback();
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
+ };
471
478
  }
472
- };
473
- } else {
474
- oscript.onload = function () {
475
- callback();
476
- };
477
- }
478
- oscript.src = url;
479
- document.body.appendChild(oscript);
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() {
488
+ var css = document.createElement('link');
489
+ css.href = url;
490
+ css.rel = 'stylesheet';
491
+ css.type = 'text/css';
492
+ document.head.appendChild(css);
480
493
  },
481
494
 
482
495
  /**
@@ -1775,14 +1788,14 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
1775
1788
  * @param {*} n
1776
1789
  * @returns {*}
1777
1790
  */
1778
- subStringByte: function subStringByte(str, n) {
1791
+ subStringByte: function subStringByte(str, start, n) {
1779
1792
  var r = /[^\x00-\xff]/g;
1780
1793
  if (str.replace(r, 'mm').length <= n) {
1781
1794
  return str;
1782
1795
  }
1783
1796
  var m = Math.floor(n / 2);
1784
1797
  for (var i = m; i < str.length; i++) {
1785
- var sub = str.substring(0, i);
1798
+ var sub = str.substring(start, i);
1786
1799
  if (sub.replace(r, 'mm').length >= n) {
1787
1800
  return sub;
1788
1801
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "gis-common",
3
3
  "description": "gis-common",
4
4
  "main": "dist/resource.min.js",
5
- "version": "1.1.17",
5
+ "version": "1.1.19",
6
6
  "author": "Guo.Yan <luv02@vip.qq.com>",
7
7
  "license": "MIT",
8
8
  "private": false,