@vtx/map 1.1.7 → 1.1.10

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.
Files changed (63) hide show
  1. package/lib/VtxMap/AMap/AMap.js +3287 -2990
  2. package/lib/VtxMap/AMap/AMap.js.map +1 -0
  3. package/lib/VtxMap/BMap/Map.js +3517 -3146
  4. package/lib/VtxMap/BMap/Map.js.map +1 -0
  5. package/lib/VtxMap/GMap/Map.js +4572 -4021
  6. package/lib/VtxMap/GMap/Map.js.map +1 -0
  7. package/lib/VtxMap/Map.js +77 -63
  8. package/lib/VtxMap/Map.js.map +1 -0
  9. package/lib/VtxMap/MapToolFunction.js +422 -370
  10. package/lib/VtxMap/MapToolFunction.js.map +1 -0
  11. package/lib/VtxMap/OMap/Map.css +2 -2
  12. package/lib/VtxMap/OMap/Map.js +4345 -3782
  13. package/lib/VtxMap/OMap/Map.js.map +1 -0
  14. package/lib/VtxMap/OlMap/Map.css +4 -1
  15. package/lib/VtxMap/OlMap/Map.js +3938 -3489
  16. package/lib/VtxMap/OlMap/Map.js.map +1 -0
  17. package/lib/VtxMap/TMap/TMap.css +0 -1
  18. package/lib/VtxMap/TMap/TMap.js +3475 -3139
  19. package/lib/VtxMap/TMap/TMap.js.map +1 -0
  20. package/lib/VtxMap/index.js +37 -24
  21. package/lib/VtxMap/index.js.map +1 -0
  22. package/lib/VtxMap/mapPlayer.js +353 -308
  23. package/lib/VtxMap/mapPlayer.js.map +1 -0
  24. package/lib/VtxMap/optimizingPointMap.js +245 -205
  25. package/lib/VtxMap/optimizingPointMap.js.map +1 -0
  26. package/lib/VtxMap/style/css.js +16 -0
  27. package/lib/VtxMap/style/css.js.map +1 -0
  28. package/lib/VtxMap/style/index.js +16 -0
  29. package/lib/VtxMap/style/index.js.map +1 -0
  30. package/lib/VtxMap/zoomMap.js +120 -101
  31. package/lib/VtxMap/zoomMap.js.map +1 -0
  32. package/lib/VtxModal/VtxModal.css +62 -0
  33. package/lib/VtxModal/VtxModal.js +223 -213
  34. package/lib/VtxModal/VtxModal.js.map +1 -0
  35. package/lib/VtxModal/VtxModal.less +2 -2
  36. package/lib/VtxModal/VtxModalAntd3.css +62 -0
  37. package/lib/VtxModal/VtxModalAntd3.less +67 -0
  38. package/lib/VtxModal/draggableModal.js +138 -119
  39. package/lib/VtxModal/draggableModal.js.map +1 -0
  40. package/lib/VtxModal/index.js +21 -14
  41. package/lib/VtxModal/index.js.map +1 -0
  42. package/lib/VtxModal/style/css.js +21 -0
  43. package/lib/VtxModal/style/css.js.map +1 -0
  44. package/lib/VtxModal/style/index.js +21 -0
  45. package/lib/VtxModal/style/index.js.map +1 -0
  46. package/lib/VtxSearchMap/VtxSearchMap.css +171 -0
  47. package/lib/VtxSearchMap/VtxSearchMap.js +864 -819
  48. package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -0
  49. package/lib/VtxSearchMap/VtxSearchMapAntd3.css +0 -0
  50. package/lib/VtxSearchMap/VtxSearchMapAntd3.less +1 -0
  51. package/lib/VtxSearchMap/index.js +9 -9
  52. package/lib/VtxSearchMap/index.js.map +1 -0
  53. package/lib/VtxSearchMap/mapping.js +15 -12
  54. package/lib/VtxSearchMap/mapping.js.map +1 -0
  55. package/lib/VtxSearchMap/style/css.js +47 -0
  56. package/lib/VtxSearchMap/style/css.js.map +1 -0
  57. package/lib/VtxSearchMap/style/index.js +47 -0
  58. package/lib/VtxSearchMap/style/index.js.map +1 -0
  59. package/lib/default.js +32 -27
  60. package/lib/default.js.map +1 -0
  61. package/lib/index.js +9 -10
  62. package/lib/index.js.map +1 -0
  63. package/package.json +25 -4
