@vtx/map 1.0.3
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/README.md +44 -0
- package/lib/VtxMap/AMap/AMap.css +24 -0
- package/lib/VtxMap/AMap/AMap.js +2944 -0
- package/lib/VtxMap/AMap/AMap.less +24 -0
- package/lib/VtxMap/BMap/Map.css +26 -0
- package/lib/VtxMap/BMap/Map.js +3128 -0
- package/lib/VtxMap/BMap/Map.less +28 -0
- package/lib/VtxMap/GMap/Map.css +88 -0
- package/lib/VtxMap/GMap/Map.js +4166 -0
- package/lib/VtxMap/GMap/Map.less +87 -0
- package/lib/VtxMap/Map.css +7 -0
- package/lib/VtxMap/Map.js +84 -0
- package/lib/VtxMap/Map.less +9 -0
- package/lib/VtxMap/MapToolFunction.js +403 -0
- package/lib/VtxMap/OMap/Map.css +76 -0
- package/lib/VtxMap/OMap/Map.js +3932 -0
- package/lib/VtxMap/OMap/Map.less +70 -0
- package/lib/VtxMap/TMap/TMap.css +26 -0
- package/lib/VtxMap/TMap/TMap.js +3151 -0
- package/lib/VtxMap/TMap/TMap.less +31 -0
- package/lib/VtxMap/index.js +34 -0
- package/lib/VtxMap/mapPlayer.js +348 -0
- package/lib/VtxMap/optimizingPointMap.js +238 -0
- package/lib/VtxMap/zoomMap.js +124 -0
- package/lib/VtxModal/VtxModal.css +62 -0
- package/lib/VtxModal/VtxModal.js +249 -0
- package/lib/VtxModal/VtxModal.less +65 -0
- package/lib/VtxModal/draggableModal.js +143 -0
- package/lib/VtxModal/index.js +22 -0
- package/lib/VtxSearchMap/VtxSearchMap.css +170 -0
- package/lib/VtxSearchMap/VtxSearchMap.js +872 -0
- package/lib/VtxSearchMap/VtxSearchMap.less +169 -0
- package/lib/VtxSearchMap/index.js +22 -0
- package/lib/VtxSearchMap/mapping.js +15 -0
- package/lib/default.js +40 -0
- package/lib/index.js +35 -0
- package/package.json +39 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.tdt-label{
|
|
2
|
+
background: transparent !important;
|
|
3
|
+
padding: 0px !important;
|
|
4
|
+
-moz-box-shadow: 0px 0px 4px transparent !important;
|
|
5
|
+
-webkit-box-shadow: 0px 0px 4px transparent !important;
|
|
6
|
+
box-shadow: 0px 0px 4px transparent !important;
|
|
7
|
+
border-width: 0px !important;
|
|
8
|
+
line-height: 22px !important;
|
|
9
|
+
}
|
|
10
|
+
.tdt-pane .tdt-marker-pane{
|
|
11
|
+
img{
|
|
12
|
+
-webkit-transform-origin-x: center;
|
|
13
|
+
-webkit-transform-origin-y: center;
|
|
14
|
+
-ms-transform-origin-x: center;
|
|
15
|
+
-ms-transform-origin-y: center;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
.vtx_gmap_html_pointCollection_t{
|
|
19
|
+
position: absolute;
|
|
20
|
+
top: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
canvas{
|
|
23
|
+
z-index: 400 !important;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
.vtx_tmap_heatmap_class{
|
|
27
|
+
canvas{
|
|
28
|
+
z-index: 400 !important;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MapPlayer = exports.VtxZoomMap = exports.VtxOptMap = exports.VtxMap = undefined;
|
|
7
|
+
|
|
8
|
+
var _Map = require('./Map');
|
|
9
|
+
|
|
10
|
+
var _Map2 = _interopRequireDefault(_Map);
|
|
11
|
+
|
|
12
|
+
var _optimizingPointMap = require('./optimizingPointMap');
|
|
13
|
+
|
|
14
|
+
var _optimizingPointMap2 = _interopRequireDefault(_optimizingPointMap);
|
|
15
|
+
|
|
16
|
+
var _zoomMap = require('./zoomMap');
|
|
17
|
+
|
|
18
|
+
var _zoomMap2 = _interopRequireDefault(_zoomMap);
|
|
19
|
+
|
|
20
|
+
var _mapPlayer = require('./mapPlayer');
|
|
21
|
+
|
|
22
|
+
var _mapPlayer2 = _interopRequireDefault(_mapPlayer);
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
|
|
26
|
+
_Map2.default.VtxOptMap = _optimizingPointMap2.default;
|
|
27
|
+
_Map2.default.VtxZoomMap = _zoomMap2.default;
|
|
28
|
+
_Map2.default.MapPlayer = _mapPlayer2.default;
|
|
29
|
+
|
|
30
|
+
exports.default = _Map2.default;
|
|
31
|
+
exports.VtxMap = _Map2.default;
|
|
32
|
+
exports.VtxOptMap = _optimizingPointMap2.default;
|
|
33
|
+
exports.VtxZoomMap = _zoomMap2.default;
|
|
34
|
+
exports.MapPlayer = _mapPlayer2.default;
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
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
|
+
|
|
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
|
+
|
|
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
|
+
|
|
13
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
14
|
+
|
|
15
|
+
/*
|
|
16
|
+
地图实例:@map
|
|
17
|
+
需要播放的点位数组:@path --- [{longitude,latitude,name,id}]
|
|
18
|
+
|
|
19
|
+
播放速度:@speed --- Number
|
|
20
|
+
播放倍率:@playRate,
|
|
21
|
+
点位设置:@pointSetting,
|
|
22
|
+
线设置:@lineSetting,
|
|
23
|
+
是否开启图标自动旋转:@enableRotation,
|
|
24
|
+
点位变化事件:@onChange
|
|
25
|
+
setSpeed
|
|
26
|
+
setCurrentIndex
|
|
27
|
+
play
|
|
28
|
+
pause
|
|
29
|
+
stop
|
|
30
|
+
destroy
|
|
31
|
+
*/
|
|
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
|
+
}
|
|
216
|
+
}
|
|
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
|
+
}
|
|
265
|
+
}
|
|
266
|
+
// 暂停播放
|
|
267
|
+
|
|
268
|
+
}, {
|
|
269
|
+
key: 'pause',
|
|
270
|
+
value: function pause(onPlayPause) {
|
|
271
|
+
this._clearTimer();
|
|
272
|
+
typeof onPlayPause == "function" && onPlayPause(this.path[this._currentIndex], this._currentIndex);
|
|
273
|
+
}
|
|
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);
|
|
285
|
+
}
|
|
286
|
+
// 销毁(删除所有添加的图层)
|
|
287
|
+
|
|
288
|
+
}, {
|
|
289
|
+
key: 'destroy',
|
|
290
|
+
value: function destroy() {
|
|
291
|
+
this._clearTimer();
|
|
292
|
+
this.map.removeGraphic(this._pointId);
|
|
293
|
+
this.map.removeGraphic(this._lineId);
|
|
294
|
+
this._currentIndex = 0;
|
|
295
|
+
this._supplementPoints = [];
|
|
296
|
+
this._currentSupplementIndex = 0;
|
|
297
|
+
}
|
|
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
|
+
}
|
|
309
|
+
}
|
|
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
|
+
}
|
|
326
|
+
}
|
|
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
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}]);
|
|
343
|
+
|
|
344
|
+
return MapPlayer;
|
|
345
|
+
}();
|
|
346
|
+
|
|
347
|
+
exports.default = MapPlayer;
|
|
348
|
+
module.exports = exports['default'];
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
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
|
+
|
|
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
|
+
|
|
11
|
+
var _react = require('react');
|
|
12
|
+
|
|
13
|
+
var _react2 = _interopRequireDefault(_react);
|
|
14
|
+
|
|
15
|
+
var _Map = require('./Map');
|
|
16
|
+
|
|
17
|
+
var _Map2 = _interopRequireDefault(_Map);
|
|
18
|
+
|
|
19
|
+
var _isEqual2 = require('lodash/isEqual');
|
|
20
|
+
|
|
21
|
+
var _isEqual3 = _interopRequireDefault(_isEqual2);
|
|
22
|
+
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
|
|
25
|
+
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); } }
|
|
26
|
+
|
|
27
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28
|
+
|
|
29
|
+
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; }
|
|
30
|
+
|
|
31
|
+
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; }
|
|
32
|
+
|
|
33
|
+
var OptimizingPointMap = function (_React$Component) {
|
|
34
|
+
_inherits(OptimizingPointMap, _React$Component);
|
|
35
|
+
|
|
36
|
+
function OptimizingPointMap(props) {
|
|
37
|
+
_classCallCheck(this, OptimizingPointMap);
|
|
38
|
+
|
|
39
|
+
var _this = _possibleConstructorReturn(this, (OptimizingPointMap.__proto__ || Object.getPrototypeOf(OptimizingPointMap)).call(this, props));
|
|
40
|
+
|
|
41
|
+
_this.map = null;
|
|
42
|
+
_this.mapLoaded = false;
|
|
43
|
+
_this.MPP = new mapPointsProcessor(props.gridSpacing || 40);
|
|
44
|
+
_this.state = {
|
|
45
|
+
filterPoints: []
|
|
46
|
+
};
|
|
47
|
+
_this.zoomEnd = _this.zoomEnd.bind(_this);
|
|
48
|
+
_this.moveEnd = _this.moveEnd.bind(_this);
|
|
49
|
+
_this.resetPoints = _this.resetPoints.bind(_this);
|
|
50
|
+
|
|
51
|
+
_this.resetDelay = {
|
|
52
|
+
timer: null,
|
|
53
|
+
eType: null
|
|
54
|
+
};
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
_createClass(OptimizingPointMap, [{
|
|
59
|
+
key: 'resetPoints',
|
|
60
|
+
value: function resetPoints(props, eType) {
|
|
61
|
+
var t = this;
|
|
62
|
+
// 延时优化,只处理最后一次操作
|
|
63
|
+
if (t.resetDelay.timer) {
|
|
64
|
+
clearTimeout(t.resetDelay.timer);
|
|
65
|
+
}
|
|
66
|
+
t.resetDelay.eType = t.resetDelay.eType == 'zoom' || eType == 'zoom' ? 'zoom' : eType;
|
|
67
|
+
t.resetDelay.timer = setTimeout(function () {
|
|
68
|
+
var mcfg = t.map.getMapExtent();
|
|
69
|
+
var param = {
|
|
70
|
+
mapHeight: mcfg.mapSize.height,
|
|
71
|
+
mapWidth: mcfg.mapSize.width,
|
|
72
|
+
minLat: mcfg.southWest.lat,
|
|
73
|
+
maxLat: mcfg.northEast.lat,
|
|
74
|
+
minLng: mcfg.southWest.lng,
|
|
75
|
+
maxLng: mcfg.northEast.lng,
|
|
76
|
+
eType: t.resetDelay.eType,
|
|
77
|
+
allPoints: props.mapPoints,
|
|
78
|
+
reservedPoints: props.reservedPoints
|
|
79
|
+
};
|
|
80
|
+
t.setState({
|
|
81
|
+
filterPoints: t.MPP.pointFilter(param)
|
|
82
|
+
});
|
|
83
|
+
t.resetDelay.timer = null;
|
|
84
|
+
t.resetDelay.eType = null;
|
|
85
|
+
}, 200);
|
|
86
|
+
}
|
|
87
|
+
}, {
|
|
88
|
+
key: 'componentDidMount',
|
|
89
|
+
value: function componentDidMount() {
|
|
90
|
+
var _this2 = this;
|
|
91
|
+
|
|
92
|
+
this.map.loadMapComplete.then(function () {
|
|
93
|
+
_this2.resetPoints(_this2.props);
|
|
94
|
+
_this2.mapLoaded = true;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}, {
|
|
98
|
+
key: 'componentWillReceiveProps',
|
|
99
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
100
|
+
if (this.mapLoaded && (!(0, _isEqual3.default)(this.props.reservedPoints, nextProps.reservedPoints) || !(0, _isEqual3.default)(this.props.mapPoints, nextProps.mapPoints))) {
|
|
101
|
+
// 外部点数据改变,更新内部点数据
|
|
102
|
+
this.resetPoints(nextProps);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, {
|
|
106
|
+
key: 'zoomEnd',
|
|
107
|
+
value: function zoomEnd(obj) {
|
|
108
|
+
this.resetPoints(this.props, 'zoom');
|
|
109
|
+
if (typeof this.props.zoomEnd === "function") {
|
|
110
|
+
this.props.zoomEnd(obj);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: 'moveEnd',
|
|
115
|
+
value: function moveEnd(obj) {
|
|
116
|
+
this.resetPoints(this.props, 'move');
|
|
117
|
+
if (typeof this.props.moveEnd === "function") {
|
|
118
|
+
this.props.moveEnd(obj);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}, {
|
|
122
|
+
key: 'render',
|
|
123
|
+
value: function render() {
|
|
124
|
+
var _this3 = this;
|
|
125
|
+
|
|
126
|
+
// console.log('优化后剩余点数:'+this.state.filterPoints.length)
|
|
127
|
+
var newProps = _extends({}, this.props, {
|
|
128
|
+
zoomEnd: this.zoomEnd,
|
|
129
|
+
moveEnd: this.moveEnd,
|
|
130
|
+
mapPoints: this.state.filterPoints,
|
|
131
|
+
getMapInstance: function getMapInstance(p) {
|
|
132
|
+
if (p) {
|
|
133
|
+
_this3.map = p;
|
|
134
|
+
}
|
|
135
|
+
if (typeof _this3.props.getMapInstance === "function") {
|
|
136
|
+
_this3.props.getMapInstance(p);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
delete newProps.gridSpacing;
|
|
141
|
+
delete newProps.reservedPoints;
|
|
142
|
+
|
|
143
|
+
return _react2.default.createElement(_Map2.default, newProps);
|
|
144
|
+
}
|
|
145
|
+
}]);
|
|
146
|
+
|
|
147
|
+
return OptimizingPointMap;
|
|
148
|
+
}(_react2.default.Component);
|
|
149
|
+
|
|
150
|
+
var mapPointsProcessor = function () {
|
|
151
|
+
function mapPointsProcessor(gridSpacing) {
|
|
152
|
+
_classCallCheck(this, mapPointsProcessor);
|
|
153
|
+
|
|
154
|
+
this.GRIDSPACING = gridSpacing || 40;
|
|
155
|
+
this.mapHeight = null; //地图高度
|
|
156
|
+
this.mapWidth = null; //地图宽度
|
|
157
|
+
// 若地图大小不变,zoom不变,网格的经纬度间隔应该保持不变以保证前后两次网格位置保持一致
|
|
158
|
+
this.lngInterval = null; //划分的网格经度间隔
|
|
159
|
+
this.latInterval = null; //划分的网格纬度间隔
|
|
160
|
+
this.maxLat = null, this.minLat = null, this.maxLng = null, this.minLng = null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
_createClass(mapPointsProcessor, [{
|
|
164
|
+
key: 'resetMapConfig',
|
|
165
|
+
value: function resetMapConfig(param) {
|
|
166
|
+
// 若没传地图相关参数默认使用上次的地图参数
|
|
167
|
+
var mapHeight = param.mapHeight,
|
|
168
|
+
mapWidth = param.mapWidth,
|
|
169
|
+
maxLat = param.maxLat,
|
|
170
|
+
minLat = param.minLat,
|
|
171
|
+
maxLng = param.maxLng,
|
|
172
|
+
minLng = param.minLng,
|
|
173
|
+
eType = param.eType;
|
|
174
|
+
|
|
175
|
+
this.maxLat = maxLat || this.maxLat;
|
|
176
|
+
this.minLat = minLat || this.minLat;
|
|
177
|
+
this.maxLng = maxLng || this.maxLng;
|
|
178
|
+
this.minLng = minLng || this.minLng;
|
|
179
|
+
// 当操作为zoom(改变最大最小经纬度)或地图宽高改变则重新计算网格
|
|
180
|
+
if (eType == 'zoom' || mapHeight && mapHeight != this.mapHeight || mapWidth && mapWidth != this.mapWidth) {
|
|
181
|
+
this.mapHeight = mapHeight || this.mapHeight;
|
|
182
|
+
this.mapWidth = mapWidth || this.mapWidth;
|
|
183
|
+
this.calGridInterval();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: 'calGridInterval',
|
|
188
|
+
value: function calGridInterval() {
|
|
189
|
+
var x_num = Math.ceil(this.mapWidth / this.GRIDSPACING);
|
|
190
|
+
var y_num = Math.ceil(this.mapHeight / this.GRIDSPACING);
|
|
191
|
+
this.lngInterval = parseFloat(((this.maxLng - this.minLng) / x_num).toFixed(6));
|
|
192
|
+
this.latInterval = parseFloat(((this.maxLat - this.minLat) / y_num).toFixed(6));
|
|
193
|
+
}
|
|
194
|
+
}, {
|
|
195
|
+
key: 'pointFilter',
|
|
196
|
+
value: function pointFilter(param) {
|
|
197
|
+
// allPoints为必填参数
|
|
198
|
+
var allPoints = param.allPoints,
|
|
199
|
+
_param$reservedPoints = param.reservedPoints,
|
|
200
|
+
reservedPoints = _param$reservedPoints === undefined ? [] : _param$reservedPoints;
|
|
201
|
+
|
|
202
|
+
this.resetMapConfig(param);
|
|
203
|
+
|
|
204
|
+
var hashPoints = {};
|
|
205
|
+
for (var i = 0, len = allPoints.length; i < len; i++) {
|
|
206
|
+
var p_lng = allPoints[i].longitude;
|
|
207
|
+
var p_lat = allPoints[i].latitude;
|
|
208
|
+
if (p_lng > this.maxLng || p_lng < this.minLng || p_lat > this.maxLat || p_lat < this.minLat) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
var x_index = parseInt(p_lng / this.lngInterval);
|
|
212
|
+
var y_index = parseInt(p_lat / this.latInterval);
|
|
213
|
+
var hashIndex = x_index + '-' + y_index;
|
|
214
|
+
if (!hashPoints[hashIndex]) {
|
|
215
|
+
hashPoints[hashIndex] = allPoints[i];
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var filteredPoints = [].concat(_toConsumableArray(reservedPoints));
|
|
220
|
+
var reservedIds = reservedPoints.map(function (item) {
|
|
221
|
+
return item.id;
|
|
222
|
+
});
|
|
223
|
+
for (var k in hashPoints) {
|
|
224
|
+
var the_point = hashPoints[k];
|
|
225
|
+
if (reservedIds.indexOf(the_point.id) == -1) {
|
|
226
|
+
filteredPoints.push(the_point);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return filteredPoints;
|
|
231
|
+
}
|
|
232
|
+
}]);
|
|
233
|
+
|
|
234
|
+
return mapPointsProcessor;
|
|
235
|
+
}();
|
|
236
|
+
|
|
237
|
+
exports.default = OptimizingPointMap;
|
|
238
|
+
module.exports = exports['default'];
|