@vtx/map 1.1.6 → 1.1.9
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/lib/VtxMap/AMap/AMap.js +3287 -2990
- package/lib/VtxMap/AMap/AMap.js.map +1 -0
- package/lib/VtxMap/BMap/Map.js +3517 -3146
- package/lib/VtxMap/BMap/Map.js.map +1 -0
- package/lib/VtxMap/GMap/Map.js +4572 -4021
- package/lib/VtxMap/GMap/Map.js.map +1 -0
- package/lib/VtxMap/Map.js +77 -63
- package/lib/VtxMap/Map.js.map +1 -0
- package/lib/VtxMap/MapToolFunction.js +422 -370
- package/lib/VtxMap/MapToolFunction.js.map +1 -0
- package/lib/VtxMap/OMap/Map.css +2 -2
- package/lib/VtxMap/OMap/Map.js +4345 -3782
- package/lib/VtxMap/OMap/Map.js.map +1 -0
- package/lib/VtxMap/OlMap/Map.css +4 -1
- package/lib/VtxMap/OlMap/Map.js +3921 -3181
- package/lib/VtxMap/OlMap/Map.js.map +1 -0
- package/lib/VtxMap/TMap/TMap.css +0 -1
- package/lib/VtxMap/TMap/TMap.js +3475 -3139
- package/lib/VtxMap/TMap/TMap.js.map +1 -0
- package/lib/VtxMap/index.js +37 -24
- package/lib/VtxMap/index.js.map +1 -0
- package/lib/VtxMap/mapPlayer.js +353 -308
- package/lib/VtxMap/mapPlayer.js.map +1 -0
- package/lib/VtxMap/optimizingPointMap.js +245 -205
- package/lib/VtxMap/optimizingPointMap.js.map +1 -0
- package/lib/VtxMap/style/css.js +16 -0
- package/lib/VtxMap/style/css.js.map +1 -0
- package/lib/VtxMap/style/index.js +16 -0
- package/lib/VtxMap/style/index.js.map +1 -0
- package/lib/VtxMap/zoomMap.js +120 -101
- package/lib/VtxMap/zoomMap.js.map +1 -0
- package/lib/VtxModal/VtxModal.css +62 -0
- package/lib/VtxModal/VtxModal.js +223 -213
- package/lib/VtxModal/VtxModal.js.map +1 -0
- package/lib/VtxModal/VtxModal.less +2 -2
- package/lib/VtxModal/VtxModalAntd3.css +62 -0
- package/lib/VtxModal/VtxModalAntd3.less +67 -0
- package/lib/VtxModal/draggableModal.js +138 -119
- package/lib/VtxModal/draggableModal.js.map +1 -0
- package/lib/VtxModal/index.js +21 -14
- package/lib/VtxModal/index.js.map +1 -0
- package/lib/VtxModal/style/css.js +21 -0
- package/lib/VtxModal/style/css.js.map +1 -0
- package/lib/VtxModal/style/index.js +21 -0
- package/lib/VtxModal/style/index.js.map +1 -0
- package/lib/VtxSearchMap/VtxSearchMap.css +171 -0
- package/lib/VtxSearchMap/VtxSearchMap.js +864 -819
- package/lib/VtxSearchMap/VtxSearchMap.js.map +1 -0
- package/lib/VtxSearchMap/VtxSearchMapAntd3.css +0 -0
- package/lib/VtxSearchMap/VtxSearchMapAntd3.less +1 -0
- package/lib/VtxSearchMap/index.js +9 -9
- package/lib/VtxSearchMap/index.js.map +1 -0
- package/lib/VtxSearchMap/mapping.js +15 -12
- package/lib/VtxSearchMap/mapping.js.map +1 -0
- package/lib/VtxSearchMap/style/css.js +47 -0
- package/lib/VtxSearchMap/style/css.js.map +1 -0
- package/lib/VtxSearchMap/style/index.js +47 -0
- package/lib/VtxSearchMap/style/index.js.map +1 -0
- package/lib/default.js +32 -27
- package/lib/default.js.map +1 -0
- package/lib/index.js +9 -10
- package/lib/index.js.map +1 -0
- package/package.json +25 -4
package/lib/VtxMap/mapPlayer.js
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
|
|
4
|
+
value: true
|
|
5
5
|
});
|
|
6
|
+
exports["default"] = void 0;
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
8
9
|
|
|
9
|
-
|
|
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
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
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
|
-
|
|
278
|
-
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
this.
|
|
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
|
-
|
|
295
|
-
this._supplementPoints = [];
|
|
296
|
-
this._currentSupplementIndex = 0;
|
|
185
|
+
}
|
|
297
186
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
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
|
-
|
|
388
|
+
return MapPlayer;
|
|
345
389
|
}();
|
|
346
390
|
|
|
347
|
-
exports
|
|
348
|
-
module.exports = exports[
|
|
391
|
+
exports["default"] = MapPlayer;
|
|
392
|
+
module.exports = exports["default"];
|
|
393
|
+
//# sourceMappingURL=mapPlayer.js.map
|