@@ -1,17 +1,34 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true
4
+ value: true
5
5
  });
6
+ exports["default"] = void 0;
6
7
 
7
- var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
8
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
9
 
9
- var _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; }; }();
10
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
11
 
11
- function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
12
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
13
+
14
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
15
+
16
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
17
+
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
25
 
13
26
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
14
27
 
28
+ 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); } }
29
+
30
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
31
+
15
32
  /*
16
33
  地图实例:@map
17
34
  需要播放的点位数组:@path --- [{longitude,latitude,name,id}]
@@ -29,320 +46,348 @@ pause
29
46
  stop
30
47
  destroy
31
48
  */
32
- var MapPlayer = function () {
33
- function MapPlayer(_ref) {
34
- var _this = this;
35
-
36
- var map = _ref.map,
37
- path = _ref.path,
38
- speed = _ref.speed,
39
- playRate = _ref.playRate,
40
- pointSetting = _ref.pointSetting,
41
- lineSetting = _ref.lineSetting,
42
- enableRotation = _ref.enableRotation,
43
- mapMove = _ref.mapMove,
44
- onChange = _ref.onChange;
45
-
46
- _classCallCheck(this, MapPlayer);
47
-
48
- this.map = map; //地图实例
49
- this.path = path || []; //点位数组
50
- this.speed = speed || 12; //点位移动速度,m/s
51
- this.playFrame = 24; //播放帧率
52
- this.playRate = playRate || 1; //播放速率
53
- this.enableRotation = enableRotation || false; //是否开启图标自动旋转
54
- this.mapMove = mapMove || false; //地图是否跟随播放点位移动
55
- this.pointSetting = pointSetting || {
56
- config: {
57
- width: 30,
58
- height: 30,
59
- markerContentX: -15,
60
- markerContentY: -15
61
- }
62
- };
63
- this.lineSetting = lineSetting || { lineWidth: 3, color: 'blue' }; //线的样式配置
64
- this.onChange = onChange;
65
-
66
- var uniqueID = new Date().valueOf() + '_' + parseInt(Math.random() * 100000000);
67
- this._pointId = 'point_' + uniqueID;
68
- this._lineId = 'line_' + uniqueID;
69
- this._currentIndex = 0; //当前播放的点位序号
70
- this._supplementPoints = []; //补点列表
71
- this._currentSupplementIndex = 0; //当前补点序号
72
- this._timer = null; //播放定时器
73
- this.map.loadMapComplete.then(function () {
74
- _this._redraw();
75
- });
76
- }
77
- // 根据当前数据重新渲染点和线的图形
78
-
79
-
80
- _createClass(MapPlayer, [{
81
- key: '_redraw',
82
- value: function _redraw() {
83
- if (this.path.length == 0) {
84
- this.map.GM.isRepetition(this._pointId) && this.map.removeGraphic(this._pointId);
85
- this.map.GM.isRepetition(this._lineId) && this.map.removeGraphic(this._lineId);
86
- return;
87
- }
88
- if (this._currentIndex < this.path.length) {
89
- // 画点
90
- var currentPoint = void 0;
91
- if (this._currentIndex == this.path.length - 1 || this._supplementPoints.length == 0) {
92
- currentPoint = this.path[this._currentIndex];
93
- } else {
94
- currentPoint = this._supplementPoints[this._currentSupplementIndex];
95
- }
96
- var pointObj = _extends({}, currentPoint, {
97
- id: this._pointId,
98
- latitude: currentPoint.latitude,
99
- longitude: currentPoint.longitude
100
- }, this.pointSetting, {
101
- config: _extends({}, this.pointSetting.config || {}, {
102
- labelContent: currentPoint.name || ''
103
- })
104
- });
105
- if (this.enableRotation) {
106
- var deg = this._currentIndex + 1 < this.path.length ? this._getIconAngle({
107
- x: this.path[this._currentIndex].longitude,
108
- y: this.path[this._currentIndex].latitude
109
- }, {
110
- x: this.path[this._currentIndex + 1].longitude,
111
- y: this.path[this._currentIndex + 1].latitude
112
- }) : 0;
113
- pointObj.config.deg = deg;
114
- }
115
-
116
- if (this.map.GM.isRepetition(this._pointId)) {
117
- this.map.updatePoint([pointObj]);
118
- this.mapMove && this.map.setCenter([pointObj.longitude, pointObj.latitude]);
119
- } else {
120
- this.map.addPoint([pointObj], 'defined');
121
- }
122
- // 画线
123
- var paths = [];
124
- for (var i = 0; i <= this._currentIndex; i++) {
125
- paths.push([this.path[i].longitude, this.path[i].latitude]);
126
- }
127
-
128
- if (this._supplementPoints.length > 0) {
129
- for (var _i = 0; _i <= this._currentSupplementIndex; _i++) {
130
- paths.push([this._supplementPoints[_i].longitude, this._supplementPoints[_i].latitude]);
131
- }
132
- }
133
- if (paths.length > 1) {
134
- var lineObj = {
135
- id: this._lineId,
136
- paths: paths,
137
- config: this.lineSetting
138
- };
139
- if (this.map.GM.isRepetition(this._lineId)) {
140
- this.map.updateLine([lineObj]);
141
- } else {
142
- this.map.addLine([lineObj], 'defined');
143
- }
144
- } else {
145
- if (this.map.GM.isRepetition(this._lineId)) {
146
- this.map.removeGraphic(this._lineId);
147
- }
148
- }
149
- }
150
- }
151
- }, {
152
- key: '_clearTimer',
153
- value: function _clearTimer() {
154
- if (this._timer) {
155
- clearTimeout(this._timer);
156
- this._timer = null;
157
- }
158
- }
159
- // 计算图标转动角度(仅适用于当前车辆图标,仅适用于中国区域)
160
-
161
- }, {
162
- key: '_getIconAngle',
163
- value: function _getIconAngle(start, end) {
164
- var diff_x = end.x - start.x,
165
- diff_y = end.y - start.y;
166
- // 1,4象限夹脚计算
167
- var ag = 360 * Math.atan(diff_y / diff_x) / (2 * Math.PI);
168
- // 地图夹角偏转计算
169
- if (diff_x == 0) {
170
- if (diff_y > 0) {
171
- return -90;
172
- } else if (diff_y < 0) {
173
- return 90;
174
- } else {
175
- return 0;
176
- }
177
- }
178
- // 坐标系1,4象限
179
- else if (diff_x > 0) {
180
- return -ag;
181
- }
182
- // 坐标系2,3象限
183
- else {
184
- return 180 - ag;
185
- }
186
- }
187
- // 根据两点生成补点列表
188
-
189
- }, {
190
- key: '_generateSupplyPoints',
191
- value: function _generateSupplyPoints(p1, p2) {
192
- var currentLng = p1.longitude,
193
- currentLat = p1.latitude;
194
- var nextLng = p2.longitude,
195
- nextLat = p2.latitude;
196
-
197
- var runTime = this.map.calculateDistance([[currentLng, currentLat], [nextLng, nextLat]]) / (this.speed * this.playRate);
198
- //不需要补点
199
- if (runTime <= 1 / this.playFrame) {
200
- return [];
201
- }
202
- // 需要补点
203
- else {
204
- var supplementNum = Math.ceil(runTime / (1 / this.playFrame)) - 1;
205
- var lng_spacing = (nextLng - currentLng) / (supplementNum + 1);
206
- var lat_spacing = (nextLat - currentLat) / (supplementNum + 1);
207
- var supplementPoints = [];
208
- for (var i = 1; i <= supplementNum; i++) {
209
- supplementPoints.push(_extends({}, this.path[this._currentIndex], {
210
- longitude: currentLng + lng_spacing * i,
211
- latitude: currentLat + lat_spacing * i
212
- }));
213
- }
214
- return supplementPoints;
215
- }
49
+ var MapPlayer = /*#__PURE__*/function () {
50
+ function MapPlayer(_ref) {
51
+ var _this = this;
52
+
53
+ var map = _ref.map,
54
+ path = _ref.path,
55
+ speed = _ref.speed,
56
+ playRate = _ref.playRate,
57
+ pointSetting = _ref.pointSetting,
58
+ lineSetting = _ref.lineSetting,
59
+ enableRotation = _ref.enableRotation,
60
+ mapMove = _ref.mapMove,
61
+ onChange = _ref.onChange;
62
+
63
+ _classCallCheck(this, MapPlayer);
64
+
65
+ this.map = map; //地图实例
66
+
67
+ this.path = path || []; //点位数组
68
+
69
+ this.speed = speed || 12; //点位移动速度,m/s
70
+
71
+ this.playFrame = 24; //播放帧率
72
+
73
+ this.playRate = playRate || 1; //播放速率
74
+
75
+ this.enableRotation = enableRotation || false; //是否开启图标自动旋转
76
+
77
+ this.mapMove = mapMove || false; //地图是否跟随播放点位移动
78
+
79
+ this.pointSetting = pointSetting || {
80
+ config: {
81
+ width: 30,
82
+ height: 30,
83
+ markerContentX: -15,
84
+ markerContentY: -15
85
+ }
86
+ };
87
+ this.lineSetting = lineSetting || {
88
+ lineWidth: 3,
89
+ color: 'blue'
90
+ }; //线的样式配置
91
+
92
+ this.onChange = onChange;
93
+ var uniqueID = "".concat(new Date().valueOf(), "_").concat(parseInt(Math.random() * 100000000));
94
+ this._pointId = "point_".concat(uniqueID);
95
+ this._lineId = "line_".concat(uniqueID);
96
+ this._currentIndex = 0; //当前播放的点位序号
97
+
98
+ this._supplementPoints = []; //补点列表
99
+
100
+ this._currentSupplementIndex = 0; //当前补点序号
101
+
102
+ this._timer = null; //播放定时器
103
+
104
+ this.map.loadMapComplete.then(function () {
105
+ _this._redraw();
106
+ });
107
+ } // 根据当前数据重新渲染点和线的图形
108
+
109
+
110
+ _createClass(MapPlayer, [{
111
+ key: "_redraw",
112
+ value: function _redraw() {
113
+ if (this.path.length == 0) {
114
+ this.map.GM.isRepetition(this._pointId) && this.map.removeGraphic(this._pointId);
115
+ this.map.GM.isRepetition(this._lineId) && this.map.removeGraphic(this._lineId);
116
+ return;
117
+ }
118
+
119
+ if (this._currentIndex < this.path.length) {
120
+ // 画点
121
+ var currentPoint;
122
+
123
+ if (this._currentIndex == this.path.length - 1 || this._supplementPoints.length == 0) {
124
+ currentPoint = this.path[this._currentIndex];
125
+ } else {
126
+ currentPoint = this._supplementPoints[this._currentSupplementIndex];
216
127
  }
217
- // 开始播放
218
-
219
- }, {
220
- key: 'play',
221
- value: function play() {
222
- var _this2 = this;
223
-
224
- this._clearTimer();
225
- if (this.path.length == 0 || this._currentIndex == this.path.length - 1) {
226
- return;
227
- };
228
- // 当前处于补点播放
229
- if (this._supplementPoints.length > 0) {
230
- this._timer = setTimeout(function () {
231
- if (_this2._currentSupplementIndex < _this2._supplementPoints.length - 1) {
232
- _this2._currentSupplementIndex = _this2._currentSupplementIndex + 1;
233
- } else {
234
- _this2._currentSupplementIndex = 0;
235
- _this2._supplementPoints = [];
236
- _this2._currentIndex = _this2._currentIndex + 1;
237
- typeof _this2.onChange == 'function' && _this2.onChange(_this2.path[_this2._currentIndex], _this2._currentIndex);
238
- }
239
- _this2._redraw();
240
- _this2.play();
241
- }, 1000 / this.playFrame);
242
- }
243
- // 当前处于非补点播放
244
- else {
245
- var spPoints = this._generateSupplyPoints(this.path[this._currentIndex], this.path[this._currentIndex + 1]);
246
- //不需要补点
247
- if (spPoints.length == 0) {
248
- this._timer = setTimeout(function () {
249
- _this2._currentIndex = _this2._currentIndex + 1;
250
- typeof _this2.onChange == 'function' && _this2.onChange(_this2.path[_this2._currentIndex], _this2._currentIndex);
251
- _this2._redraw();
252
- _this2.play();
253
- }, 1000 / this.playFrame);
254
- }
255
- // 需要补点
256
- else {
257
- this._timer = setTimeout(function () {
258
- _this2._currentSupplementIndex = 0;
259
- _this2._supplementPoints = spPoints;
260
- _this2._redraw();
261
- _this2.play();
262
- }, 1000 / this.playFrame);
263
- }
264
- }
128
+
129
+ var pointObj = _objectSpread(_objectSpread(_objectSpread({}, currentPoint), {}, {
130
+ id: this._pointId,
131
+ latitude: currentPoint.latitude,
132
+ longitude: currentPoint.longitude
133
+ }, this.pointSetting), {}, {
134
+ config: _objectSpread(_objectSpread({}, this.pointSetting.config || {}), {}, {
135
+ labelContent: currentPoint.name || ''
136
+ })
137
+ });
138
+
139
+ if (this.enableRotation) {
140
+ var deg = this._currentIndex + 1 < this.path.length ? this._getIconAngle({
141
+ x: this.path[this._currentIndex].longitude,
142
+ y: this.path[this._currentIndex].latitude
143
+ }, {
144
+ x: this.path[this._currentIndex + 1].longitude,
145
+ y: this.path[this._currentIndex + 1].latitude
146
+ }) : 0;
147
+ pointObj.config.deg = deg;
265
148
  }
266
- // 暂停播放
267
149
 
268
- }, {
269
- key: 'pause',
270
- value: function pause(onPlayPause) {
271
- this._clearTimer();
272
- typeof onPlayPause == "function" && onPlayPause(this.path[this._currentIndex], this._currentIndex);
150
+ if (this.map.GM.isRepetition(this._pointId)) {
151
+ this.map.updatePoint([pointObj]);
152
+ this.mapMove && this.map.setCenter([pointObj.longitude, pointObj.latitude]);
153
+ } else {
154
+ this.map.addPoint([pointObj], 'defined');
155
+ } // 画线
156
+
157
+
158
+ var paths = [];
159
+
160
+ for (var i = 0; i <= this._currentIndex; i++) {
161
+ paths.push([this.path[i].longitude, this.path[i].latitude]);
273
162
  }
274
- // 停止播放(回到初始点位)
275
-
276
- }, {
277
- key: 'stop',
278
- value: function stop() {
279
- this._clearTimer();
280
- this._currentIndex = 0;
281
- this._supplementPoints = [];
282
- this._currentSupplementIndex = 0;
283
- this._redraw();
284
- // typeof this.onChange == "function" && this.onChange(this.path[0],0);
163
+
164
+ if (this._supplementPoints.length > 0) {
165
+ for (var _i = 0; _i <= this._currentSupplementIndex; _i++) {
166
+ paths.push([this._supplementPoints[_i].longitude, this._supplementPoints[_i].latitude]);
167
+ }
285
168
  }
286
- // 销毁(删除所有添加的图层)
287
169
 
288
- }, {
289
- key: 'destroy',
290
- value: function destroy() {
291
- this._clearTimer();
292
- this.map.removeGraphic(this._pointId);
170
+ if (paths.length > 1) {
171
+ var lineObj = {
172
+ id: this._lineId,
173
+ paths: paths,
174
+ config: this.lineSetting
175
+ };
176
+
177
+ if (this.map.GM.isRepetition(this._lineId)) {
178
+ this.map.updateLine([lineObj]);
179
+ } else {
180
+ this.map.addLine([lineObj], 'defined');
181
+ }
182
+ } else {
183
+ if (this.map.GM.isRepetition(this._lineId)) {
293
184
  this.map.removeGraphic(this._lineId);
294
- this._currentIndex = 0;
295
- this._supplementPoints = [];
296
- this._currentSupplementIndex = 0;
185
+ }
297
186
  }
298
- // 设置速度
299
-
300
- }, {
301
- key: 'setPlayRate',
302
- value: function setPlayRate(newPlayRate) {
303
- this.playRate = newPlayRate;
304
- //如果当前处于补点状态,重新生成新的补点
305
- if (this._supplementPoints.length > 0) {
306
- var newSpPoints = this._generateSupplyPoints(this._supplementPoints[this._currentSupplementIndex], this.path[this._currentIndex + 1]);
307
- this._supplementPoints = [].concat(_toConsumableArray(this._supplementPoints.slice(0, this._currentSupplementIndex + 1)), _toConsumableArray(newSpPoints));
308
- }
187
+ }
188
+ }
189
+ }, {
190
+ key: "_clearTimer",
191
+ value: function _clearTimer() {
192
+ if (this._timer) {
193
+ clearTimeout(this._timer);
194
+ this._timer = null;
195
+ }
196
+ } // 计算图标转动角度(仅适用于当前车辆图标,仅适用于中国区域)
197
+
198
+ }, {
199
+ key: "_getIconAngle",
200
+ value: function _getIconAngle(start, end) {
201
+ var diff_x = end.x - start.x,
202
+ diff_y = end.y - start.y; // 1,4象限夹脚计算
203
+
204
+ var ag = 360 * Math.atan(diff_y / diff_x) / (2 * Math.PI); // 地图夹角偏转计算
205
+
206
+ if (diff_x == 0) {
207
+ if (diff_y > 0) {
208
+ return -90;
209
+ } else if (diff_y < 0) {
210
+ return 90;
211
+ } else {
212
+ return 0;
309
213
  }
310
- // 设置当前播放点位的位置
311
-
312
- }, {
313
- key: 'setCurrentIndex',
314
- value: function setCurrentIndex(pIndex) {
315
- if (pIndex >= this.path.length) return;
316
-
317
- this._currentIndex = pIndex;
318
- this._supplementPoints = [];
319
- this._currentSupplementIndex = 0;
320
- // typeof this.onChange == "function" && this.onChange(this.path[pIndex],pIndex);
321
- this._redraw();
322
- if (this._timer) {
323
- this._clearTimer();
324
- this.play();
325
- }
214
+ } // 坐标系1,4象限
215
+ else if (diff_x > 0) {
216
+ return -ag;
217
+ } // 坐标系2,3象限
218
+ else {
219
+ return 180 - ag;
220
+ }
221
+ } // 根据两点生成补点列表
222
+
223
+ }, {
224
+ key: "_generateSupplyPoints",
225
+ value: function _generateSupplyPoints(p1, p2) {
226
+ var currentLng = p1.longitude,
227
+ currentLat = p1.latitude;
228
+ var nextLng = p2.longitude,
229
+ nextLat = p2.latitude;
230
+ var runTime = this.map.calculateDistance([[currentLng, currentLat], [nextLng, nextLat]]) / (this.speed * this.playRate); //不需要补点
231
+
232
+ if (runTime <= 1 / this.playFrame) {
233
+ return [];
234
+ } // 需要补点
235
+ else {
236
+ var supplementNum = Math.ceil(runTime / (1 / this.playFrame)) - 1;
237
+ var lng_spacing = (nextLng - currentLng) / (supplementNum + 1);
238
+ var lat_spacing = (nextLat - currentLat) / (supplementNum + 1);
239
+ var supplementPoints = [];
240
+
241
+ for (var i = 1; i <= supplementNum; i++) {
242
+ supplementPoints.push(_objectSpread(_objectSpread({}, this.path[this._currentIndex]), {}, {
243
+ longitude: currentLng + lng_spacing * i,
244
+ latitude: currentLat + lat_spacing * i
245
+ }));
326
246
  }
327
- // 重新设置播放路线
328
-
329
- }, {
330
- key: 'setPath',
331
- value: function setPath(newPath) {
332
- this.path = newPath;
333
- this._currentIndex = 0;
334
- this._supplementPoints = [];
335
- this._currentSupplementIndex = 0;
336
- this._redraw();
337
- if (this._timer) {
338
- this._clearTimer();
339
- this.play();
340
- }
247
+
248
+ return supplementPoints;
249
+ }
250
+ } // 开始播放
251
+
252
+ }, {
253
+ key: "play",
254
+ value: function play() {
255
+ var _this2 = this;
256
+
257
+ this._clearTimer();
258
+
259
+ if (this.path.length == 0 || this._currentIndex == this.path.length - 1) {
260
+ return;
261
+ }
262
+
263
+ ; // 当前处于补点播放
264
+
265
+ if (this._supplementPoints.length > 0) {
266
+ this._timer = setTimeout(function () {
267
+ if (_this2._currentSupplementIndex < _this2._supplementPoints.length - 1) {
268
+ _this2._currentSupplementIndex = _this2._currentSupplementIndex + 1;
269
+ } else {
270
+ _this2._currentSupplementIndex = 0;
271
+ _this2._supplementPoints = [];
272
+ _this2._currentIndex = _this2._currentIndex + 1;
273
+ typeof _this2.onChange == 'function' && _this2.onChange(_this2.path[_this2._currentIndex], _this2._currentIndex);
274
+ }
275
+
276
+ _this2._redraw();
277
+
278
+ _this2.play();
279
+ }, 1000 / this.playFrame);
280
+ } // 当前处于非补点播放
281
+ else {
282
+ var spPoints = this._generateSupplyPoints(this.path[this._currentIndex], this.path[this._currentIndex + 1]); //不需要补点
283
+
284
+
285
+ if (spPoints.length == 0) {
286
+ this._timer = setTimeout(function () {
287
+ _this2._currentIndex = _this2._currentIndex + 1;
288
+ typeof _this2.onChange == 'function' && _this2.onChange(_this2.path[_this2._currentIndex], _this2._currentIndex);
289
+
290
+ _this2._redraw();
291
+
292
+ _this2.play();
293
+ }, 1000 / this.playFrame);
294
+ } // 需要补点
295
+ else {
296
+ this._timer = setTimeout(function () {
297
+ _this2._currentSupplementIndex = 0;
298
+ _this2._supplementPoints = spPoints;
299
+
300
+ _this2._redraw();
301
+
302
+ _this2.play();
303
+ }, 1000 / this.playFrame);
341
304
  }
342
- }]);
305
+ }
306
+ } // 暂停播放
307
+
308
+ }, {
309
+ key: "pause",
310
+ value: function pause(onPlayPause) {
311
+ this._clearTimer();
312
+
313
+ typeof onPlayPause == "function" && onPlayPause(this.path[this._currentIndex], this._currentIndex);
314
+ } // 停止播放(回到初始点位)
315
+
316
+ }, {
317
+ key: "stop",
318
+ value: function stop() {
319
+ this._clearTimer();
320
+
321
+ this._currentIndex = 0;
322
+ this._supplementPoints = [];
323
+ this._currentSupplementIndex = 0;
324
+
325
+ this._redraw(); // typeof this.onChange == "function" && this.onChange(this.path[0],0);
326
+
327
+ } // 销毁(删除所有添加的图层)
328
+
329
+ }, {
330
+ key: "destroy",
331
+ value: function destroy() {
332
+ this._clearTimer();
333
+
334
+ this.map.removeGraphic(this._pointId);
335
+ this.map.removeGraphic(this._lineId);
336
+ this._currentIndex = 0;
337
+ this._supplementPoints = [];
338
+ this._currentSupplementIndex = 0;
339
+ } // 设置速度
340
+
341
+ }, {
342
+ key: "setPlayRate",
343
+ value: function setPlayRate(newPlayRate) {
344
+ this.playRate = newPlayRate; //如果当前处于补点状态,重新生成新的补点
345
+
346
+ if (this._supplementPoints.length > 0) {
347
+ var newSpPoints = this._generateSupplyPoints(this._supplementPoints[this._currentSupplementIndex], this.path[this._currentIndex + 1]);
348
+
349
+ this._supplementPoints = [].concat(_toConsumableArray(this._supplementPoints.slice(0, this._currentSupplementIndex + 1)), _toConsumableArray(newSpPoints));
350
+ }
351
+ } // 设置当前播放点位的位置
352
+
353
+ }, {
354
+ key: "setCurrentIndex",
355
+ value: function setCurrentIndex(pIndex) {
356
+ if (pIndex >= this.path.length) return;
357
+ this._currentIndex = pIndex;
358
+ this._supplementPoints = [];
359
+ this._currentSupplementIndex = 0; // typeof this.onChange == "function" && this.onChange(this.path[pIndex],pIndex);
360
+
361
+ this._redraw();
362
+
363
+ if (this._timer) {
364
+ this._clearTimer();
365
+
366
+ this.play();
367
+ }
368
+ } // 重新设置播放路线
369
+
370
+ }, {
371
+ key: "setPath",
372
+ value: function setPath(newPath) {
373
+ this.path = newPath;
374
+ this._currentIndex = 0;
375
+ this._supplementPoints = [];
376
+ this._currentSupplementIndex = 0;
377
+
378
+ this._redraw();
379
+
380
+ if (this._timer) {
381
+ this._clearTimer();
382
+
383
+ this.play();
384
+ }
385
+ }
386
+ }]);
343
387
 
344
- return MapPlayer;
388
+ return MapPlayer;
345
389
  }();
346
390
 
347
- exports.default = MapPlayer;
348
- module.exports = exports['default'];
391
+ exports["default"] = MapPlayer;
392
+ module.exports = exports["default"];
393
+ //# sourceMappingURL=mapPlayer.js.map