dtable-ui-component 6.0.29-beta13 → 6.0.29-beta15

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.
@@ -205,7 +205,6 @@
205
205
  }
206
206
 
207
207
  .dtable-ui-geolocation-map-editor .search-tables-input {
208
- line-height: 38px;
209
208
  padding-right: 30px;
210
209
  border-bottom: 0;
211
210
  background: #fff;
@@ -334,23 +334,27 @@ class MapEditor extends _react.Component {
334
334
  componentDidMount() {
335
335
  if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
336
336
  if (!window.BMap) {
337
- window.renderBaiduMap = () => this.renderBaiduMap();
338
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
337
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey).then(() => {
338
+ this.renderBaiduMap();
339
+ });
339
340
  } else {
340
341
  this.renderBaiduMap();
341
342
  }
342
343
  return;
343
344
  } else if (this.mapType === _mapEditorUtils.MAP_TYPES.G_MAP) {
344
345
  if (!window.google) {
345
- window.renderGoogleMap = () => this.renderGoogleMap();
346
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey);
346
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey).then(() => {
347
+ this.renderGoogleMap();
348
+ });
347
349
  } else {
348
350
  this.renderGoogleMap();
349
351
  }
350
352
  return;
351
353
  } else if (this.mapType === _mapEditorUtils.MAP_TYPES.M_MAP) {
352
354
  if (!window.minemap) {
353
- (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey, this.loadMineMapCallBack);
355
+ (0, _mapEditorUtils.loadMapSource)(this.mapType, this.mapKey).then(() => {
356
+ this.loadMineMapCallBack();
357
+ });
354
358
  } else {
355
359
  this.renderMineMap();
356
360
  }
@@ -51,7 +51,6 @@
51
51
  }
52
52
 
53
53
  .dtable-ui-large-map-editor-dialog .dtable-ui-geolocation-map-editor-large .search-tables-input {
54
- line-height: 38px;
55
54
  padding-right: 30px;
56
55
  border-bottom: 0;
57
56
  background: #fff;
@@ -95,26 +95,53 @@ const getMapInfo = function () {
95
95
  };
96
96
  };
97
97
  exports.getMapInfo = getMapInfo;
98
- const loadMapSource = (mapType, mapKey, callback) => {
99
- if (!mapType || !mapKey) return;
100
- let scriptUrl = '';
101
- let script = document.createElement('script');
102
- script.type = 'text/javascript';
103
- if (mapType === MAP_TYPES.B_MAP) {
104
- scriptUrl = "https://api.map.baidu.com/api?v=3.0&ak=".concat(mapKey, "}&callback=renderBaiduMap");
105
- } else if (mapType === MAP_TYPES.G_MAP) {
106
- scriptUrl = "https://maps.googleapis.com/maps/api/js?key=".concat(mapKey, "&callback=renderGoogleMap&libraries=&v=weekly");
107
- } else {
108
- scriptUrl = 'https://minemap.minedata.cn/minemapapi/v2.1.1/minemap.js';
109
- let link = document.createElement('link');
110
- link.rel = 'stylesheet';
111
- link.type = 'text/css';
112
- link.href = 'https://minemap.minedata.cn/minemapapi/v2.1.1/minemap.css';
113
- document.head.appendChild(link);
114
- }
115
- script.src = scriptUrl;
116
- document.body.appendChild(script);
117
- if (callback) callback();
98
+ const isImplementedOnload = script => {
99
+ script = script || document.createElement('script');
100
+ if ('onload' in script) return true;
101
+ script.setAttribute('onload', '');
102
+ return typeof script['onload'] === 'function'; // ff true ie false .
103
+ };
104
+ const loadMapSource = (mapType, mapKey) => {
105
+ return new Promise((resolve, reject) => {
106
+ if (!mapType || !mapKey) {
107
+ reject();
108
+ return;
109
+ }
110
+ let scriptUrl = '';
111
+ let script = document.createElement('script');
112
+ script.type = 'text/javascript';
113
+ if (mapType === MAP_TYPES.B_MAP) {
114
+ scriptUrl = "https://api.map.baidu.com/api?v=3.0&ak=".concat(mapKey);
115
+ } else if (mapType === MAP_TYPES.G_MAP) {
116
+ scriptUrl = "https://maps.googleapis.com/maps/api/js?key=".concat(mapKey, "&libraries=&v=weekly");
117
+ } else {
118
+ scriptUrl = 'https://minemap.minedata.cn/minemapapi/v2.1.1/minemap.js';
119
+ let link = document.createElement('link');
120
+ link.rel = 'stylesheet';
121
+ link.type = 'text/css';
122
+ link.href = 'https://minemap.minedata.cn/minemapapi/v2.1.1/minemap.css';
123
+ document.head.appendChild(link);
124
+ }
125
+ script.src = scriptUrl;
126
+ script.onerror = err => {
127
+ reject(err);
128
+ };
129
+ if (isImplementedOnload(script)) {
130
+ // Firefox, Safari, Chrome, and Opera
131
+ script.onload = res => {
132
+ resolve(res);
133
+ };
134
+ } else {
135
+ // IE
136
+ script.onreadystatechange = () => {
137
+ if (script.readyState === 'loaded' || script.readyState === 'complete') {
138
+ script.onreadystatechange = null;
139
+ resolve();
140
+ }
141
+ };
142
+ }
143
+ document.body.appendChild(script);
144
+ });
118
145
  };
119
146
  exports.loadMapSource = loadMapSource;
120
147
  const locateCurrentPosition = (map, mapType, callback) => {
@@ -349,7 +349,7 @@ class MapSelectionEditor extends _react.Component {
349
349
  }
350
350
  }
351
351
  componentWillUnmount() {
352
- if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
352
+ if (this.map && this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
353
353
  let center = {};
354
354
  center.zoom = this.map.getZoom();
355
355
  let coordinate = this.map.getCenter();
@@ -355,7 +355,7 @@ class LargeMapSelectionEditorDialog extends _react.default.Component {
355
355
  }
356
356
  }
357
357
  componentWillUnmount() {
358
- if (this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
358
+ if (this.map && this.mapType === _mapEditorUtils.MAP_TYPES.B_MAP) {
359
359
  let center = {};
360
360
  center.zoom = this.map.getZoom();
361
361
  let coordinate = this.map.getCenter();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.29-beta13",
3
+ "version": "6.0.29-beta15",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",