@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,4166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
8
|
+
|
|
9
|
+
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; };
|
|
10
|
+
|
|
11
|
+
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; }; }();
|
|
12
|
+
|
|
13
|
+
var _react = require('react');
|
|
14
|
+
|
|
15
|
+
var _react2 = _interopRequireDefault(_react);
|
|
16
|
+
|
|
17
|
+
require('./Map.css');
|
|
18
|
+
|
|
19
|
+
var _MapToolFunction = require('../MapToolFunction');
|
|
20
|
+
|
|
21
|
+
var _immutable = require('immutable');
|
|
22
|
+
|
|
23
|
+
var _immutable2 = _interopRequireDefault(_immutable);
|
|
24
|
+
|
|
25
|
+
var _default = require('../../default');
|
|
26
|
+
|
|
27
|
+
var _default2 = _interopRequireDefault(_default);
|
|
28
|
+
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
|
|
31
|
+
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; }
|
|
32
|
+
|
|
33
|
+
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); } }
|
|
34
|
+
|
|
35
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
36
|
+
|
|
37
|
+
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; }
|
|
38
|
+
|
|
39
|
+
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; }
|
|
40
|
+
//公共地址配置
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
var Set = _immutable2.default.Set;
|
|
44
|
+
|
|
45
|
+
var ArcgisMap = function (_React$Component) {
|
|
46
|
+
_inherits(ArcgisMap, _React$Component);
|
|
47
|
+
|
|
48
|
+
function ArcgisMap(props) {
|
|
49
|
+
_classCallCheck(this, ArcgisMap);
|
|
50
|
+
|
|
51
|
+
var _this = _possibleConstructorReturn(this, (ArcgisMap.__proto__ || Object.getPrototypeOf(ArcgisMap)).call(this, props));
|
|
52
|
+
|
|
53
|
+
_this.grwkid = 4326; //wkid 坐标系对应,全局使用.
|
|
54
|
+
_this.wkid = (isNaN(parseInt(props.wkid)) ? props.wkid : parseInt(props.wkid)) || 4326; //wkid 坐标系对应,全局使用.
|
|
55
|
+
_this.wkidStr = isNaN(parseInt(props.wkid)) ? 'wkt' : 'wkid';
|
|
56
|
+
_this.zIndexGraphics = []; //需要放在最后的图元,zoom和pan时刷新dom到最后
|
|
57
|
+
_this.htmlPointsId = 'vtx_gmap_html_points'; //html点位容器id class管理
|
|
58
|
+
_this.pointCollectionId = 'vtx_gmap_html_pointCollection'; //海量点canvas点位容器id class管理
|
|
59
|
+
_this.Label = {}; //所有label 集合
|
|
60
|
+
_this.labelLayer = { x: 0, y: 0 }; //label图层 位置管理
|
|
61
|
+
_this.GM = new _MapToolFunction.graphicManage(); //初始化 图元管理方法
|
|
62
|
+
_this.getPolygonArea = _MapToolFunction.getPolygonArea;
|
|
63
|
+
_this.loadTimer = null; //初始化地图 load时延缓数据处理
|
|
64
|
+
_this.animTimer = {}; //点位跳动动画 定时集合
|
|
65
|
+
_this.animCount = {}; //点位跳动动画 定时计数
|
|
66
|
+
_this.moveToTimer = null; //moveTo时间对象
|
|
67
|
+
_this.drawToolbar = null; //绘制对象
|
|
68
|
+
_this.drawParam = {}; //缓存 绘制的数据
|
|
69
|
+
_this.editToolbar = null; //编辑对象
|
|
70
|
+
_this.editToolbarC = null; //编辑对象
|
|
71
|
+
_this.editId = ''; //当前编辑的图元id
|
|
72
|
+
_this.canMoveLabel = false; //编辑点时,label跟着移动开关
|
|
73
|
+
//当前鼠标的经纬度,便捷含label点时刷新
|
|
74
|
+
//x,y鼠标坐标 px,py鼠标与点中心偏移坐标 isCount是否计算偏移
|
|
75
|
+
_this.mouseNowPosition = { x: 0, y: 0, px: 0, py: 0, isCount: false };
|
|
76
|
+
_this.heatmap = null; //热力图对象
|
|
77
|
+
_this.clusterMarkers = []; //聚合点位id数组
|
|
78
|
+
_this.clusterPs = []; //聚合集合点
|
|
79
|
+
_this.clusterPt = []; //地图中聚合点集合
|
|
80
|
+
_this.morepoints = []; //海量点集合
|
|
81
|
+
_this.areaRestriction = null; //区域限制数据
|
|
82
|
+
_this.movePoints = [];
|
|
83
|
+
//是否绘制测距
|
|
84
|
+
_this.rangingTool = {
|
|
85
|
+
isRanging: false, //是否开启状态
|
|
86
|
+
line: {}, //线
|
|
87
|
+
points: [], //点
|
|
88
|
+
distance: 0, //测距长度
|
|
89
|
+
mapRangingTool: null //测距回调
|
|
90
|
+
};
|
|
91
|
+
_this.rangingTools = {}; //测距点线缓存
|
|
92
|
+
_this.state = {
|
|
93
|
+
gis: null, //地图对象
|
|
94
|
+
mapId: props.mapId,
|
|
95
|
+
mapCreated: false,
|
|
96
|
+
pointIds: [], //地图上点的ids
|
|
97
|
+
lineIds: [], //地图上线的ids
|
|
98
|
+
polygonIds: [], //地图上面的ids
|
|
99
|
+
circleIds: [], //地图上圆的ids
|
|
100
|
+
// editId: '',//当前编辑的图元id
|
|
101
|
+
editGraphic: '', //当前编辑完后图元所有数据
|
|
102
|
+
boundaryInfo: [], //当前画出的边界线的id和区域名
|
|
103
|
+
drawIds: { //绘制工具id集合
|
|
104
|
+
point: [],
|
|
105
|
+
polyline: [],
|
|
106
|
+
polygon: [],
|
|
107
|
+
circle: [],
|
|
108
|
+
rectangle: []
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
_this.loadMapJs();
|
|
112
|
+
return _this;
|
|
113
|
+
}
|
|
114
|
+
//加载地图信息
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
_createClass(ArcgisMap, [{
|
|
118
|
+
key: 'loadMapJs',
|
|
119
|
+
value: function loadMapJs() {
|
|
120
|
+
this.loadMapComplete = new Promise(function (resolve, reject) {
|
|
121
|
+
if (window.GMap) {
|
|
122
|
+
resolve(window.GMap);
|
|
123
|
+
} else {
|
|
124
|
+
//加载 js
|
|
125
|
+
// $.getScript('http://222.92.212.126:25048/gis/html/js/arcgis_js_api/library/3.9/3.9/init.js',()=>{
|
|
126
|
+
$.getScript(_default2.default.arcgisServerURL + '/html/js/arcgis_js_api/library/3.9/3.9/init.js', function () {
|
|
127
|
+
var Heatmap = new Promise(function (resolve, reject) {
|
|
128
|
+
$.getScript(_default2.default.mapServerURL + '/gisheatmap.js', function () {
|
|
129
|
+
resolve();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
var PointCollection = new Promise(function (resolve, reject) {
|
|
133
|
+
$.getScript(_default2.default.mapServerURL + '/GPointCollection.js', function () {
|
|
134
|
+
resolve();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
Promise.all([Heatmap, PointCollection]).then(function () {
|
|
138
|
+
//require是关键字 这边用window区别
|
|
139
|
+
window.require(["esri/map", "esri/layers/ArcGISTiledMapServiceLayer", "dojo/on", 'esri/geometry/Point', 'esri/symbols/SimpleMarkerSymbol', "esri/Color", "esri/graphic", "esri/domUtils", "esri/toolbars/edit", "esri/symbols/PictureMarkerSymbol", "esri/symbols/TextSymbol", "esri/symbols/SimpleLineSymbol", "esri/toolbars/draw", "esri/layers/WMTSLayer", "esri/geometry/Extent", "esri/layers/WMTSLayerInfo", "esri/geometry/Polyline", "esri/symbols/SimpleFillSymbol", "esri/geometry/Circle", "esri/layers/TileInfo", "esri/SpatialReference", "esri/dijit/BasemapToggle"], function (Map) {
|
|
140
|
+
window.GMap = Map;
|
|
141
|
+
resolve(window.GMap);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
//加载 css
|
|
146
|
+
$("<link>").attr({ rel: "stylesheet", type: "text/css", href: _default2.default.arcgisServerURL + '/html/js/arcgis_js_api/library/3.9/3.9/js/dojo/dijit/themes/tundra/tundra.css' }).appendTo("head");
|
|
147
|
+
$("<link>").attr({ rel: "stylesheet", type: "text/css", href: _default2.default.arcgisServerURL + '/html/js/arcgis_js_api/library/3.9/3.9/js/esri/css/esri.css' }).appendTo("head");
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
//初始化地图数据
|
|
152
|
+
|
|
153
|
+
}, {
|
|
154
|
+
key: 'init',
|
|
155
|
+
value: function init() {
|
|
156
|
+
var _this2 = this;
|
|
157
|
+
|
|
158
|
+
var t = this;
|
|
159
|
+
//创建地图
|
|
160
|
+
t.createMap();
|
|
161
|
+
// 处理数据(整合)
|
|
162
|
+
var initData = function initData() {
|
|
163
|
+
var _t$props = t.props,
|
|
164
|
+
mapPoints = _t$props.mapPoints,
|
|
165
|
+
mapLines = _t$props.mapLines,
|
|
166
|
+
mapPolygons = _t$props.mapPolygons,
|
|
167
|
+
mapCircles = _t$props.mapCircles,
|
|
168
|
+
mapVisiblePoints = _t$props.mapVisiblePoints,
|
|
169
|
+
mapCluster = _t$props.mapCluster,
|
|
170
|
+
mapZoomLevel = _t$props.mapZoomLevel,
|
|
171
|
+
isOpenTrafficInfo = _t$props.isOpenTrafficInfo,
|
|
172
|
+
mapPointCollection = _t$props.mapPointCollection,
|
|
173
|
+
areaRestriction = _t$props.areaRestriction;
|
|
174
|
+
var _t$props2 = t.props,
|
|
175
|
+
boundaryName = _t$props2.boundaryName,
|
|
176
|
+
heatMapData = _t$props2.heatMapData,
|
|
177
|
+
customizedBoundary = _t$props2.customizedBoundary;
|
|
178
|
+
var _t$state = t.state,
|
|
179
|
+
boundaryInfo = _t$state.boundaryInfo,
|
|
180
|
+
pointIds = _t$state.pointIds,
|
|
181
|
+
lineIds = _t$state.lineIds,
|
|
182
|
+
polygonIds = _t$state.polygonIds,
|
|
183
|
+
circleIds = _t$state.circleIds;
|
|
184
|
+
//添加点
|
|
185
|
+
|
|
186
|
+
if (mapPoints instanceof Array) {
|
|
187
|
+
t.addPoint(mapPoints);
|
|
188
|
+
}
|
|
189
|
+
//添加线
|
|
190
|
+
if (mapLines instanceof Array) {
|
|
191
|
+
t.addLine(mapLines);
|
|
192
|
+
}
|
|
193
|
+
//添加面
|
|
194
|
+
if (mapPolygons instanceof Array) {
|
|
195
|
+
t.addPolygon(mapPolygons);
|
|
196
|
+
}
|
|
197
|
+
//添加圆
|
|
198
|
+
if (mapCircles instanceof Array) {
|
|
199
|
+
t.addCircle(mapCircles);
|
|
200
|
+
}
|
|
201
|
+
//是否设置比例尺
|
|
202
|
+
if (t.props.showControl) {
|
|
203
|
+
t.showControl();
|
|
204
|
+
}
|
|
205
|
+
// 画热力图
|
|
206
|
+
if (heatMapData) {
|
|
207
|
+
t.heatMapOverlay(heatMapData);
|
|
208
|
+
}
|
|
209
|
+
//设置点聚合
|
|
210
|
+
if (mapCluster instanceof Array) {
|
|
211
|
+
t.cluster(mapCluster);
|
|
212
|
+
}
|
|
213
|
+
//添加海量点
|
|
214
|
+
if (mapPointCollection instanceof Array) {
|
|
215
|
+
t.addPointCollection(mapPointCollection);
|
|
216
|
+
}
|
|
217
|
+
//设置区域限制
|
|
218
|
+
if (areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
|
|
219
|
+
t.setAreaRestriction(areaRestriction);
|
|
220
|
+
}
|
|
221
|
+
t.setState({
|
|
222
|
+
mapCreated: true
|
|
223
|
+
});
|
|
224
|
+
};
|
|
225
|
+
//事件监听
|
|
226
|
+
var event = function event() {
|
|
227
|
+
//html点位 根据地图移动和zoom计算位置
|
|
228
|
+
var changeLabel = function changeLabel() {
|
|
229
|
+
for (var i in t.Label) {
|
|
230
|
+
var cmids = t.clusterMarkers.map(function (item) {
|
|
231
|
+
return item.id;
|
|
232
|
+
});
|
|
233
|
+
if (t.Label[i]) {
|
|
234
|
+
var position = t.GM.getGraphic(i).geometry;
|
|
235
|
+
var tl = t.state.gis.toScreen(position);
|
|
236
|
+
// let tl = t.state.gis.toScreen(t.Label[i].position);
|
|
237
|
+
//渲染優化
|
|
238
|
+
if (!(tl.y < -50 || tl.x < -50 || tl.y > t.state.gis.height || tl.x > t.state.gis.width)) {
|
|
239
|
+
t.Label[i].html.css({
|
|
240
|
+
position: 'absolute',
|
|
241
|
+
top: tl.y + t.Label[i].offset.y - t.labelLayer.y,
|
|
242
|
+
left: tl.x + t.Label[i].offset.x - t.labelLayer.x
|
|
243
|
+
});
|
|
244
|
+
if (!t.Label[i].add && cmids.indexOf(i) == -1) {
|
|
245
|
+
$('#' + t.htmlPointsId).append(t.Label[i].html);
|
|
246
|
+
t.Label[i].add = true;
|
|
247
|
+
}
|
|
248
|
+
} else {
|
|
249
|
+
if (t.Label[i].add && cmids.indexOf(i) == -1) {
|
|
250
|
+
t.Label[i].html.remove();
|
|
251
|
+
t.Label[i].add = false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
//见需要在顶部显示的图元重新排位置
|
|
258
|
+
var czIndex = function czIndex() {
|
|
259
|
+
for (var i = 0; i < t.zIndexGraphics.length; i++) {
|
|
260
|
+
$('#' + t.props.mapId + '_graphics_layer').append(t.GM.getGraphic(t.zIndexGraphics[i]).getNode());
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/*测距功能*/
|
|
264
|
+
var rangingToolFun = function rangingToolFun(e, status) {
|
|
265
|
+
if (t.rangingTool.isRanging) {
|
|
266
|
+
//测距开始
|
|
267
|
+
//点击位置
|
|
268
|
+
var lnlt = [e.mapPoint.x, e.mapPoint.y];
|
|
269
|
+
//2个点以上 计算长度
|
|
270
|
+
if (t.rangingTool.points.length > 0) {
|
|
271
|
+
t.rangingTool.distance += (0, _MapToolFunction.getDistance)(lnlt, [t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude], t.state.gis, t.grwkid);
|
|
272
|
+
} else {
|
|
273
|
+
t.rangingTool.line.paths = [];
|
|
274
|
+
}
|
|
275
|
+
t.rangingTool.line.paths.push([].concat(lnlt));
|
|
276
|
+
//处理距离展示
|
|
277
|
+
var distext = t.rangingTool.distance > 0 ? t.rangingTool.distance > 1000 ? '\u603B\u957F:' + Math.round(t.rangingTool.distance / 10) / 100 + '\u516C\u91CC' : '\u603B\u957F:' + t.rangingTool.distance + '\u7C73' : '起点';
|
|
278
|
+
//加点
|
|
279
|
+
var point = {
|
|
280
|
+
id: t.rangingTool.points.length + 'vtx_g_rang_p' + Math.random(),
|
|
281
|
+
longitude: lnlt[0],
|
|
282
|
+
latitude: lnlt[1],
|
|
283
|
+
markerContent: '\n <div style=\'z-index:1;\'>\n <div class=\'vtx-g-rangingPoint\'></div>\n <div class=\'vtx-g-rangingDistance\'>' + distext + '</div>\n </div>\n ',
|
|
284
|
+
config: {
|
|
285
|
+
width: 130,
|
|
286
|
+
height: 30,
|
|
287
|
+
markerContentX: -5.5,
|
|
288
|
+
markerContentY: -12.5
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
//用addpoint方法加点
|
|
292
|
+
t.addPoint([point]);
|
|
293
|
+
//缓存点信息
|
|
294
|
+
t.rangingTool.points.push(point);
|
|
295
|
+
if (t.rangingTool.line.paths.length == 2) {
|
|
296
|
+
//加线
|
|
297
|
+
t.rangingTool.line = {
|
|
298
|
+
id: 'vtx_g_rang_line' + Math.random(),
|
|
299
|
+
paths: [].concat(_toConsumableArray(t.rangingTool.line.paths)),
|
|
300
|
+
config: {
|
|
301
|
+
color: '#ff0000',
|
|
302
|
+
lineWidth: 2,
|
|
303
|
+
lineType: 'solid'
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
t.addLine([t.rangingTool.line]);
|
|
307
|
+
} else if (t.rangingTool.line.paths.length > 2) {
|
|
308
|
+
t.updateLine([_extends({}, t.rangingTool.line, {
|
|
309
|
+
paths: [].concat(_toConsumableArray(t.rangingTool.line.paths))
|
|
310
|
+
})]);
|
|
311
|
+
}
|
|
312
|
+
//双击 测距结束
|
|
313
|
+
if (status == 'dbl') {
|
|
314
|
+
//开启双击缩放功能
|
|
315
|
+
t.state.gis.enableDoubleClickZoom();
|
|
316
|
+
var rangkey = new Date().getTime() + Math.random();
|
|
317
|
+
//加结束点
|
|
318
|
+
var end = {
|
|
319
|
+
id: 'vtx_g_rang_end' + Math.random(),
|
|
320
|
+
longitude: lnlt[0],
|
|
321
|
+
latitude: lnlt[1],
|
|
322
|
+
markerContent: '\n <div>\n <div class=\'vtx-g-rang-exit\'>x</div>\n </div>\n ',
|
|
323
|
+
config: {
|
|
324
|
+
width: 13,
|
|
325
|
+
height: 13,
|
|
326
|
+
markerContentX: -20,
|
|
327
|
+
markerContentY: -20
|
|
328
|
+
},
|
|
329
|
+
index: rangkey
|
|
330
|
+
};
|
|
331
|
+
//用addpoint方法加点
|
|
332
|
+
t.addPoint([end]);
|
|
333
|
+
//删除提示框
|
|
334
|
+
t.removeGraphic('vtx-g-rang-showRangTool', 'point');
|
|
335
|
+
t.removeGraphic('vtx-g-rang-showRangTool-line', 'line');
|
|
336
|
+
//缓存当前这一条测距数据
|
|
337
|
+
t.rangingTools[rangkey] = _extends({}, t.rangingTool);
|
|
338
|
+
//回调测距参数
|
|
339
|
+
if (t.rangingTool.mapRangingTool) {
|
|
340
|
+
t.rangingTool.mapRangingTool({
|
|
341
|
+
distance: t.rangingTool.distance,
|
|
342
|
+
lnglats: t.rangingTool.line.paths
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
t.rangingTool.isRanging = false;
|
|
346
|
+
t.rangingTool = _extends({}, t.rangingTool, {
|
|
347
|
+
isRanging: false, //是否开启状态
|
|
348
|
+
line: {}, //线缓存
|
|
349
|
+
points: [], //点
|
|
350
|
+
distance: 0 //测距长度
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
};
|
|
355
|
+
//地图鼠标移入事件
|
|
356
|
+
t.state.gis.on('mouse-over', function (e) {
|
|
357
|
+
//鼠标移出地图时,删除测距显示点
|
|
358
|
+
if (t.rangingTool.isRanging) {
|
|
359
|
+
var rp = {
|
|
360
|
+
id: 'vtx-g-rang-showRangTool',
|
|
361
|
+
longitude: e.mapPoint.x,
|
|
362
|
+
latitude: e.mapPoint.y,
|
|
363
|
+
markerContent: '\n <div class=\'vtx-g-rang-showRangTool\'>\u5355\u51FB\u786E\u5B9A\u8D77\u70B9</div>\n ',
|
|
364
|
+
config: {
|
|
365
|
+
markerContentX: 20,
|
|
366
|
+
markerContentY: 20
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
t.addPoint([rp]);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
//地图鼠标移出事件
|
|
373
|
+
t.state.gis.on('mouse-out', function (e) {
|
|
374
|
+
//鼠标移出地图时,删除测距显示点
|
|
375
|
+
if (t.rangingTool.isRanging) {
|
|
376
|
+
t.removeGraphic('vtx-g-rang-showRangTool', 'point');
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
//地图鼠标移动事件
|
|
380
|
+
t.state.gis.on('mouse-move', function (e) {
|
|
381
|
+
//鼠标移动地图时,删除测距显示点
|
|
382
|
+
if (t.rangingTool.isRanging) {
|
|
383
|
+
//获取测距提示点位
|
|
384
|
+
var rp = _extends({}, t.GM.getGraphicParam('vtx-g-rang-showRangTool').attributes);
|
|
385
|
+
//删除多余数据,避免other层级太多
|
|
386
|
+
delete rp.other;
|
|
387
|
+
var rcontent = rp.markerContent;
|
|
388
|
+
if (t.rangingTool.points.length > 0) {
|
|
389
|
+
var distance = (0, _MapToolFunction.getDistance)([e.mapPoint.x, e.mapPoint.y], [t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude], t.state.gis, t.grwkid);
|
|
390
|
+
// 实时计算距离
|
|
391
|
+
distance += t.rangingTool.distance;
|
|
392
|
+
var distext = distance > 1000 ? '\u603B\u957F:' + Math.round(distance / 10) / 100 + '\u516C\u91CC' : '\u603B\u957F:' + distance + '\u7C73';
|
|
393
|
+
rcontent = '\n <div class=\'vtx-g-rang-showRangTool\'>\n <div>' + distext + '</div>\n <div>\u5355\u51FB\u786E\u5B9A\u5730\u70B9,\u53CC\u51FB\u7ED3\u675F</div>\n </div>\n ';
|
|
394
|
+
//测距移动的线
|
|
395
|
+
var sl = {
|
|
396
|
+
id: 'vtx-g-rang-showRangTool-line',
|
|
397
|
+
paths: [[t.rangingTool.points[t.rangingTool.points.length - 1].longitude, t.rangingTool.points[t.rangingTool.points.length - 1].latitude], [e.mapPoint.x, e.mapPoint.y]],
|
|
398
|
+
config: {
|
|
399
|
+
color: '#ff0000',
|
|
400
|
+
lineWidth: 2,
|
|
401
|
+
lineType: 'solid',
|
|
402
|
+
pellucidity: 0.5
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
if (!t.GM.getGraphic('vtx-g-rang-showRangTool-line')) {
|
|
406
|
+
t.addLine([sl]);
|
|
407
|
+
} else {
|
|
408
|
+
t.updateLine([sl]);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
rp = _extends({}, rp, {
|
|
412
|
+
longitude: e.mapPoint.x,
|
|
413
|
+
latitude: e.mapPoint.y,
|
|
414
|
+
markerContent: rcontent
|
|
415
|
+
});
|
|
416
|
+
t.updatePoint([rp]);
|
|
417
|
+
}
|
|
418
|
+
//编辑移动
|
|
419
|
+
if (t.editId && t.canMoveLabel) {
|
|
420
|
+
t.mouseNowPosition = _extends({}, t.mouseNowPosition, {
|
|
421
|
+
x: e.mapPoint.x,
|
|
422
|
+
y: e.mapPoint.y
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
//地图双击事件
|
|
427
|
+
t.state.gis.on('dbl-click', function (e) {
|
|
428
|
+
/*测距功能*/
|
|
429
|
+
rangingToolFun(e, 'dbl');
|
|
430
|
+
});
|
|
431
|
+
//地图点击事件
|
|
432
|
+
t.state.gis.on('click', function (e) {
|
|
433
|
+
var t = _this2;
|
|
434
|
+
/*测距功能*/
|
|
435
|
+
rangingToolFun(e);
|
|
436
|
+
//地图点击事件
|
|
437
|
+
t.clickMap(e);
|
|
438
|
+
});
|
|
439
|
+
//鼠标拖拽开始事件
|
|
440
|
+
t.state.gis.on('mouse-drag-start', function (e) {
|
|
441
|
+
t.dragMapStart(e);
|
|
442
|
+
});
|
|
443
|
+
//鼠标拖拽结束事件
|
|
444
|
+
t.state.gis.on('mouse-drag-end', function (e) {
|
|
445
|
+
t.dragMapEnd(e);
|
|
446
|
+
});
|
|
447
|
+
//1.地图移动事件
|
|
448
|
+
t.state.gis.on('pan', function (e) {
|
|
449
|
+
//切换html图层位置
|
|
450
|
+
$('#' + t.htmlPointsId).css({
|
|
451
|
+
top: t.labelLayer.y + e.delta.y,
|
|
452
|
+
left: t.labelLayer.x + e.delta.x
|
|
453
|
+
});
|
|
454
|
+
$('#' + t.pointCollectionId).css({
|
|
455
|
+
top: e.delta.y,
|
|
456
|
+
left: e.delta.x
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
if (t.heatmap) {
|
|
460
|
+
t.heatmap.changeDiv(e.delta.y, e.delta.x);
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
//地图拖动开始
|
|
464
|
+
t.state.gis.on('pan-start', function (e) {
|
|
465
|
+
t.moveStart(e);
|
|
466
|
+
});
|
|
467
|
+
//地图拖动结束
|
|
468
|
+
t.state.gis.on('pan-end', function (e) {
|
|
469
|
+
t.moveEnd(e);
|
|
470
|
+
//聚合点位id存在,则执行聚合运算
|
|
471
|
+
if (t.clusterMarkers.length > 0) {
|
|
472
|
+
t.dealClusterPoint();
|
|
473
|
+
}
|
|
474
|
+
$('#' + t.pointCollectionId).css({
|
|
475
|
+
top: 0,
|
|
476
|
+
left: 0
|
|
477
|
+
});
|
|
478
|
+
//重画海量点
|
|
479
|
+
if (t.morepoints.length > 0) {
|
|
480
|
+
t.updatePointCollection(t.props.mapPointCollection);
|
|
481
|
+
}
|
|
482
|
+
//记录html图层位置
|
|
483
|
+
t.labelLayer = {
|
|
484
|
+
x: eval($('#' + t.htmlPointsId).css('left').replace('px', '')),
|
|
485
|
+
y: eval($('#' + t.htmlPointsId).css('top').replace('px', ''))
|
|
486
|
+
//html点位 根据地图移动和zoom计算位置
|
|
487
|
+
};changeLabel();
|
|
488
|
+
//热力图重绘
|
|
489
|
+
if (t.heatmap) {
|
|
490
|
+
t.heatmap.draw();
|
|
491
|
+
}
|
|
492
|
+
//见需要在顶部显示的图元重新排位置
|
|
493
|
+
for (var i = 0; i < t.zIndexGraphics.length; i++) {
|
|
494
|
+
t.czIndex(t.zIndexGraphics[i]);
|
|
495
|
+
}
|
|
496
|
+
//处理区域限制逻辑
|
|
497
|
+
if (t.areaRestriction) {
|
|
498
|
+
t.dealAreaRestriction(e);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
// 地图zoom开始
|
|
502
|
+
t.state.gis.on('zoom-start', function (e) {
|
|
503
|
+
t.zoomStart(e);
|
|
504
|
+
//隐藏label根节点
|
|
505
|
+
$('#' + t.htmlPointsId).css({ display: 'none' });
|
|
506
|
+
//海量点dom
|
|
507
|
+
$('#' + t.pointCollectionId).css({ display: 'none' });
|
|
508
|
+
if (t.heatmap && !t.isHideHeatMap) {
|
|
509
|
+
t.heatmap.hide();
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
// 地图zoom结束
|
|
513
|
+
t.state.gis.on('zoom-end', function (e) {
|
|
514
|
+
t.zoomEnd(e);
|
|
515
|
+
//聚合点位id存在,则执行聚合运算
|
|
516
|
+
if (t.clusterMarkers.length > 0) {
|
|
517
|
+
t.dealClusterPoint();
|
|
518
|
+
}
|
|
519
|
+
//显示label根节点
|
|
520
|
+
$('#' + t.htmlPointsId).css({ display: 'inline-block' });
|
|
521
|
+
//海量点dom
|
|
522
|
+
$('#' + t.pointCollectionId).css({ display: 'inline-block' });
|
|
523
|
+
//刷新label点位位置
|
|
524
|
+
changeLabel();
|
|
525
|
+
if (t.heatmap && !t.isHideHeatMap) {
|
|
526
|
+
t.heatmap.show();
|
|
527
|
+
t.heatmap.draw();
|
|
528
|
+
}
|
|
529
|
+
//重画海量点
|
|
530
|
+
if (t.morepoints.length > 0) {
|
|
531
|
+
t.updatePointCollection(t.props.mapPointCollection);
|
|
532
|
+
}
|
|
533
|
+
//见需要在顶部显示的图元重新排位置
|
|
534
|
+
for (var i = 0; i < t.zIndexGraphics.length; i++) {
|
|
535
|
+
t.czIndex(t.zIndexGraphics[i]);
|
|
536
|
+
}
|
|
537
|
+
//重新计算比例尺
|
|
538
|
+
if ($('#' + t.props.mapId + '_zoom_slider_show')[0]) {
|
|
539
|
+
var getScale = t.state.gis.getScale() * 0.025399998 / 96;
|
|
540
|
+
//分母系数
|
|
541
|
+
var coefficient = Math.pow(10, Math.floor(getScale).toString().length - 1);
|
|
542
|
+
//判断系数 , 总长度值
|
|
543
|
+
var gs = getScale / coefficient,
|
|
544
|
+
toldis = 1,
|
|
545
|
+
isCent = false;
|
|
546
|
+
//计算比例尺数值和长度
|
|
547
|
+
if (gs < 1) {
|
|
548
|
+
isCent = true;
|
|
549
|
+
gs *= 10;
|
|
550
|
+
}
|
|
551
|
+
if (gs >= 5) {
|
|
552
|
+
toldis = 5 * coefficient * 100;
|
|
553
|
+
} else if (gs >= 2) {
|
|
554
|
+
toldis = 2 * coefficient * 100;
|
|
555
|
+
} else {
|
|
556
|
+
toldis = 1 * coefficient * 100;
|
|
557
|
+
}
|
|
558
|
+
var scaleW = toldis / getScale;
|
|
559
|
+
if (isCent) {
|
|
560
|
+
scaleW /= 10;
|
|
561
|
+
toldis /= 10;
|
|
562
|
+
}
|
|
563
|
+
//宽度矫正处理
|
|
564
|
+
if (scaleW < 50) {
|
|
565
|
+
toldis *= 1.5;
|
|
566
|
+
scaleW = toldis / getScale;
|
|
567
|
+
}
|
|
568
|
+
//处理比例尺值显示
|
|
569
|
+
toldis = toldis >= 1000 ? Math.round(toldis / 1000) + '\u516C\u91CC' : toldis + '\u7C73';
|
|
570
|
+
$('#' + t.props.mapId + '_zoom_slider_show').css({ width: scaleW - 2 });
|
|
571
|
+
$($('#' + t.props.mapId + '_zoom_slider_show').children()[0]).html(toldis);
|
|
572
|
+
}
|
|
573
|
+
});
|
|
574
|
+
//2.图元事件
|
|
575
|
+
//图元点击事件
|
|
576
|
+
t.state.gis.graphics.on('click', function (e) {
|
|
577
|
+
if (!e.graphic.attributes) {
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
var gid = e.graphic.attributes.id;
|
|
581
|
+
//聚合点位不执行 图元事件
|
|
582
|
+
if (gid == 'vtx-clusterPoint') {
|
|
583
|
+
t.setVisiblePoints({ fitView: e.graphic.attributes.ids });
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
t.clickGraphic(gid, e);
|
|
587
|
+
if (_typeof(e.graphic.attributes) == 'object') {
|
|
588
|
+
//点击图元的id
|
|
589
|
+
//判断是否点击的测距关闭点位
|
|
590
|
+
if (gid && gid.indexOf('vtx_g_rang_end') > -1) {
|
|
591
|
+
var index = t.GM.getGraphicParam(gid).attributes.index;
|
|
592
|
+
var ls = t.rangingTools[index].line,
|
|
593
|
+
ps = t.rangingTools[index].points;
|
|
594
|
+
//删除测距线
|
|
595
|
+
t.removeGraphic(ls.id, 'line');
|
|
596
|
+
//删除关闭点
|
|
597
|
+
t.removeGraphic(gid, 'point');
|
|
598
|
+
//删除中间点
|
|
599
|
+
for (var i = 0; i < ps.length; i++) {
|
|
600
|
+
t.removeGraphic(ps[i].id, 'point');
|
|
601
|
+
}
|
|
602
|
+
//清除测距数据缓存
|
|
603
|
+
delete t.rangingTools[index];
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
//图元鼠标移入事件
|
|
608
|
+
t.state.gis.graphics.on('mouse-over', function (e) {
|
|
609
|
+
if (!e.graphic.attributes) {
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
var gid = e.graphic.attributes.id;
|
|
613
|
+
//聚合点位不执行 图元事件
|
|
614
|
+
if (gid == 'vtx-clusterPoint') {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
t.mouseOverGraphic(gid, e);
|
|
618
|
+
});
|
|
619
|
+
//图元鼠标移除事件
|
|
620
|
+
t.state.gis.graphics.on('mouse-out', function (e) {
|
|
621
|
+
if (!e.graphic.attributes) {
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
var gid = e.graphic.attributes.id;
|
|
625
|
+
//聚合点位不执行 图元事件
|
|
626
|
+
if (gid == 'vtx-clusterPoint') {
|
|
627
|
+
return false;
|
|
628
|
+
}
|
|
629
|
+
t.mouseOutGraphic(gid, e);
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
//graphics对象存在 直接处理数据,不存在 通过load事件等待
|
|
633
|
+
if (t.state.gis.graphics) {
|
|
634
|
+
$('#' + t.props.mapId + '_gc').css({ 'z-index': 1 });
|
|
635
|
+
//添加自定义图元 图层
|
|
636
|
+
$('#' + t.props.mapId + '_layers').append('<div id=' + t.htmlPointsId + ' class=\'vtx_gmap_html_points\' ></div>');
|
|
637
|
+
//海量点图元容器
|
|
638
|
+
$('#' + t.props.mapId + '_layers').append('<div id=' + t.pointCollectionId + ' class=\'vtx_gmap_html_pointCollection\' ></div>');
|
|
639
|
+
//隐藏比例尺控制 (便于后期控制显示)
|
|
640
|
+
$('#' + t.props.mapId + '_zoom_slider').css({ display: 'none' });
|
|
641
|
+
//事件监听
|
|
642
|
+
event();
|
|
643
|
+
t.setCenter(t.props.mapCenter);
|
|
644
|
+
//处理数据
|
|
645
|
+
initData();
|
|
646
|
+
}
|
|
647
|
+
t.state.gis.on('load', function () {
|
|
648
|
+
$('#' + t.props.mapId + '_gc').css({ 'z-index': 1 });
|
|
649
|
+
//添加自定义图元 图层
|
|
650
|
+
$('#' + t.props.mapId + '_layers').append('<div id=' + t.htmlPointsId + ' class=\'vtx_gmap_html_points\' ></div>');
|
|
651
|
+
//海量点图元容器
|
|
652
|
+
$('#' + t.props.mapId + '_layers').append('<div id=' + t.pointCollectionId + ' class=\'vtx_gmap_html_pointCollection\' ></div>');
|
|
653
|
+
//隐藏比例尺控制 (便于后期控制显示)
|
|
654
|
+
$('#' + t.props.mapId + '_zoom_slider').css({ display: 'none' });
|
|
655
|
+
//事件监听
|
|
656
|
+
event();
|
|
657
|
+
t.setCenter(t.props.mapCenter);
|
|
658
|
+
//处理数据
|
|
659
|
+
initData();
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
//创建地图 1.gis服务 需要load 2.wmts wms等服务无需load
|
|
663
|
+
|
|
664
|
+
}, {
|
|
665
|
+
key: 'createMap',
|
|
666
|
+
value: function createMap() {
|
|
667
|
+
var t = this;
|
|
668
|
+
var _t$props3 = t.props,
|
|
669
|
+
mapCenter = _t$props3.mapCenter,
|
|
670
|
+
mapId = _t$props3.mapId,
|
|
671
|
+
mapZoomLevel = _t$props3.mapZoomLevel,
|
|
672
|
+
minZoom = _t$props3.minZoom,
|
|
673
|
+
maxZoom = _t$props3.maxZoom,
|
|
674
|
+
mapServer = _t$props3.mapServer;
|
|
675
|
+
|
|
676
|
+
var options = {
|
|
677
|
+
zoom: mapZoomLevel || 10,
|
|
678
|
+
center: mapCenter || [120.404, 30.915]
|
|
679
|
+
};
|
|
680
|
+
if (minZoom) {
|
|
681
|
+
options.minZoom = parseInt(minZoom);
|
|
682
|
+
}
|
|
683
|
+
if (maxZoom) {
|
|
684
|
+
options.maxZoom = parseInt(maxZoom);
|
|
685
|
+
}
|
|
686
|
+
if (!window.VtxMap) {
|
|
687
|
+
window.VtxMap = {};
|
|
688
|
+
}
|
|
689
|
+
var fullExtent = (mapServer || {}).fullExtent || {
|
|
690
|
+
xmin: -180.0, ymin: -90.0, xmax: 180.0, ymax: 90.0
|
|
691
|
+
};
|
|
692
|
+
var map = window.VtxMap[mapId] = t.state.gis = new GMap(t.props.mapId.toString(), _extends({
|
|
693
|
+
autoResize: true,
|
|
694
|
+
logo: false,
|
|
695
|
+
isKeyboardNavigation: false,
|
|
696
|
+
showAttribution: true,
|
|
697
|
+
backgroundColor: '#f1f1f1',
|
|
698
|
+
extent: new esri.geometry.Extent(_extends({}, fullExtent, {
|
|
699
|
+
spatialReference: _defineProperty({}, t.wkidStr, t.wkid)
|
|
700
|
+
}))
|
|
701
|
+
}, options));
|
|
702
|
+
window.onModalResize = function () {
|
|
703
|
+
map.resize(true);
|
|
704
|
+
map.reposition();
|
|
705
|
+
};
|
|
706
|
+
t.addMapLayers(mapServer);
|
|
707
|
+
t.htmlPointsId = mapId + '_' + t.htmlPointsId;
|
|
708
|
+
t.pointCollectionId = mapId + '_' + t.pointCollectionId;
|
|
709
|
+
}
|
|
710
|
+
//处理图层
|
|
711
|
+
|
|
712
|
+
}, {
|
|
713
|
+
key: 'addMapLayers',
|
|
714
|
+
value: function addMapLayers() {
|
|
715
|
+
var mapServer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
716
|
+
|
|
717
|
+
var t = this;
|
|
718
|
+
//清除所有图层服务
|
|
719
|
+
t.state.gis.removeAllLayers();
|
|
720
|
+
var services = [].concat(_toConsumableArray(mapServer.services || [])),
|
|
721
|
+
servs = [];
|
|
722
|
+
for (var im = 0; im < services.length; im++) {
|
|
723
|
+
var url = services[im].url;
|
|
724
|
+
//从新加载图层
|
|
725
|
+
switch (services[im].type) {
|
|
726
|
+
case 'gis':
|
|
727
|
+
for (var i = 0; i < url.length; i++) {
|
|
728
|
+
var basemap = new esri.layers[services[im].gisServer || 'ArcGISTiledMapServiceLayer'](url[i]);
|
|
729
|
+
servs.push(basemap);
|
|
730
|
+
}
|
|
731
|
+
break;
|
|
732
|
+
case 'wmts':
|
|
733
|
+
for (var _i = 0; _i < url.length; _i++) {
|
|
734
|
+
var tileInfo = new esri.layers.TileInfo({
|
|
735
|
+
"dpi": 96,
|
|
736
|
+
"format": services[im].format || "format/png",
|
|
737
|
+
"compressionQuality": 0,
|
|
738
|
+
"spatialReference": new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid || 4326)),
|
|
739
|
+
"rows": 256,
|
|
740
|
+
"cols": 256,
|
|
741
|
+
"origin": mapServer.origin || { x: -180, y: 90 },
|
|
742
|
+
"lods": mapServer.lods || []
|
|
743
|
+
});
|
|
744
|
+
var tileExtent = new esri.geometry.Extent(mapServer.fullExtent.xmin, mapServer.fullExtent.ymin, mapServer.fullExtent.xmax, mapServer.fullExtent.ymax, new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid)));
|
|
745
|
+
var inTileExtent = new esri.geometry.Extent(mapServer.initialExtent.xmin, mapServer.initialExtent.ymin, mapServer.initialExtent.xmax, mapServer.initialExtent.ymax, new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid)));
|
|
746
|
+
var layerInfo = new esri.layers.WMTSLayerInfo({
|
|
747
|
+
tileInfo: tileInfo,
|
|
748
|
+
fullExtent: tileExtent,
|
|
749
|
+
initialExtent: inTileExtent,
|
|
750
|
+
identifier: (services[im].layer || {})[_i] || "SRTM_Color_Index",
|
|
751
|
+
tileMatrixSet: services[im].tilematrixset || "31.25m",
|
|
752
|
+
format: services[im].format || "png",
|
|
753
|
+
style: "default"
|
|
754
|
+
});
|
|
755
|
+
var resourceInfo = {
|
|
756
|
+
version: "1.0.0",
|
|
757
|
+
layerInfos: [layerInfo],
|
|
758
|
+
copyright: ''
|
|
759
|
+
};
|
|
760
|
+
var options = {
|
|
761
|
+
serviceMode: "KVP",
|
|
762
|
+
resourceInfo: resourceInfo,
|
|
763
|
+
layerInfo: layerInfo
|
|
764
|
+
};
|
|
765
|
+
var wmtsLayer = new esri.layers.WMTSLayer(url[_i], options);
|
|
766
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace(wmtsLayer.UrlTemplate.substring(wmtsLayer.UrlTemplate.indexOf('&FORMAT'), wmtsLayer.UrlTemplate.indexOf('&TILEMATRIXSET')), '&FORMAT=' + (services[im].format || 'format/png'));
|
|
767
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('SERVICE', 'service');
|
|
768
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&VERSION', '&version');
|
|
769
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&REQUEST', '&request');
|
|
770
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&LAYER', '&layer');
|
|
771
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&STYLE', '&format');
|
|
772
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&FORMAT', '&style');
|
|
773
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&TILEMATRIXSET', '&tileMatrixSet');
|
|
774
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&TILEMATRIX', '&tileMatrix');
|
|
775
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&TILEROW', '&tileRow');
|
|
776
|
+
wmtsLayer.UrlTemplate = wmtsLayer.UrlTemplate.replace('&TILECOL', '&tileCol');
|
|
777
|
+
servs.push(wmtsLayer);
|
|
778
|
+
}
|
|
779
|
+
break;
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
if (services.length <= 0) {
|
|
783
|
+
console.warn('!warning 图层服务必选,或图层类型暂不支持,默认天地图浙江地理wmts图层服务!');
|
|
784
|
+
for (var _im = 0; _im < _MapToolFunction.defaultWmtsMapLayers.services.length; _im++) {
|
|
785
|
+
var _url = _MapToolFunction.defaultWmtsMapLayers.services[_im].url;
|
|
786
|
+
var dtileInfo = new esri.layers.TileInfo({
|
|
787
|
+
"dpi": 96,
|
|
788
|
+
// "format": "tiles",
|
|
789
|
+
"compressionQuality": 0,
|
|
790
|
+
"spatialReference": new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid || 4326)),
|
|
791
|
+
"rows": 256,
|
|
792
|
+
"cols": 256,
|
|
793
|
+
"origin": _MapToolFunction.defaultWmtsMapLayers.origin || { x: -180, y: 90 },
|
|
794
|
+
"lods": _MapToolFunction.defaultWmtsMapLayers.lods || []
|
|
795
|
+
});
|
|
796
|
+
var dtileExtent = new esri.geometry.Extent(_MapToolFunction.defaultWmtsMapLayers.fullExtent.xmin, _MapToolFunction.defaultWmtsMapLayers.fullExtent.ymin, _MapToolFunction.defaultWmtsMapLayers.fullExtent.xmax, _MapToolFunction.defaultWmtsMapLayers.fullExtent.ymax, new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid)));
|
|
797
|
+
var dinTileExtent = new esri.geometry.Extent(_MapToolFunction.defaultWmtsMapLayers.initialExtent.xmin, _MapToolFunction.defaultWmtsMapLayers.initialExtent.ymin, _MapToolFunction.defaultWmtsMapLayers.initialExtent.xmax, _MapToolFunction.defaultWmtsMapLayers.initialExtent.ymax, new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid)));
|
|
798
|
+
for (var _i2 = 0; _i2 < _url.length; _i2++) {
|
|
799
|
+
var dlayerInfo = new esri.layers.WMTSLayerInfo({
|
|
800
|
+
tileInfo: dtileInfo,
|
|
801
|
+
fullExtent: dtileExtent,
|
|
802
|
+
initialExtent: dinTileExtent,
|
|
803
|
+
identifier: _MapToolFunction.defaultWmtsMapLayers.services[_im].layer[_i2] || "SRTM_Color_Index",
|
|
804
|
+
tileMatrixSet: _MapToolFunction.defaultWmtsMapLayers.services[_im].tilematrixset || "31.25m",
|
|
805
|
+
format: _MapToolFunction.defaultWmtsMapLayers.services[_im].format || "png",
|
|
806
|
+
style: "default"
|
|
807
|
+
});
|
|
808
|
+
var dresourceInfo = {
|
|
809
|
+
version: "1.0.0",
|
|
810
|
+
layerInfos: [dlayerInfo],
|
|
811
|
+
copyright: ''
|
|
812
|
+
};
|
|
813
|
+
var doptions = {
|
|
814
|
+
serviceMode: "KVP",
|
|
815
|
+
resourceInfo: dresourceInfo,
|
|
816
|
+
layerInfo: dlayerInfo
|
|
817
|
+
};
|
|
818
|
+
var _wmtsLayer = new esri.layers.WMTSLayer(_url[_i2], doptions);
|
|
819
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace(_wmtsLayer.UrlTemplate.substr(_wmtsLayer.UrlTemplate.indexOf('&FORMAT='), _wmtsLayer.UrlTemplate.substr(_wmtsLayer.UrlTemplate.indexOf('&FORMAT=') + 1).indexOf('&') + 1), '&FORMAT=' + (_MapToolFunction.defaultWmtsMapLayers.services[_im].format || 'format/png'));
|
|
820
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('SERVICE', 'service');
|
|
821
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&VERSION', '&version');
|
|
822
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&REQUEST', '&request');
|
|
823
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&LAYER', '&layer');
|
|
824
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&STYLE', '&format');
|
|
825
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&FORMAT', '&style');
|
|
826
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&TILEMATRIXSET', '&tileMatrixSet');
|
|
827
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&TILEMATRIX', '&tileMatrix');
|
|
828
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&TILEROW', '&tileRow');
|
|
829
|
+
_wmtsLayer.UrlTemplate = _wmtsLayer.UrlTemplate.replace('&TILECOL', '&tileCol');
|
|
830
|
+
servs.push(_wmtsLayer);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
for (var j = 0; j < servs.length; j++) {
|
|
835
|
+
t.state.gis.addLayer(servs[j]);
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
//新增点位
|
|
839
|
+
|
|
840
|
+
}, {
|
|
841
|
+
key: 'addPoint',
|
|
842
|
+
value: function addPoint(mapPoints, type) {
|
|
843
|
+
var _this3 = this;
|
|
844
|
+
|
|
845
|
+
var t = this;
|
|
846
|
+
var psids = [].concat(_toConsumableArray(t.state.pointIds));
|
|
847
|
+
//添加绘制点
|
|
848
|
+
if (type && type !== 'defined') {
|
|
849
|
+
psids = [].concat(_toConsumableArray(t.state.drawIds[type]));
|
|
850
|
+
}
|
|
851
|
+
mapPoints.map(function (item, index) {
|
|
852
|
+
//如果id重复,直接跳过不执行.
|
|
853
|
+
if (_this3.GM.isRepetition(item.id)) {
|
|
854
|
+
console.warn('\u52A0\u70B9id: ' + item.id + ' \u91CD\u590D');
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
//点位数据不符合,直接跳过
|
|
858
|
+
if (!item.longitude || !item.latitude) {
|
|
859
|
+
console.warn('\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF');
|
|
860
|
+
return false;
|
|
861
|
+
}
|
|
862
|
+
var cg = {
|
|
863
|
+
width: 30,
|
|
864
|
+
height: 30,
|
|
865
|
+
labelContent: '',
|
|
866
|
+
labelPixelX: 0,
|
|
867
|
+
labelPixelY: 34,
|
|
868
|
+
BAnimationType: 3,
|
|
869
|
+
//高德以左上定位,百度以中心为定位
|
|
870
|
+
//默认点的偏移值就不同
|
|
871
|
+
markerContentX: -15,
|
|
872
|
+
markerContentY: -30,
|
|
873
|
+
deg: 0
|
|
874
|
+
};
|
|
875
|
+
if (item.markerContent) {
|
|
876
|
+
cg = _extends({}, cg, { markerContentX: 0, markerContentY: 0, width: 100, height: 30 });
|
|
877
|
+
}
|
|
878
|
+
//初始化默认数据
|
|
879
|
+
if (item.config) {
|
|
880
|
+
cg = _extends({}, cg, item.config);
|
|
881
|
+
}
|
|
882
|
+
//创建arcgis的经纬度对象
|
|
883
|
+
var position = new esri.geometry.Point({
|
|
884
|
+
longitude: item.longitude,
|
|
885
|
+
latitude: item.latitude,
|
|
886
|
+
spatialReference: { wkid: t.grwkid }
|
|
887
|
+
});
|
|
888
|
+
var marker = null,
|
|
889
|
+
label = null;
|
|
890
|
+
if (item.markerContent) {
|
|
891
|
+
//html点位
|
|
892
|
+
//添加透明点(便于事件处理)
|
|
893
|
+
var markerSymbol = new esri.symbol.PictureMarkerSymbol(_default2.default.mapServerURL + '/images/touming.png', cg.width, cg.height);
|
|
894
|
+
//设置偏移点的位置到左上角(原来在中心)
|
|
895
|
+
markerSymbol.setOffset(cg.markerContentX + cg.width / 2, -(cg.markerContentY + cg.height / 2));
|
|
896
|
+
marker = new esri.Graphic(position, markerSymbol, { id: item.id });
|
|
897
|
+
//设置markercontent的数据,用于label加点到地图
|
|
898
|
+
label = {
|
|
899
|
+
html: $(item.markerContent),
|
|
900
|
+
offset: {
|
|
901
|
+
x: cg.markerContentX,
|
|
902
|
+
y: cg.markerContentY
|
|
903
|
+
},
|
|
904
|
+
position: position
|
|
905
|
+
};
|
|
906
|
+
} else {
|
|
907
|
+
//图片点位
|
|
908
|
+
var _markerSymbol = new esri.symbol.PictureMarkerSymbol(item.url || _default2.default.mapServerURL + '/images/defaultMarker.png', cg.width, cg.height);
|
|
909
|
+
_markerSymbol.setAngle(cg.deg);
|
|
910
|
+
//设置偏移点的位置到左上角(原来在中心)
|
|
911
|
+
_markerSymbol.setOffset(cg.markerContentX + cg.width / 2, -(cg.markerContentY + cg.height / 2));
|
|
912
|
+
//点位图元
|
|
913
|
+
marker = new esri.Graphic(position, _markerSymbol, { id: item.id });
|
|
914
|
+
//添加label
|
|
915
|
+
if (item.canShowLabel && cg.labelContent) {
|
|
916
|
+
//label默认样式
|
|
917
|
+
var labelClass = 'label-content';
|
|
918
|
+
//接受label自定义样式
|
|
919
|
+
if (item.labelClass) {
|
|
920
|
+
labelClass = item.labelClass.split(',').join(' ');
|
|
921
|
+
}
|
|
922
|
+
//设置label的数据,用于label加点到地图
|
|
923
|
+
label = {
|
|
924
|
+
html: $('<div style=\'margin-left: 0;z-index: ' + (cg.zIndex || 0) + ';\'>\n <div class=\'' + labelClass + '\'>' + cg.labelContent + '</div>\n </div>'),
|
|
925
|
+
//offset 需要处理 图片点位的位置(将点位偏移和宽度加入计算)
|
|
926
|
+
offset: {
|
|
927
|
+
x: cg.labelPixelX + (cg.markerContentX + cg.width / 2),
|
|
928
|
+
y: cg.labelPixelY + cg.markerContentY
|
|
929
|
+
},
|
|
930
|
+
position: position
|
|
931
|
+
};
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
//点跳动动画
|
|
935
|
+
if (!item.markerContent && cg.BAnimationType == 0) {
|
|
936
|
+
t.pointAnimation(item.id, marker);
|
|
937
|
+
} else {
|
|
938
|
+
t.pointAnimation(item.id, null);
|
|
939
|
+
}
|
|
940
|
+
//添加图元到地图
|
|
941
|
+
t.state.gis.graphics.add(marker);
|
|
942
|
+
//统一处理添加点位 含label和html的添加
|
|
943
|
+
//处理label的加点
|
|
944
|
+
t.dealLabelGraphics(item.id, label);
|
|
945
|
+
//缓存所有点的id
|
|
946
|
+
psids.push(item.id);
|
|
947
|
+
//缓存当前点的图元对象和基本数据
|
|
948
|
+
t.GM.setGraphic(item.id, marker).setGraphicParam(item.id, {
|
|
949
|
+
attributes: _extends({}, item, { other: item }),
|
|
950
|
+
geometryType: 'point',
|
|
951
|
+
geometry: {
|
|
952
|
+
type: 'point',
|
|
953
|
+
x: item.longitude,
|
|
954
|
+
y: item.latitude
|
|
955
|
+
}
|
|
956
|
+
});
|
|
957
|
+
});
|
|
958
|
+
if (type !== 'defined') {
|
|
959
|
+
//添加绘制点
|
|
960
|
+
if (type) {
|
|
961
|
+
t.state.drawIds = _extends({}, t.state.drawIds, _defineProperty({}, type, psids));
|
|
962
|
+
// t.setState({
|
|
963
|
+
// drawIds:{
|
|
964
|
+
// ...t.state.drawIds,
|
|
965
|
+
// [type]: psids
|
|
966
|
+
// }
|
|
967
|
+
// });
|
|
968
|
+
} else {
|
|
969
|
+
t.state.pointIds = psids;
|
|
970
|
+
//所有点缓存在state中
|
|
971
|
+
// t.setState({
|
|
972
|
+
// pointIds: psids
|
|
973
|
+
// });
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
//更新点位
|
|
978
|
+
|
|
979
|
+
}, {
|
|
980
|
+
key: 'updatePoint',
|
|
981
|
+
value: function updatePoint(mapPoints) {
|
|
982
|
+
var _this4 = this;
|
|
983
|
+
|
|
984
|
+
var t = this;
|
|
985
|
+
// let dpoints = [],apoints = [];
|
|
986
|
+
mapPoints.map(function (item, index) {
|
|
987
|
+
//判断图元是否存在.
|
|
988
|
+
if (_this4.GM.isRepetition(item.id)) {
|
|
989
|
+
//点位数据不符合,直接跳过
|
|
990
|
+
if (!item.longitude || !item.latitude) {
|
|
991
|
+
console.warn('\u70B9 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF');
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
//获取原有的图元
|
|
995
|
+
var gc = t.GM.getGraphic(item.id);
|
|
996
|
+
var cg = {
|
|
997
|
+
width: 30,
|
|
998
|
+
height: 30,
|
|
999
|
+
labelContent: '',
|
|
1000
|
+
labelPixelX: 0,
|
|
1001
|
+
labelPixelY: 34,
|
|
1002
|
+
BAnimationType: 3,
|
|
1003
|
+
//高德以左上定位,百度以中心为定位
|
|
1004
|
+
//默认点的偏移值就不同
|
|
1005
|
+
markerContentX: -15,
|
|
1006
|
+
markerContentY: -30,
|
|
1007
|
+
deg: 0
|
|
1008
|
+
};
|
|
1009
|
+
if (item.markerContent) {
|
|
1010
|
+
cg = _extends({}, cg, { markerContentX: 0, markerContentY: 0, width: 100, height: 30 });
|
|
1011
|
+
}
|
|
1012
|
+
if (item.config) {
|
|
1013
|
+
cg = _extends({}, cg, item.config);
|
|
1014
|
+
}
|
|
1015
|
+
//创建arcgis的经纬度对象
|
|
1016
|
+
var position = new esri.geometry.Point({
|
|
1017
|
+
longitude: item.longitude,
|
|
1018
|
+
latitude: item.latitude,
|
|
1019
|
+
spatialReference: { wkid: t.grwkid }
|
|
1020
|
+
});
|
|
1021
|
+
//label对象
|
|
1022
|
+
var label = null;
|
|
1023
|
+
if (item.markerContent) {
|
|
1024
|
+
//symbol 样式信息修改
|
|
1025
|
+
if (gc.symbol) {
|
|
1026
|
+
gc.symbol.setUrl(_default2.default.mapServerURL + '/images/touming.png');
|
|
1027
|
+
}
|
|
1028
|
+
//设置markercontent的数据,用于label加点到地图
|
|
1029
|
+
label = {
|
|
1030
|
+
html: $(item.markerContent),
|
|
1031
|
+
offset: {
|
|
1032
|
+
x: cg.markerContentX,
|
|
1033
|
+
y: cg.markerContentY
|
|
1034
|
+
},
|
|
1035
|
+
position: position
|
|
1036
|
+
};
|
|
1037
|
+
} else {
|
|
1038
|
+
//symbol 样式信息修改
|
|
1039
|
+
if (gc.symbol) {
|
|
1040
|
+
gc.symbol.setUrl(item.url || _default2.default.mapServerURL + '/images/defaultMarker.png');
|
|
1041
|
+
}
|
|
1042
|
+
gc.symbol.setAngle(cg.deg);
|
|
1043
|
+
//添加label
|
|
1044
|
+
if (item.canShowLabel && cg.labelContent) {
|
|
1045
|
+
//label默认样式
|
|
1046
|
+
var labelClass = 'label-content';
|
|
1047
|
+
//接受label自定义样式
|
|
1048
|
+
if (item.labelClass) {
|
|
1049
|
+
labelClass = item.labelClass.split(',').join(' ');
|
|
1050
|
+
}
|
|
1051
|
+
//设置label的数据,用于label加点到地图
|
|
1052
|
+
label = {
|
|
1053
|
+
html: $('<div style=\'margin-left: 0;\'>\n <div class=\'' + labelClass + '\'>' + cg.labelContent + '</div>\n </div>'),
|
|
1054
|
+
//offset 需要处理 图片点位的位置(将点位偏移和宽度加入计算)
|
|
1055
|
+
offset: {
|
|
1056
|
+
x: cg.labelPixelX + (cg.markerContentX + cg.width / 2),
|
|
1057
|
+
y: cg.labelPixelY + cg.markerContentY
|
|
1058
|
+
},
|
|
1059
|
+
position: position
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
//symbol 样式信息修改
|
|
1064
|
+
if (gc.symbol) {
|
|
1065
|
+
gc.symbol.setOffset(cg.markerContentX + cg.width / 2, -(cg.markerContentY + cg.height / 2));
|
|
1066
|
+
gc.symbol.setWidth(cg.width);
|
|
1067
|
+
gc.symbol.setHeight(cg.height);
|
|
1068
|
+
}
|
|
1069
|
+
//点位动画效果
|
|
1070
|
+
if (!item.markerContent && cg.BAnimationType == 0) {
|
|
1071
|
+
t.pointAnimation(item.id, gc);
|
|
1072
|
+
} else {
|
|
1073
|
+
t.pointAnimation(item.id, null);
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
//动画效果会延迟执行经纬度的切换
|
|
1077
|
+
if (cg.isAnimation) {
|
|
1078
|
+
t.moveTo(item.id, [item.longitude, item.latitude], cg.animationDelay, cg.autoRotation, item.url, item.urlleft);
|
|
1079
|
+
} else {
|
|
1080
|
+
//gometry 位置信息修改
|
|
1081
|
+
if (gc.geometry) {
|
|
1082
|
+
// gc.geometry.setLatitude(item.latitude);
|
|
1083
|
+
// gc.geometry.setLongitude(item.longitude);
|
|
1084
|
+
gc.setGeometry(position);
|
|
1085
|
+
//设置完点位后 需要刷新下点位的显示范围
|
|
1086
|
+
gc._extent.update(item.longitude, item.latitude, item.longitude, item.latitude, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
1087
|
+
if (gc._extent._parts && gc._extent._parts[0]) {
|
|
1088
|
+
gc._extent._parts[0].extent.update(item.longitude, item.latitude, item.longitude, item.latitude, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
1089
|
+
}
|
|
1090
|
+
// gc._extent.update(new esri.geometry.Extent(item.longitude,item.latitude,item.longitude,item.latitude,{ wkid: t.grwkid }));
|
|
1091
|
+
// gc._extent._parts[0].extent = gc._extent.centerAt(position);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
//删除原有的label 下面从新加载
|
|
1095
|
+
if (t.Label[item.id]) {
|
|
1096
|
+
t.Label[item.id].html.remove();
|
|
1097
|
+
}
|
|
1098
|
+
//刷新点位
|
|
1099
|
+
t.dealLabelGraphics(item.id, label);
|
|
1100
|
+
//刷新缓存数据
|
|
1101
|
+
t.GM.setGraphicParam(item.id, {
|
|
1102
|
+
attributes: _extends({}, item, { other: item }),
|
|
1103
|
+
geometryType: 'point',
|
|
1104
|
+
geometry: {
|
|
1105
|
+
type: 'point',
|
|
1106
|
+
x: item.longitude,
|
|
1107
|
+
y: item.latitude
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
} else {
|
|
1111
|
+
console.warn('\u66F4\u65B0\u7684\u70B9\u4F4Did\u4E0D\u5B58\u5728!');
|
|
1112
|
+
return false;
|
|
1113
|
+
}
|
|
1114
|
+
});
|
|
1115
|
+
t.state.gis.graphics.refresh();
|
|
1116
|
+
t.moveAnimation();
|
|
1117
|
+
}
|
|
1118
|
+
//添加线
|
|
1119
|
+
|
|
1120
|
+
}, {
|
|
1121
|
+
key: 'addLine',
|
|
1122
|
+
value: function addLine(mapLines, type) {
|
|
1123
|
+
var t = this;
|
|
1124
|
+
var lsids = [].concat(_toConsumableArray(t.state.lineIds));
|
|
1125
|
+
if (type && type !== 'defined') {
|
|
1126
|
+
lsids = [].concat(_toConsumableArray(t.state.drawIds[type]));
|
|
1127
|
+
}
|
|
1128
|
+
//遍历添加线(图元)
|
|
1129
|
+
mapLines.map(function (item, index) {
|
|
1130
|
+
//如果id重复,直接跳过不执行.
|
|
1131
|
+
if (t.GM.isRepetition(item.id)) {
|
|
1132
|
+
console.warn('\u591A\u6298\u7EBFid: ' + item.id + ' \u91CD\u590D');
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1135
|
+
//多折线点位数据不符合,直接跳过
|
|
1136
|
+
if (!(item.paths && item.paths.length >= 2)) {
|
|
1137
|
+
console.warn('\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF');
|
|
1138
|
+
return false;
|
|
1139
|
+
}
|
|
1140
|
+
//初始化默认参数
|
|
1141
|
+
var cg = {
|
|
1142
|
+
color: '#277ffa',
|
|
1143
|
+
pellucidity: 0.9,
|
|
1144
|
+
lineWidth: 5,
|
|
1145
|
+
lineType: 'solid',
|
|
1146
|
+
isHidden: false
|
|
1147
|
+
//合并参数
|
|
1148
|
+
};if (item.config) {
|
|
1149
|
+
cg = _extends({}, cg, item.config);
|
|
1150
|
+
}
|
|
1151
|
+
//处理线的点数组
|
|
1152
|
+
var linePath = new esri.geometry.Polyline({
|
|
1153
|
+
paths: [[].concat(_toConsumableArray(item.paths))],
|
|
1154
|
+
spatialReference: { wkid: t.grwkid }
|
|
1155
|
+
});
|
|
1156
|
+
//线类型
|
|
1157
|
+
var style = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1158
|
+
switch (cg.lineType) {
|
|
1159
|
+
case 'solid':
|
|
1160
|
+
style = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1161
|
+
break;
|
|
1162
|
+
case 'dashed':
|
|
1163
|
+
style = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
1164
|
+
break;
|
|
1165
|
+
}
|
|
1166
|
+
//处理颜色和透明度 使用rgba处理透明度
|
|
1167
|
+
var color = new esri.Color(cg.color);
|
|
1168
|
+
color.a = cg.pellucidity;
|
|
1169
|
+
//线类型对象
|
|
1170
|
+
var lineSymbol = new esri.symbol.SimpleLineSymbol(style, color, cg.lineWidth);
|
|
1171
|
+
//创建线对象
|
|
1172
|
+
var line = new esri.Graphic(linePath, lineSymbol, { id: item.id });
|
|
1173
|
+
//判断线显示和隐藏
|
|
1174
|
+
if (cg.isHidden) {
|
|
1175
|
+
line.hide();
|
|
1176
|
+
} else {
|
|
1177
|
+
line.show();
|
|
1178
|
+
}
|
|
1179
|
+
lsids.push(item.id);
|
|
1180
|
+
//添加线图元
|
|
1181
|
+
t.state.gis.graphics.add(line);
|
|
1182
|
+
//处理线缓存
|
|
1183
|
+
t.GM.setGraphic(item.id, line).setGraphicParam(item.id, {
|
|
1184
|
+
attributes: _extends({}, item, {
|
|
1185
|
+
paths: item.paths,
|
|
1186
|
+
other: item
|
|
1187
|
+
}),
|
|
1188
|
+
geometryType: 'polyline',
|
|
1189
|
+
geometry: {
|
|
1190
|
+
type: 'polyline',
|
|
1191
|
+
paths: item.paths
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1194
|
+
});
|
|
1195
|
+
if (type !== 'defined') {
|
|
1196
|
+
//添加绘制点
|
|
1197
|
+
if (type) {
|
|
1198
|
+
t.state.drawIds = _extends({}, t.state.drawIds, _defineProperty({}, type, lsids));
|
|
1199
|
+
// t.setState({
|
|
1200
|
+
// drawIds:{
|
|
1201
|
+
// ...t.state.drawIds,
|
|
1202
|
+
// [type]: lsids
|
|
1203
|
+
// }
|
|
1204
|
+
// });
|
|
1205
|
+
} else {
|
|
1206
|
+
t.state.lineIds = lsids;
|
|
1207
|
+
// t.setState({
|
|
1208
|
+
// lineIds: lsids
|
|
1209
|
+
// });
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
//更新线
|
|
1214
|
+
|
|
1215
|
+
}, {
|
|
1216
|
+
key: 'updateLine',
|
|
1217
|
+
value: function updateLine(mapLines) {
|
|
1218
|
+
var t = this;
|
|
1219
|
+
//遍历添加线(图元)
|
|
1220
|
+
mapLines.map(function (item, index) {
|
|
1221
|
+
//判断图元是否存在.
|
|
1222
|
+
if (t.GM.isRepetition(item.id)) {
|
|
1223
|
+
//多折线点位数据不符合,直接跳过
|
|
1224
|
+
if (!(item.paths && item.paths.length >= 2)) {
|
|
1225
|
+
console.warn('\u591A\u6298\u7EBFpaths\u6570\u636E\u9519\u8BEF');
|
|
1226
|
+
return false;
|
|
1227
|
+
}
|
|
1228
|
+
} else {
|
|
1229
|
+
console.warn('\u66F4\u65B0\u7684\u591A\u6298\u7EBFid\u4E0D\u5B58\u5728!');
|
|
1230
|
+
return false;
|
|
1231
|
+
}
|
|
1232
|
+
var gc = t.GM.getGraphic(item.id);
|
|
1233
|
+
//初始化默认参数
|
|
1234
|
+
var cg = {
|
|
1235
|
+
color: '#277ffa',
|
|
1236
|
+
pellucidity: 0.9,
|
|
1237
|
+
lineWidth: 5,
|
|
1238
|
+
lineType: 'solid', //'solid' 'dashed'
|
|
1239
|
+
isHidden: false
|
|
1240
|
+
//合并参数
|
|
1241
|
+
};if (item.config) {
|
|
1242
|
+
cg = _extends({}, cg, item.config);
|
|
1243
|
+
}
|
|
1244
|
+
//删除原来的点位
|
|
1245
|
+
gc.geometry.removePath(0);
|
|
1246
|
+
//添加新的点位
|
|
1247
|
+
gc.geometry.addPath([].concat(_toConsumableArray(item.paths)));
|
|
1248
|
+
|
|
1249
|
+
var _t$dealData = t.dealData(item.paths),
|
|
1250
|
+
_extent = _t$dealData._extent;
|
|
1251
|
+
//设置完点位后 需要刷新下点位的显示范围/
|
|
1252
|
+
|
|
1253
|
+
|
|
1254
|
+
gc._extent.update(_extent.longitude, _extent.latitude, _extent.longitude, _extent.latitude, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
1255
|
+
// gc._extent.update(new esri.geometry.Extent(_extent.xmin,_extent.ymin,_extent.xmax,_extent.ymax,{ wkid: t.grwkid }));
|
|
1256
|
+
// gc._extent._parts[0].extent = {...gc._extent._parts[0].extent,..._extent};
|
|
1257
|
+
//处理颜色和透明度 使用rgba处理透明度
|
|
1258
|
+
var color = new esri.Color(cg.color);
|
|
1259
|
+
color.a = cg.pellucidity;
|
|
1260
|
+
gc.symbol.setColor(color);
|
|
1261
|
+
//设置线类型
|
|
1262
|
+
var style = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1263
|
+
switch (cg.lineType) {
|
|
1264
|
+
case 'solid':
|
|
1265
|
+
style = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1266
|
+
break;
|
|
1267
|
+
case 'dashed':
|
|
1268
|
+
style = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
1269
|
+
break;
|
|
1270
|
+
}
|
|
1271
|
+
gc.symbol.setStyle(style);
|
|
1272
|
+
//设置线宽
|
|
1273
|
+
gc.symbol.setWidth(cg.lineWidth);
|
|
1274
|
+
//判断线显示和隐藏
|
|
1275
|
+
if (cg.isHidden) {
|
|
1276
|
+
gc.hide();
|
|
1277
|
+
} else {
|
|
1278
|
+
gc.show();
|
|
1279
|
+
}
|
|
1280
|
+
t.GM.setGraphicParam(item.id, {
|
|
1281
|
+
attributes: _extends({}, item, {
|
|
1282
|
+
paths: item.paths,
|
|
1283
|
+
other: item
|
|
1284
|
+
}),
|
|
1285
|
+
geometryType: 'polyline',
|
|
1286
|
+
geometry: {
|
|
1287
|
+
type: 'polyline',
|
|
1288
|
+
paths: item.paths
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
});
|
|
1292
|
+
//刷新图元
|
|
1293
|
+
t.state.gis.graphics.refresh();
|
|
1294
|
+
}
|
|
1295
|
+
//添加面
|
|
1296
|
+
|
|
1297
|
+
}, {
|
|
1298
|
+
key: 'addPolygon',
|
|
1299
|
+
value: function addPolygon(mapPolygons, type) {
|
|
1300
|
+
var t = this;
|
|
1301
|
+
var pgsids = [].concat(_toConsumableArray(t.state.polygonIds));
|
|
1302
|
+
if (type) {
|
|
1303
|
+
pgsids = [].concat(_toConsumableArray(t.state.drawIds[type]));
|
|
1304
|
+
}
|
|
1305
|
+
//遍历添加面(图元)
|
|
1306
|
+
mapPolygons.map(function (item, index) {
|
|
1307
|
+
//如果id重复,直接跳过不执行.
|
|
1308
|
+
if (t.GM.isRepetition(item.id)) {
|
|
1309
|
+
console.warn('\u591A\u8FB9\u5F62id: ' + item.id + ' \u91CD\u590D');
|
|
1310
|
+
return false;
|
|
1311
|
+
}
|
|
1312
|
+
//多边形点位数据不符合,直接跳过
|
|
1313
|
+
if (!(item.rings && item.rings.length >= 3)) {
|
|
1314
|
+
console.warn('\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF');
|
|
1315
|
+
return false;
|
|
1316
|
+
}
|
|
1317
|
+
//初始化参数
|
|
1318
|
+
var cg = {
|
|
1319
|
+
lineType: 'solid',
|
|
1320
|
+
lineWidth: 5,
|
|
1321
|
+
lineColor: '#277ffa',
|
|
1322
|
+
lineOpacity: 1,
|
|
1323
|
+
color: '#fff',
|
|
1324
|
+
pellucidity: 0.5
|
|
1325
|
+
// isHidden: false //后期需要再加
|
|
1326
|
+
};
|
|
1327
|
+
if (item.config) {
|
|
1328
|
+
cg = _extends({}, cg, item.config);
|
|
1329
|
+
}
|
|
1330
|
+
var rings = [].concat(_toConsumableArray(item.rings));
|
|
1331
|
+
if (item.rings[0][0] != item.rings[item.rings.length - 1][0] || item.rings[0][1] != item.rings[item.rings.length - 1][1]) {
|
|
1332
|
+
rings = [].concat(_toConsumableArray(rings), [item.rings[0]]);
|
|
1333
|
+
}
|
|
1334
|
+
//处理面的点数据
|
|
1335
|
+
var polygonPath = esri.geometry.Polygon({
|
|
1336
|
+
//添加最后一个点,使面闭合
|
|
1337
|
+
rings: [rings],
|
|
1338
|
+
spatialReference: { wkid: t.grwkid }
|
|
1339
|
+
});
|
|
1340
|
+
//线类型
|
|
1341
|
+
var lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1342
|
+
switch (cg.lineType) {
|
|
1343
|
+
case 'solid':
|
|
1344
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1345
|
+
break;
|
|
1346
|
+
case 'dashed':
|
|
1347
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
1348
|
+
break;
|
|
1349
|
+
}
|
|
1350
|
+
//处理边框线颜色和透明度 使用rgba处理透明度
|
|
1351
|
+
var lineColor = new esri.Color(cg.lineColor);
|
|
1352
|
+
lineColor.a = cg.lineOpacity;
|
|
1353
|
+
//生成线类型对象
|
|
1354
|
+
var lineSymbol = new esri.symbol.SimpleLineSymbol(lineStyle, lineColor, cg.lineWidth);
|
|
1355
|
+
//创建面对象
|
|
1356
|
+
var polygonSymbol = new esri.symbol.SimpleFillSymbol();
|
|
1357
|
+
//添加边框线数据
|
|
1358
|
+
polygonSymbol.setOutline(lineSymbol);
|
|
1359
|
+
//处理填充颜色和透明度 使用rgba处理透明度
|
|
1360
|
+
var polygonColor = new esri.Color(cg.color);
|
|
1361
|
+
polygonColor.a = cg.pellucidity;
|
|
1362
|
+
polygonSymbol.setColor(polygonColor);
|
|
1363
|
+
//创建面对象
|
|
1364
|
+
var polygon = new esri.Graphic(polygonPath, polygonSymbol, { id: item.id });
|
|
1365
|
+
//添加面图元
|
|
1366
|
+
t.state.gis.graphics.add(polygon);
|
|
1367
|
+
//缓存面id
|
|
1368
|
+
pgsids.push(item.id);
|
|
1369
|
+
//缓存面图元对象和对于传入数据
|
|
1370
|
+
t.GM.setGraphic(item.id, polygon).setGraphicParam(item.id, {
|
|
1371
|
+
attributes: _extends({}, item, {
|
|
1372
|
+
rings: item.rings,
|
|
1373
|
+
other: item
|
|
1374
|
+
}),
|
|
1375
|
+
geometryType: 'polygon',
|
|
1376
|
+
geometry: {
|
|
1377
|
+
type: 'polygon',
|
|
1378
|
+
rings: item.rings
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
});
|
|
1382
|
+
//添加绘制点
|
|
1383
|
+
if (type) {
|
|
1384
|
+
t.state.drawIds = _extends({}, t.state.drawIds, _defineProperty({}, type, pgsids));
|
|
1385
|
+
// t.setState({
|
|
1386
|
+
// drawIds:{
|
|
1387
|
+
// ...t.state.drawIds,
|
|
1388
|
+
// [type]: pgsids
|
|
1389
|
+
// }
|
|
1390
|
+
// });
|
|
1391
|
+
} else {
|
|
1392
|
+
t.state.polygonIds = pgsids;
|
|
1393
|
+
// t.setState({
|
|
1394
|
+
// polygonIds: pgsids
|
|
1395
|
+
// });
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
//更新面
|
|
1399
|
+
|
|
1400
|
+
}, {
|
|
1401
|
+
key: 'updatePolygon',
|
|
1402
|
+
value: function updatePolygon(mapPolygons) {
|
|
1403
|
+
var t = this;
|
|
1404
|
+
mapPolygons.map(function (item, index) {
|
|
1405
|
+
//判断图元是否存在.
|
|
1406
|
+
if (t.GM.isRepetition(item.id)) {
|
|
1407
|
+
//多边形点位数据不符合,直接跳过
|
|
1408
|
+
if (!(item.rings && item.rings.length >= 3)) {
|
|
1409
|
+
console.warn('\u591A\u8FB9\u5F62rings\u6570\u636E\u9519\u8BEF');
|
|
1410
|
+
return false;
|
|
1411
|
+
}
|
|
1412
|
+
} else {
|
|
1413
|
+
console.warn('\u66F4\u65B0\u7684\u591A\u8FB9\u5F62id\u4E0D\u5B58\u5728!');
|
|
1414
|
+
return false;
|
|
1415
|
+
}
|
|
1416
|
+
//获取原有的图元
|
|
1417
|
+
var gc = t.GM.getGraphic(item.id);
|
|
1418
|
+
//初始化参数
|
|
1419
|
+
var cg = {
|
|
1420
|
+
lineType: 'solid',
|
|
1421
|
+
lineWidth: 5,
|
|
1422
|
+
lineColor: '#277ffa',
|
|
1423
|
+
lineOpacity: 1,
|
|
1424
|
+
color: '#fff',
|
|
1425
|
+
pellucidity: 0.5
|
|
1426
|
+
// isHidden: false //后期需要再加
|
|
1427
|
+
};
|
|
1428
|
+
if (item.config) {
|
|
1429
|
+
cg = _extends({}, cg, item.config);
|
|
1430
|
+
}
|
|
1431
|
+
//删除原来的点位
|
|
1432
|
+
gc.geometry.removeRing(0);
|
|
1433
|
+
var rings = [].concat(_toConsumableArray(item.rings));
|
|
1434
|
+
if (item.rings[0][0] != item.rings[item.rings.length - 1][0] || item.rings[0][1] != item.rings[item.rings.length - 1][1]) {
|
|
1435
|
+
rings = [].concat(_toConsumableArray(rings), [item.rings[0]]);
|
|
1436
|
+
}
|
|
1437
|
+
//添加新的点位
|
|
1438
|
+
gc.geometry.addRing(rings);
|
|
1439
|
+
|
|
1440
|
+
var _t$dealData2 = t.dealData(item.rings),
|
|
1441
|
+
_extent = _t$dealData2._extent;
|
|
1442
|
+
//设置完点位后 需要刷新下点位的显示范围
|
|
1443
|
+
|
|
1444
|
+
|
|
1445
|
+
gc._extent.update(_extent.xmin, _extent.ymin, _extent.xmax, _extent.ymax, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
1446
|
+
// gc._extent.update(new esri.geometry.Extent(_extent.xmin,_extent.ymin,_extent.xmax,_extent.ymax,{ wkid: t.grwkid }));
|
|
1447
|
+
// gc._extent._parts[0].extent = {...gc._extent._parts[0].extent,..._extent};
|
|
1448
|
+
|
|
1449
|
+
//线类型
|
|
1450
|
+
var lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1451
|
+
switch (cg.lineType) {
|
|
1452
|
+
case 'solid':
|
|
1453
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1454
|
+
break;
|
|
1455
|
+
case 'dashed':
|
|
1456
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
gc.symbol.outline.setStyle(lineStyle);
|
|
1460
|
+
//处理边框线颜色和透明度 使用rgba处理透明度
|
|
1461
|
+
var lineColor = new esri.Color(cg.lineColor);
|
|
1462
|
+
lineColor.a = cg.lineOpacity;
|
|
1463
|
+
gc.symbol.outline.setColor(lineColor);
|
|
1464
|
+
//设置线宽
|
|
1465
|
+
gc.symbol.outline.setWidth(cg.lineWidth);
|
|
1466
|
+
//处理填充颜色和透明度 使用rgba处理透明度
|
|
1467
|
+
var polygonColor = new esri.Color(cg.color);
|
|
1468
|
+
polygonColor.a = cg.pellucidity;
|
|
1469
|
+
gc.symbol.setColor(polygonColor);
|
|
1470
|
+
t.GM.setGraphicParam(item.id, {
|
|
1471
|
+
attributes: _extends({}, item, {
|
|
1472
|
+
rings: item.rings,
|
|
1473
|
+
other: item
|
|
1474
|
+
}),
|
|
1475
|
+
geometryType: 'polygon',
|
|
1476
|
+
geometry: {
|
|
1477
|
+
type: 'polygon',
|
|
1478
|
+
rings: item.rings
|
|
1479
|
+
}
|
|
1480
|
+
});
|
|
1481
|
+
});
|
|
1482
|
+
//刷新图元
|
|
1483
|
+
t.state.gis.graphics.refresh();
|
|
1484
|
+
}
|
|
1485
|
+
//添加圆 circle
|
|
1486
|
+
|
|
1487
|
+
}, {
|
|
1488
|
+
key: 'addCircle',
|
|
1489
|
+
value: function addCircle(mapCircles, type) {
|
|
1490
|
+
var t = this;
|
|
1491
|
+
var ccsids = [].concat(_toConsumableArray(t.state.circleIds));
|
|
1492
|
+
if (type) {
|
|
1493
|
+
ccsids = [].concat(_toConsumableArray(t.state.drawIds[type]));
|
|
1494
|
+
}
|
|
1495
|
+
mapCircles.map(function (item, index) {
|
|
1496
|
+
//如果id重复,直接跳过不执行.
|
|
1497
|
+
if (t.GM.isRepetition(item.id)) {
|
|
1498
|
+
console.warn('\u5706id: ' + item.id + ' \u91CD\u590D');
|
|
1499
|
+
return false;
|
|
1500
|
+
}
|
|
1501
|
+
//圆 点位数据不符合,直接跳过
|
|
1502
|
+
if (!item.longitude || !item.latitude) {
|
|
1503
|
+
console.warn('\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF');
|
|
1504
|
+
return false;
|
|
1505
|
+
}
|
|
1506
|
+
var cg = {
|
|
1507
|
+
lineType: 'solid',
|
|
1508
|
+
lineWidth: 5,
|
|
1509
|
+
lineColor: '#277ffa',
|
|
1510
|
+
lineOpacity: 1,
|
|
1511
|
+
color: '#fff',
|
|
1512
|
+
pellucidity: 0.5
|
|
1513
|
+
// isHidden: false //后期需要在加
|
|
1514
|
+
};
|
|
1515
|
+
if (item.config) {
|
|
1516
|
+
cg = _extends({}, cg, item.config);
|
|
1517
|
+
}
|
|
1518
|
+
var center = new esri.geometry.Point(parseFloat(item.longitude), parseFloat(item.latitude));
|
|
1519
|
+
//创建圆 位置对象
|
|
1520
|
+
var position = new esri.geometry.Circle({ center: center, radius: parseFloat(item.radius) });
|
|
1521
|
+
//线类型
|
|
1522
|
+
var lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1523
|
+
switch (cg.lineType) {
|
|
1524
|
+
case 'solid':
|
|
1525
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1526
|
+
break;
|
|
1527
|
+
case 'dashed':
|
|
1528
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
//处理边框线颜色和透明度 使用rgba处理透明度
|
|
1532
|
+
var lineColor = new esri.Color(cg.lineColor);
|
|
1533
|
+
lineColor.a = cg.lineOpacity;
|
|
1534
|
+
//生成线类型对象
|
|
1535
|
+
var lineSymbol = new esri.symbol.SimpleLineSymbol(lineStyle, lineColor, parseFloat(cg.lineWidth));
|
|
1536
|
+
//创建面对象
|
|
1537
|
+
var circleSymbol = new esri.symbol.SimpleFillSymbol();
|
|
1538
|
+
//添加边框线数据
|
|
1539
|
+
circleSymbol.setOutline(lineSymbol);
|
|
1540
|
+
//处理填充颜色和透明度 使用rgba处理透明度
|
|
1541
|
+
var circleColor = new esri.Color(cg.color);
|
|
1542
|
+
circleColor.a = cg.pellucidity;
|
|
1543
|
+
circleSymbol.setColor(circleColor);
|
|
1544
|
+
//创建圆对象
|
|
1545
|
+
var circle = new esri.Graphic(position, circleSymbol, { id: item.id });
|
|
1546
|
+
//添加图元对象
|
|
1547
|
+
t.state.gis.graphics.add(circle);
|
|
1548
|
+
//缓存数据
|
|
1549
|
+
ccsids.push(item.id);
|
|
1550
|
+
t.GM.setGraphic(item.id, circle).setGraphicParam(item.id, {
|
|
1551
|
+
attributes: _extends({}, item, { other: item }),
|
|
1552
|
+
geometryType: 'circle',
|
|
1553
|
+
geometry: {
|
|
1554
|
+
type: 'circle',
|
|
1555
|
+
x: parseFloat(item.longitude),
|
|
1556
|
+
y: parseFloat(item.latitude),
|
|
1557
|
+
radius: parseFloat(item.radius)
|
|
1558
|
+
}
|
|
1559
|
+
});
|
|
1560
|
+
});
|
|
1561
|
+
//添加绘制点
|
|
1562
|
+
if (type) {
|
|
1563
|
+
t.state.drawIds = _extends({}, t.state.drawIds, _defineProperty({}, type, ccsids));
|
|
1564
|
+
// t.setState({
|
|
1565
|
+
// drawIds:{
|
|
1566
|
+
// ...t.state.drawIds,
|
|
1567
|
+
// [type]: ccsids
|
|
1568
|
+
// }
|
|
1569
|
+
// });
|
|
1570
|
+
} else {
|
|
1571
|
+
t.state.circleIds = ccsids;
|
|
1572
|
+
// t.setState({
|
|
1573
|
+
// circleIds: ccsids
|
|
1574
|
+
// });
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
//更新圆
|
|
1578
|
+
|
|
1579
|
+
}, {
|
|
1580
|
+
key: 'updateCircle',
|
|
1581
|
+
value: function updateCircle(mapCircles) {
|
|
1582
|
+
var t = this;
|
|
1583
|
+
mapCircles.map(function (item, index) {
|
|
1584
|
+
//判断图元是否存在.
|
|
1585
|
+
if (t.GM.isRepetition(item.id)) {
|
|
1586
|
+
//圆 点位数据不符合,直接跳过
|
|
1587
|
+
if (!item.longitude || !item.latitude) {
|
|
1588
|
+
console.warn('\u5706 \u7ECF\u7EAC\u5EA6 \u6570\u636E\u9519\u8BEF');
|
|
1589
|
+
return false;
|
|
1590
|
+
}
|
|
1591
|
+
} else {
|
|
1592
|
+
console.warn('\u66F4\u65B0\u7684\u5706id\u4E0D\u5B58\u5728!');
|
|
1593
|
+
return false;
|
|
1594
|
+
}
|
|
1595
|
+
//获取原有的图元
|
|
1596
|
+
var gc = t.GM.getGraphic(item.id);
|
|
1597
|
+
//获取原有的面属性,转换key值
|
|
1598
|
+
var cg = {
|
|
1599
|
+
lineType: 'solid',
|
|
1600
|
+
lineWidth: 5,
|
|
1601
|
+
lineColor: '#277ffa',
|
|
1602
|
+
lineOpacity: 1,
|
|
1603
|
+
color: '#fff',
|
|
1604
|
+
pellucidity: 0.5
|
|
1605
|
+
// isHidden: false //后期需要在加
|
|
1606
|
+
};
|
|
1607
|
+
if (item.config) {
|
|
1608
|
+
cg = _extends({}, cg, item.config);
|
|
1609
|
+
}
|
|
1610
|
+
var center = new esri.geometry.Point(parseFloat(item.longitude), parseFloat(item.latitude));
|
|
1611
|
+
//创建圆 位置对象
|
|
1612
|
+
var position = new esri.geometry.Circle({ center: center, radius: parseFloat(item.radius) });
|
|
1613
|
+
//线类型
|
|
1614
|
+
var lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1615
|
+
switch (cg.lineType) {
|
|
1616
|
+
case 'solid':
|
|
1617
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
1618
|
+
break;
|
|
1619
|
+
case 'dashed':
|
|
1620
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
1621
|
+
break;
|
|
1622
|
+
}
|
|
1623
|
+
//处理边框线颜色和透明度 使用rgba处理透明度
|
|
1624
|
+
var lineColor = new esri.Color(cg.lineColor);
|
|
1625
|
+
lineColor.a = cg.lineOpacity;
|
|
1626
|
+
//生成线类型对象
|
|
1627
|
+
var lineSymbol = new esri.symbol.SimpleLineSymbol(lineStyle, lineColor, parseFloat(cg.lineWidth));
|
|
1628
|
+
//创建面对象
|
|
1629
|
+
var circleSymbol = new esri.symbol.SimpleFillSymbol();
|
|
1630
|
+
//添加边框线数据
|
|
1631
|
+
circleSymbol.setOutline(lineSymbol);
|
|
1632
|
+
//处理填充颜色和透明度 使用rgba处理透明度
|
|
1633
|
+
var circleColor = new esri.Color(cg.color);
|
|
1634
|
+
circleColor.a = cg.pellucidity;
|
|
1635
|
+
circleSymbol.setColor(circleColor);
|
|
1636
|
+
//更新位置
|
|
1637
|
+
gc.setGeometry(position);
|
|
1638
|
+
//更新样式
|
|
1639
|
+
gc.setSymbol(circleSymbol);
|
|
1640
|
+
t.GM.setGraphicParam(item.id, {
|
|
1641
|
+
attributes: _extends({}, item, { other: item }),
|
|
1642
|
+
geometryType: 'circle',
|
|
1643
|
+
geometry: {
|
|
1644
|
+
type: 'circle',
|
|
1645
|
+
x: parseFloat(item.longitude),
|
|
1646
|
+
y: parseFloat(item.latitude),
|
|
1647
|
+
radius: parseFloat(item.radius)
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
});
|
|
1651
|
+
//刷新图元
|
|
1652
|
+
t.state.gis.graphics.refresh();
|
|
1653
|
+
}
|
|
1654
|
+
//添加海量点
|
|
1655
|
+
|
|
1656
|
+
}, {
|
|
1657
|
+
key: 'addPointCollection',
|
|
1658
|
+
value: function addPointCollection() {
|
|
1659
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1660
|
+
|
|
1661
|
+
var t = this;
|
|
1662
|
+
data.map(function (item, index) {
|
|
1663
|
+
var d = item || {};
|
|
1664
|
+
var points = (d.points || []).map(function (d, i) {
|
|
1665
|
+
var p = new esri.geometry.Point(d.lng, d.lat);
|
|
1666
|
+
p = t.state.gis.toScreen(p);
|
|
1667
|
+
return [p.x, p.y];
|
|
1668
|
+
});
|
|
1669
|
+
var options = {
|
|
1670
|
+
size: d.size,
|
|
1671
|
+
shape: d.shape,
|
|
1672
|
+
color: d.color,
|
|
1673
|
+
width: t.state.gis.width,
|
|
1674
|
+
height: t.state.gis.height,
|
|
1675
|
+
mapId: t.props.mapId
|
|
1676
|
+
};
|
|
1677
|
+
var VotexpointCollection = new GMapLib.PointCollection(points, options);
|
|
1678
|
+
t.morepoints.push({
|
|
1679
|
+
id: d.id,
|
|
1680
|
+
value: VotexpointCollection
|
|
1681
|
+
});
|
|
1682
|
+
VotexpointCollection.draw();
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
//更新海量点
|
|
1686
|
+
|
|
1687
|
+
}, {
|
|
1688
|
+
key: 'updatePointCollection',
|
|
1689
|
+
value: function updatePointCollection() {
|
|
1690
|
+
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1691
|
+
|
|
1692
|
+
var t = this;
|
|
1693
|
+
data.map(function (ds, ind) {
|
|
1694
|
+
t.morepoints.map(function (item, index) {
|
|
1695
|
+
if (item.id == ds.id) {
|
|
1696
|
+
var points = (ds.points || []).map(function (d, i) {
|
|
1697
|
+
var p = new esri.geometry.Point(d.lng, d.lat);
|
|
1698
|
+
p = t.state.gis.toScreen(p);
|
|
1699
|
+
return [p.x, p.y];
|
|
1700
|
+
});
|
|
1701
|
+
var options = {
|
|
1702
|
+
size: ds.size,
|
|
1703
|
+
shape: ds.shape,
|
|
1704
|
+
color: ds.color,
|
|
1705
|
+
width: t.state.gis.width,
|
|
1706
|
+
height: t.state.gis.height
|
|
1707
|
+
};
|
|
1708
|
+
item.value.reDraw(points, options);
|
|
1709
|
+
}
|
|
1710
|
+
});
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
//删除海量点
|
|
1714
|
+
|
|
1715
|
+
}, {
|
|
1716
|
+
key: 'clearPointCollection',
|
|
1717
|
+
value: function clearPointCollection() {
|
|
1718
|
+
var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
1719
|
+
|
|
1720
|
+
var t = this;
|
|
1721
|
+
ids.map(function (id, ind) {
|
|
1722
|
+
t.morepoints.map(function (item, index) {
|
|
1723
|
+
if (id == item.id) {
|
|
1724
|
+
item.value.clear();
|
|
1725
|
+
}
|
|
1726
|
+
});
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1729
|
+
//删除全部海量点
|
|
1730
|
+
|
|
1731
|
+
}, {
|
|
1732
|
+
key: 'clearAllPointCollection',
|
|
1733
|
+
value: function clearAllPointCollection() {
|
|
1734
|
+
var t = this;
|
|
1735
|
+
t.morepoints.map(function (item, index) {
|
|
1736
|
+
item.value.clear();
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
//热力图
|
|
1740
|
+
|
|
1741
|
+
}, {
|
|
1742
|
+
key: 'heatMapOverlay',
|
|
1743
|
+
value: function heatMapOverlay() {
|
|
1744
|
+
var d = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1745
|
+
|
|
1746
|
+
var t = this;
|
|
1747
|
+
var cg = {
|
|
1748
|
+
radius: 20,
|
|
1749
|
+
max: 100,
|
|
1750
|
+
visible: true,
|
|
1751
|
+
opacity: 0.7
|
|
1752
|
+
};
|
|
1753
|
+
if (d.config) {
|
|
1754
|
+
cg = _extends({}, cg, d.config);
|
|
1755
|
+
}
|
|
1756
|
+
if (!t.heatmap) {
|
|
1757
|
+
t.heatmap = new GMapLib.HeatmapOverlay({
|
|
1758
|
+
visible: cg.visible
|
|
1759
|
+
});
|
|
1760
|
+
t.heatmap.initialize(t.state.gis, t.props.mapId);
|
|
1761
|
+
}
|
|
1762
|
+
var option = {
|
|
1763
|
+
radius: cg.radius,
|
|
1764
|
+
//百度是1-100,高德是0-1
|
|
1765
|
+
opacity: eval(cg.opacity) * 100,
|
|
1766
|
+
visible: cg.visible
|
|
1767
|
+
};
|
|
1768
|
+
if (cg.gradient) {
|
|
1769
|
+
option.gradient = cg.gradient;
|
|
1770
|
+
}
|
|
1771
|
+
t.heatmap.setOptions(option);
|
|
1772
|
+
t.heatmap.setDataSet({
|
|
1773
|
+
max: cg.max,
|
|
1774
|
+
data: d.data || []
|
|
1775
|
+
});
|
|
1776
|
+
if (cg.visible) {
|
|
1777
|
+
t.isHideHeatMap = false;
|
|
1778
|
+
t.heatmap.show();
|
|
1779
|
+
} else {
|
|
1780
|
+
t.isHideHeatMap = true;
|
|
1781
|
+
t.heatmap.hide();
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
/*事件处理*/
|
|
1785
|
+
//图元事件
|
|
1786
|
+
|
|
1787
|
+
}, {
|
|
1788
|
+
key: 'clickGraphic',
|
|
1789
|
+
value: function clickGraphic(id, e) {
|
|
1790
|
+
var t = this;
|
|
1791
|
+
//编辑中的图元关闭其他事件返回
|
|
1792
|
+
if (t.editId == id) return false;
|
|
1793
|
+
if (typeof t.props.clickGraphic === "function") {
|
|
1794
|
+
var param = t.getGraphic(id);
|
|
1795
|
+
var obj = {
|
|
1796
|
+
param: param,
|
|
1797
|
+
type: param.geometry.type, //图元类型
|
|
1798
|
+
attributes: _extends({}, param.attributes.other, { config: param.attributes.config }), //添加时图元信息
|
|
1799
|
+
top: e.clientY, //当前点所在的位置(屏幕)
|
|
1800
|
+
left: e.clientX,
|
|
1801
|
+
e: e
|
|
1802
|
+
};
|
|
1803
|
+
t.props.clickGraphic(obj);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
//图元鼠标悬浮事件
|
|
1807
|
+
|
|
1808
|
+
}, {
|
|
1809
|
+
key: 'mouseOverGraphic',
|
|
1810
|
+
value: function mouseOverGraphic(id, e) {
|
|
1811
|
+
var t = this;
|
|
1812
|
+
//编辑中的图元关闭其他事件返回
|
|
1813
|
+
if (t.state.editId == id) return false;
|
|
1814
|
+
if (typeof t.props.mouseOverGraphic === 'function') {
|
|
1815
|
+
var obj = {
|
|
1816
|
+
e: e, id: id,
|
|
1817
|
+
param: t.getGraphic(id),
|
|
1818
|
+
top: e.clientY, //当前点所在的位置(屏幕)
|
|
1819
|
+
left: e.clientX
|
|
1820
|
+
};
|
|
1821
|
+
t.props.mouseOverGraphic(obj);
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
//图元鼠标移开事件
|
|
1825
|
+
|
|
1826
|
+
}, {
|
|
1827
|
+
key: 'mouseOutGraphic',
|
|
1828
|
+
value: function mouseOutGraphic(id, e) {
|
|
1829
|
+
var t = this;
|
|
1830
|
+
//编辑中的图元关闭其他事件返回
|
|
1831
|
+
if (t.state.editId == id) return false;
|
|
1832
|
+
if (typeof t.props.mouseOutGraphic === "function") {
|
|
1833
|
+
var obj = {
|
|
1834
|
+
e: e, id: id,
|
|
1835
|
+
param: t.getGraphic(id),
|
|
1836
|
+
top: e.clientY, //当前点所在的位置(屏幕)
|
|
1837
|
+
left: e.clientX
|
|
1838
|
+
};
|
|
1839
|
+
t.props.mouseOutGraphic(obj);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
/*地图事件*/
|
|
1843
|
+
//地图点击事件
|
|
1844
|
+
|
|
1845
|
+
}, {
|
|
1846
|
+
key: 'clickMap',
|
|
1847
|
+
value: function clickMap(e) {
|
|
1848
|
+
var t = this;
|
|
1849
|
+
if (typeof t.props.clickMap === 'function') {
|
|
1850
|
+
var obj = t.getMapExtent();
|
|
1851
|
+
obj.e = e;
|
|
1852
|
+
obj.clickLngLat = {
|
|
1853
|
+
lng: (e.mapPoint || {}).x,
|
|
1854
|
+
lat: (e.mapPoint || {}).y
|
|
1855
|
+
};
|
|
1856
|
+
obj.pixel = {
|
|
1857
|
+
x: (e.screenPoint || {}).x,
|
|
1858
|
+
y: (e.screenPoint || {}).y
|
|
1859
|
+
};
|
|
1860
|
+
t.props.clickMap(obj);
|
|
1861
|
+
}
|
|
1862
|
+
}
|
|
1863
|
+
//地图拖动之前事件
|
|
1864
|
+
|
|
1865
|
+
}, {
|
|
1866
|
+
key: 'dragMapStart',
|
|
1867
|
+
value: function dragMapStart(e) {
|
|
1868
|
+
var t = this;
|
|
1869
|
+
if (typeof t.props.dragMapStart === 'function') {
|
|
1870
|
+
var obj = t.getMapExtent();
|
|
1871
|
+
obj.e = e;
|
|
1872
|
+
t.props.dragMapStart(obj);
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1875
|
+
//地图拖动结束后事件
|
|
1876
|
+
|
|
1877
|
+
}, {
|
|
1878
|
+
key: 'dragMapEnd',
|
|
1879
|
+
value: function dragMapEnd(e) {
|
|
1880
|
+
var t = this;
|
|
1881
|
+
if (typeof t.props.dragMapEnd === 'function') {
|
|
1882
|
+
var obj = t.getMapExtent();
|
|
1883
|
+
obj.e = e;
|
|
1884
|
+
t.props.dragMapEnd(obj);
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
//地图移动之前事件
|
|
1888
|
+
|
|
1889
|
+
}, {
|
|
1890
|
+
key: 'moveStart',
|
|
1891
|
+
value: function moveStart(e) {
|
|
1892
|
+
var t = this;
|
|
1893
|
+
if (typeof t.props.moveStart === 'function') {
|
|
1894
|
+
var obj = t.getMapExtent();
|
|
1895
|
+
obj.e = e;
|
|
1896
|
+
t.props.moveStart(obj);
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
//地图移动结束后事件
|
|
1900
|
+
|
|
1901
|
+
}, {
|
|
1902
|
+
key: 'moveEnd',
|
|
1903
|
+
value: function moveEnd(e) {
|
|
1904
|
+
var t = this;
|
|
1905
|
+
if (typeof t.props.moveEnd === 'function') {
|
|
1906
|
+
var obj = t.getMapExtent();
|
|
1907
|
+
obj.e = e;
|
|
1908
|
+
t.props.moveEnd(obj);
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
//地图更改缩放级别开始时触发触发此事件
|
|
1912
|
+
|
|
1913
|
+
}, {
|
|
1914
|
+
key: 'zoomStart',
|
|
1915
|
+
value: function zoomStart(e) {
|
|
1916
|
+
var t = this;
|
|
1917
|
+
if (typeof t.props.zoomStart === 'function') {
|
|
1918
|
+
var obj = t.getMapExtent();
|
|
1919
|
+
obj.e = e;
|
|
1920
|
+
t.props.zoomStart(obj);
|
|
1921
|
+
}
|
|
1922
|
+
}
|
|
1923
|
+
//地图更改缩放级别结束时触发触发此事件
|
|
1924
|
+
|
|
1925
|
+
}, {
|
|
1926
|
+
key: 'zoomEnd',
|
|
1927
|
+
value: function zoomEnd(e) {
|
|
1928
|
+
var t = this;
|
|
1929
|
+
if (typeof t.props.zoomEnd === 'function') {
|
|
1930
|
+
var obj = t.getMapExtent();
|
|
1931
|
+
obj.e = e;
|
|
1932
|
+
t.props.zoomEnd(obj);
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
/*set方法*/
|
|
1936
|
+
//设置地图中心位置 lng/经度 lat/纬度
|
|
1937
|
+
|
|
1938
|
+
}, {
|
|
1939
|
+
key: 'setCenter',
|
|
1940
|
+
value: function setCenter(gt) {
|
|
1941
|
+
var t = this;
|
|
1942
|
+
if (gt) {
|
|
1943
|
+
//经纬度 必须存在 否则不操作
|
|
1944
|
+
if (!gt[0] || !gt[1]) {
|
|
1945
|
+
return false;
|
|
1946
|
+
}
|
|
1947
|
+
//如果设置的经纬度 与当前中心点一样 不操作
|
|
1948
|
+
var c = t.getCenter();
|
|
1949
|
+
if (c.lng == gt[0] && c.lat == gt[1]) {
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
t.state.gis.centerAt(new esri.geometry.Point(gt[0], gt[1], new esri.SpatialReference(_defineProperty({}, t.wkidStr, t.wkid))));
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
//设置地图比例尺
|
|
1956
|
+
|
|
1957
|
+
}, {
|
|
1958
|
+
key: 'setZoomLevel',
|
|
1959
|
+
value: function setZoomLevel(zoom) {
|
|
1960
|
+
var t = this;
|
|
1961
|
+
var z = t.state.gis.getZoom();
|
|
1962
|
+
if (z == zoom) {
|
|
1963
|
+
return false;
|
|
1964
|
+
}
|
|
1965
|
+
t.state.gis.setZoom(parseInt(zoom));
|
|
1966
|
+
}
|
|
1967
|
+
//将制定图元展示在视野内 (强制改变地图中心位置)
|
|
1968
|
+
/*
|
|
1969
|
+
参数arg格式如下1,2
|
|
1970
|
+
1.string 格式如:'1,a,2,3,4'
|
|
1971
|
+
2.数组 ['1','2']
|
|
1972
|
+
*/
|
|
1973
|
+
|
|
1974
|
+
}, {
|
|
1975
|
+
key: 'setVisiblePoints',
|
|
1976
|
+
value: function setVisiblePoints(mapVisiblePoints) {
|
|
1977
|
+
var t = this;
|
|
1978
|
+
var arg = null;
|
|
1979
|
+
var type = mapVisiblePoints.type;
|
|
1980
|
+
var ary = []; //图元id集合
|
|
1981
|
+
var obj = []; //经纬度集合
|
|
1982
|
+
switch (mapVisiblePoints.fitView) {
|
|
1983
|
+
case 'point':
|
|
1984
|
+
arg = this.state.pointIds;
|
|
1985
|
+
break;
|
|
1986
|
+
case 'line':
|
|
1987
|
+
arg = this.state.lineIds;
|
|
1988
|
+
break;
|
|
1989
|
+
case 'polygon':
|
|
1990
|
+
arg = this.state.polygonIds;
|
|
1991
|
+
break;
|
|
1992
|
+
case 'circle':
|
|
1993
|
+
arg = this.state.circleIds;
|
|
1994
|
+
break;
|
|
1995
|
+
case 'all':
|
|
1996
|
+
arg = this.state.pointIds.concat(this.state.lineIds).concat(this.state.polygonIds).concat(this.state.circleIds);
|
|
1997
|
+
break;
|
|
1998
|
+
default:
|
|
1999
|
+
arg = mapVisiblePoints.fitView;
|
|
2000
|
+
break;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
if (typeof arg === 'string') {
|
|
2004
|
+
ary = arg.split(',');
|
|
2005
|
+
} else if (arg instanceof Array) {
|
|
2006
|
+
ary = arg;
|
|
2007
|
+
}
|
|
2008
|
+
if (ary[0] instanceof Array) {
|
|
2009
|
+
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(ary));
|
|
2010
|
+
} else {
|
|
2011
|
+
for (var i = 0; i < ary.length; i++) {
|
|
2012
|
+
var g = t.GM.getGraphicParam(ary[i]);
|
|
2013
|
+
switch (g.geometry.type) {
|
|
2014
|
+
case 'point':
|
|
2015
|
+
case 'circle':
|
|
2016
|
+
obj.push([g.geometry.x, g.geometry.y]);
|
|
2017
|
+
break;
|
|
2018
|
+
case 'polyline':
|
|
2019
|
+
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.paths));
|
|
2020
|
+
break;
|
|
2021
|
+
case 'polygon':
|
|
2022
|
+
obj = [].concat(_toConsumableArray(obj), _toConsumableArray(g.geometry.rings));
|
|
2023
|
+
break;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
|
|
2028
|
+
var _t$dealData3 = t.dealData(obj),
|
|
2029
|
+
_extent = _t$dealData3._extent;
|
|
2030
|
+
|
|
2031
|
+
if (_extent.xmin && _extent.xmax && _extent.ymin && _extent.ymax) {
|
|
2032
|
+
//避免偏移引起的点位漏看
|
|
2033
|
+
_extent = t.dealExtendBounds(_extent, 100);
|
|
2034
|
+
var ext = new esri.geometry.Extent(_extends({}, _extent, { spatialReference: _defineProperty({}, t.wkidStr, t.wkid) }));
|
|
2035
|
+
if (!type || type == 'all' || type == 'zoom') {
|
|
2036
|
+
t.state.gis.setExtent(ext);
|
|
2037
|
+
} else if (type == 'center') {
|
|
2038
|
+
t.state.gis.centerAt(ext.getCenter());
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
/*get方法*/
|
|
2043
|
+
//获取当前地图的中心位置
|
|
2044
|
+
|
|
2045
|
+
}, {
|
|
2046
|
+
key: 'getCurrentCenter',
|
|
2047
|
+
value: function getCurrentCenter() {
|
|
2048
|
+
var t = this;
|
|
2049
|
+
var extent = t.state.gis.geographicExtent;
|
|
2050
|
+
return [(extent.xmax + extent.xmin) / 2, (extent.ymax + extent.ymin) / 2];
|
|
2051
|
+
}
|
|
2052
|
+
//获取当前比例尺
|
|
2053
|
+
|
|
2054
|
+
}, {
|
|
2055
|
+
key: 'getZoomLevel',
|
|
2056
|
+
value: function getZoomLevel() {
|
|
2057
|
+
var t = this;
|
|
2058
|
+
return t.state.gis.getLevel();
|
|
2059
|
+
}
|
|
2060
|
+
//获取当前中心点
|
|
2061
|
+
|
|
2062
|
+
}, {
|
|
2063
|
+
key: 'getCenter',
|
|
2064
|
+
value: function getCenter() {
|
|
2065
|
+
var t = this;
|
|
2066
|
+
var _t$state$gis$extent = t.state.gis.extent,
|
|
2067
|
+
xmin = _t$state$gis$extent.xmin,
|
|
2068
|
+
ymin = _t$state$gis$extent.ymin,
|
|
2069
|
+
xmax = _t$state$gis$extent.xmax,
|
|
2070
|
+
ymax = _t$state$gis$extent.ymax;
|
|
2071
|
+
|
|
2072
|
+
return { lng: (xmin + xmax) / 2, lat: (ymin + ymax) / 2 };
|
|
2073
|
+
}
|
|
2074
|
+
//获取图元数据
|
|
2075
|
+
|
|
2076
|
+
}, {
|
|
2077
|
+
key: 'getGraphic',
|
|
2078
|
+
value: function getGraphic(id) {
|
|
2079
|
+
var t = this;
|
|
2080
|
+
if (!id) {
|
|
2081
|
+
return false;
|
|
2082
|
+
}
|
|
2083
|
+
var gp = t.GM.getGraphicParam(id);
|
|
2084
|
+
var gg = t.GM.getGraphic(id);
|
|
2085
|
+
if (!gg) {
|
|
2086
|
+
return false;
|
|
2087
|
+
}
|
|
2088
|
+
var p = {},
|
|
2089
|
+
pts = [],
|
|
2090
|
+
lng = 0,
|
|
2091
|
+
lat = 0;
|
|
2092
|
+
switch (gp.geometryType) {
|
|
2093
|
+
case 'point':
|
|
2094
|
+
lng = gg.geometry.x;
|
|
2095
|
+
lat = gg.geometry.y;
|
|
2096
|
+
p = _extends({}, gp, {
|
|
2097
|
+
mapLayer: gg,
|
|
2098
|
+
geometry: _extends({}, gp.geometry, {
|
|
2099
|
+
x: lng,
|
|
2100
|
+
y: lat
|
|
2101
|
+
}),
|
|
2102
|
+
attributes: _extends({}, gp.attributes, {
|
|
2103
|
+
longitude: lng,
|
|
2104
|
+
latitude: lat,
|
|
2105
|
+
other: _extends({}, gp.attributes.other, {
|
|
2106
|
+
longitude: lng,
|
|
2107
|
+
latitude: lat
|
|
2108
|
+
})
|
|
2109
|
+
})
|
|
2110
|
+
});
|
|
2111
|
+
break;
|
|
2112
|
+
case 'polyline':
|
|
2113
|
+
pts = gg.geometry.paths[0];
|
|
2114
|
+
p = _extends({}, gp, {
|
|
2115
|
+
mapLayer: gg,
|
|
2116
|
+
geometry: _extends({}, gp.geometry, {
|
|
2117
|
+
paths: pts
|
|
2118
|
+
}),
|
|
2119
|
+
attributes: _extends({}, gp.attributes, {
|
|
2120
|
+
paths: pts,
|
|
2121
|
+
other: _extends({}, gp.attributes.other, {
|
|
2122
|
+
paths: pts
|
|
2123
|
+
})
|
|
2124
|
+
})
|
|
2125
|
+
});
|
|
2126
|
+
break;
|
|
2127
|
+
case 'polygon':
|
|
2128
|
+
pts = gg.geometry.rings[0];
|
|
2129
|
+
p = _extends({}, gp, {
|
|
2130
|
+
mapLayer: gg,
|
|
2131
|
+
geometry: _extends({}, gp.geometry, {
|
|
2132
|
+
rings: pts
|
|
2133
|
+
}),
|
|
2134
|
+
attributes: _extends({}, gp.attributes, {
|
|
2135
|
+
rings: pts,
|
|
2136
|
+
other: _extends({}, gp.attributes.other, {
|
|
2137
|
+
rings: pts
|
|
2138
|
+
})
|
|
2139
|
+
}),
|
|
2140
|
+
area: (0, _MapToolFunction.getPolygonArea)(pts)
|
|
2141
|
+
});
|
|
2142
|
+
break;
|
|
2143
|
+
case 'circle':
|
|
2144
|
+
lng = gg.geometry.center.x;
|
|
2145
|
+
lat = gg.geometry.center.y;
|
|
2146
|
+
var radius = 0;
|
|
2147
|
+
p = _extends({}, gp, {
|
|
2148
|
+
mapLayer: gg,
|
|
2149
|
+
geometry: _extends({}, gp.geometry, {
|
|
2150
|
+
x: lng,
|
|
2151
|
+
y: lat,
|
|
2152
|
+
radius: radius
|
|
2153
|
+
}),
|
|
2154
|
+
attributes: _extends({}, gp.attributes, {
|
|
2155
|
+
longitude: lng,
|
|
2156
|
+
latitude: lat,
|
|
2157
|
+
radius: radius,
|
|
2158
|
+
other: _extends({}, gp.attributes.other, {
|
|
2159
|
+
longitude: lng,
|
|
2160
|
+
latitude: lat,
|
|
2161
|
+
radius: radius
|
|
2162
|
+
})
|
|
2163
|
+
}),
|
|
2164
|
+
area: Math.PI * radius * radius
|
|
2165
|
+
});
|
|
2166
|
+
break;
|
|
2167
|
+
}
|
|
2168
|
+
return p;
|
|
2169
|
+
}
|
|
2170
|
+
//获取地图当前的位置状态信息
|
|
2171
|
+
|
|
2172
|
+
}, {
|
|
2173
|
+
key: 'getMapExtent',
|
|
2174
|
+
value: function getMapExtent() {
|
|
2175
|
+
var t = this;
|
|
2176
|
+
var nowBounds = t.state.gis._getAvailExtent();
|
|
2177
|
+
var obj = {};
|
|
2178
|
+
obj.southWest = {
|
|
2179
|
+
lng: nowBounds.xmin,
|
|
2180
|
+
lat: nowBounds.ymin
|
|
2181
|
+
};
|
|
2182
|
+
obj.northEast = {
|
|
2183
|
+
lng: nowBounds.xmax,
|
|
2184
|
+
lat: nowBounds.ymax
|
|
2185
|
+
};
|
|
2186
|
+
obj.nowCenter = t.getCenter();
|
|
2187
|
+
obj.zoom = t.getZoomLevel();
|
|
2188
|
+
obj.mapSize = { width: t.state.gis.width, height: t.state.gis.height };
|
|
2189
|
+
obj.radius = t.calculatePointsDistance([obj.nowCenter.lng, obj.nowCenter.lat], [obj.northEast.lng, obj.northEast.lat]);
|
|
2190
|
+
return obj;
|
|
2191
|
+
}
|
|
2192
|
+
/*工具方法*/
|
|
2193
|
+
|
|
2194
|
+
}, {
|
|
2195
|
+
key: 'vtxRangingTool',
|
|
2196
|
+
value: function vtxRangingTool(mapRangingTool) {
|
|
2197
|
+
var t = this;
|
|
2198
|
+
//关闭测距时双击地图缩放功能
|
|
2199
|
+
t.state.gis.disableDoubleClickZoom();
|
|
2200
|
+
//开启测距状态
|
|
2201
|
+
if (!t.rangingTool.isRanging) {
|
|
2202
|
+
t.rangingTool.isRanging = true;
|
|
2203
|
+
}
|
|
2204
|
+
//初始测距回调
|
|
2205
|
+
if (!t.rangingTool.mapRangingTool) {
|
|
2206
|
+
t.rangingTool.mapRangingTool = mapRangingTool;
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
/*功能方法*/
|
|
2210
|
+
//单个删除图元
|
|
2211
|
+
|
|
2212
|
+
}, {
|
|
2213
|
+
key: 'removeGraphic',
|
|
2214
|
+
value: function removeGraphic(id, type) {
|
|
2215
|
+
var t = this;
|
|
2216
|
+
var graphic = t.GM.getGraphic(id);
|
|
2217
|
+
//刪除label
|
|
2218
|
+
if (t.Label[id]) {
|
|
2219
|
+
t.Label[id].html.remove();
|
|
2220
|
+
delete t.Label[id];
|
|
2221
|
+
}
|
|
2222
|
+
if (!!graphic) {
|
|
2223
|
+
//清除聚合点 避免异常
|
|
2224
|
+
// t._cluster.removeMarker(this.GM.getGraphic(id));
|
|
2225
|
+
//清除地图中图元
|
|
2226
|
+
t.state.gis.graphics.remove(graphic);
|
|
2227
|
+
//清除对应id的图元数据缓存
|
|
2228
|
+
t.GM.removeGraphic(id);
|
|
2229
|
+
} else {
|
|
2230
|
+
return false;
|
|
2231
|
+
}
|
|
2232
|
+
for (var i = 0; i < t.movePoints.length; i++) {
|
|
2233
|
+
if (t.movePoints[i].id == id) {
|
|
2234
|
+
t.movePoints.splice(i, 1);
|
|
2235
|
+
continue;
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
var ids = [];
|
|
2239
|
+
switch (type) {
|
|
2240
|
+
case 'point':
|
|
2241
|
+
ids = t.state.pointIds;
|
|
2242
|
+
break;
|
|
2243
|
+
case 'line':
|
|
2244
|
+
ids = t.state.lineIds;
|
|
2245
|
+
break;
|
|
2246
|
+
case 'polygon':
|
|
2247
|
+
ids = t.state.polygonIds;
|
|
2248
|
+
break;
|
|
2249
|
+
case 'circle':
|
|
2250
|
+
ids = t.state.circleIds;
|
|
2251
|
+
break;
|
|
2252
|
+
case 'draw':
|
|
2253
|
+
if (t.state.drawIds.point.indexOf(id) > -1) {
|
|
2254
|
+
t.state.drawIds.point.splice(t.state.drawIds.point.indexOf(id), 1);
|
|
2255
|
+
}
|
|
2256
|
+
if (t.state.drawIds.polyline.indexOf(id) > -1) {
|
|
2257
|
+
t.state.drawIds.polyline.splice(t.state.drawIds.polyline.indexOf(id), 1);
|
|
2258
|
+
}
|
|
2259
|
+
if (t.state.drawIds.polygon.indexOf(id) > -1) {
|
|
2260
|
+
t.state.drawIds.polygon.splice(t.state.drawIds.polygon.indexOf(id), 1);
|
|
2261
|
+
}
|
|
2262
|
+
if (t.state.drawIds.circle.indexOf(id) > -1) {
|
|
2263
|
+
t.state.drawIds.circle.splice(t.state.drawIds.circle.indexOf(id), 1);
|
|
2264
|
+
}
|
|
2265
|
+
if (t.state.drawIds.rectangle.indexOf(id) > -1) {
|
|
2266
|
+
t.state.drawIds.rectangle.splice(t.state.drawIds.rectangle.indexOf(id), 1);
|
|
2267
|
+
}
|
|
2268
|
+
break;
|
|
2269
|
+
default:
|
|
2270
|
+
if (t.state.pointIds.indexOf(id) > -1) {
|
|
2271
|
+
t.state.pointIds.splice(t.state.pointIds.indexOf(id), 1);
|
|
2272
|
+
}
|
|
2273
|
+
if (t.state.lineIds.indexOf(id) > -1) {
|
|
2274
|
+
t.state.lineIds.splice(t.state.lineIds.indexOf(id), 1);
|
|
2275
|
+
}
|
|
2276
|
+
if (t.state.polygonIds.indexOf(id) > -1) {
|
|
2277
|
+
t.state.polygonIds.splice(t.state.polygonIds.indexOf(id), 1);
|
|
2278
|
+
}
|
|
2279
|
+
if (t.state.circleIds.indexOf(id) > -1) {
|
|
2280
|
+
t.state.circleIds.splice(t.state.circleIds.indexOf(id), 1);
|
|
2281
|
+
}
|
|
2282
|
+
break;
|
|
2283
|
+
}
|
|
2284
|
+
if (id == t.state.editId) {
|
|
2285
|
+
t.state.editId = '';
|
|
2286
|
+
}
|
|
2287
|
+
if (ids.indexOf(id) != -1) {
|
|
2288
|
+
ids.splice(ids.indexOf(id), 1);
|
|
2289
|
+
}
|
|
2290
|
+
}
|
|
2291
|
+
//清空地图
|
|
2292
|
+
|
|
2293
|
+
}, {
|
|
2294
|
+
key: 'clearAll',
|
|
2295
|
+
value: function clearAll() {
|
|
2296
|
+
var t = this;
|
|
2297
|
+
//清空热力图
|
|
2298
|
+
if (t.heatmap) {
|
|
2299
|
+
t.heatmap.clear();
|
|
2300
|
+
}
|
|
2301
|
+
t.heatmap = null;
|
|
2302
|
+
t.movePoints = [];
|
|
2303
|
+
t.clearAllPointCollection();
|
|
2304
|
+
//循环所有id删除
|
|
2305
|
+
var _t$state2 = t.state,
|
|
2306
|
+
pointIds = _t$state2.pointIds,
|
|
2307
|
+
lineIds = _t$state2.lineIds,
|
|
2308
|
+
polygonIds = _t$state2.polygonIds,
|
|
2309
|
+
circleIds = _t$state2.circleIds,
|
|
2310
|
+
drawIds = _t$state2.drawIds;
|
|
2311
|
+
//拷贝数组,避免原数组操作,影响循环
|
|
2312
|
+
|
|
2313
|
+
var ps = [].concat(_toConsumableArray(pointIds)),
|
|
2314
|
+
ls = [].concat(_toConsumableArray(lineIds)),
|
|
2315
|
+
pgs = [].concat(_toConsumableArray(polygonIds)),
|
|
2316
|
+
cs = [].concat(_toConsumableArray(circleIds));
|
|
2317
|
+
// 删除点
|
|
2318
|
+
for (var i = 0; i < ps.length; i++) {
|
|
2319
|
+
t.removeGraphic(ps[i], 'point');
|
|
2320
|
+
}
|
|
2321
|
+
// 删除线
|
|
2322
|
+
for (var _i3 = 0; _i3 < ls.length; _i3++) {
|
|
2323
|
+
t.removeGraphic(ls[_i3], 'line');
|
|
2324
|
+
}
|
|
2325
|
+
// 删除面
|
|
2326
|
+
for (var _i4 = 0; _i4 < pgs.length; _i4++) {
|
|
2327
|
+
t.removeGraphic(pgs[_i4], 'polygon');
|
|
2328
|
+
}
|
|
2329
|
+
// 删除圆
|
|
2330
|
+
for (var _i5 = 0; _i5 < cs.length; _i5++) {
|
|
2331
|
+
t.removeGraphic(cs[_i5], 'circle');
|
|
2332
|
+
}
|
|
2333
|
+
//删除绘制的点
|
|
2334
|
+
var point = drawIds.point,
|
|
2335
|
+
polyline = drawIds.polyline,
|
|
2336
|
+
polygon = drawIds.polygon,
|
|
2337
|
+
circle = drawIds.circle,
|
|
2338
|
+
rectangle = drawIds.rectangle;
|
|
2339
|
+
|
|
2340
|
+
for (var _i6 = 0; _i6 < point.length; _i6++) {
|
|
2341
|
+
t.removeGraphic(point[_i6]);
|
|
2342
|
+
}
|
|
2343
|
+
for (var _i7 = 0; _i7 < polyline.length; _i7++) {
|
|
2344
|
+
t.removeGraphic(polyline[_i7]);
|
|
2345
|
+
}
|
|
2346
|
+
for (var _i8 = 0; _i8 < polygon.length; _i8++) {
|
|
2347
|
+
t.removeGraphic(polygon[_i8]);
|
|
2348
|
+
}
|
|
2349
|
+
for (var _i9 = 0; _i9 < circle.length; _i9++) {
|
|
2350
|
+
t.removeGraphic(circle[_i9]);
|
|
2351
|
+
}
|
|
2352
|
+
for (var _i10 = 0; _i10 < rectangle.length; _i10++) {
|
|
2353
|
+
t.removeGraphic(rectangle[_i10]);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
//展示比例尺
|
|
2357
|
+
|
|
2358
|
+
}, {
|
|
2359
|
+
key: 'showControl',
|
|
2360
|
+
value: function showControl() {
|
|
2361
|
+
var t = this,
|
|
2362
|
+
type = '',
|
|
2363
|
+
location = { top: 20, left: 20 },
|
|
2364
|
+
ls = { top: 20, left: 60 },
|
|
2365
|
+
w = t.state.gis.width,
|
|
2366
|
+
h = t.state.gis.height;
|
|
2367
|
+
switch (t.props.showControl.location) {
|
|
2368
|
+
case 'tl':
|
|
2369
|
+
location = { top: 20, left: 20 };
|
|
2370
|
+
ls = { top: 20, left: 70 };
|
|
2371
|
+
if (!t.props.showControl.type) {
|
|
2372
|
+
ls = { top: 20, left: 20 };
|
|
2373
|
+
}
|
|
2374
|
+
break;
|
|
2375
|
+
case 'bl':
|
|
2376
|
+
location = { top: h - 83, left: 20 };
|
|
2377
|
+
ls = { top: h - 50, left: 70 };
|
|
2378
|
+
if (!t.props.showControl.type) {
|
|
2379
|
+
ls = { top: h - 50, left: 20 };
|
|
2380
|
+
}
|
|
2381
|
+
break;
|
|
2382
|
+
case 'tr':
|
|
2383
|
+
location = { top: 20, left: w - 52 };
|
|
2384
|
+
ls = { top: 20, left: w - 152 };
|
|
2385
|
+
if (!t.props.showControl.type) {
|
|
2386
|
+
ls = { top: 20, left: w - 93 };
|
|
2387
|
+
}
|
|
2388
|
+
break;
|
|
2389
|
+
case 'br':
|
|
2390
|
+
location = { top: h - 83, left: w - 52 };
|
|
2391
|
+
ls = { top: h - 50, left: w - 152 };
|
|
2392
|
+
if (!t.props.showControl.type) {
|
|
2393
|
+
ls = { top: h - 50, left: w - 93 };
|
|
2394
|
+
}
|
|
2395
|
+
break;
|
|
2396
|
+
}
|
|
2397
|
+
if (!$('#' + t.props.mapId + '_zoom_slider_show')[0]) {
|
|
2398
|
+
var getScale = t.state.gis.getScale() * 0.025399998 / 96;
|
|
2399
|
+
//分母系数
|
|
2400
|
+
var coefficient = Math.pow(10, Math.floor(getScale).toString().length - 1);
|
|
2401
|
+
//判断系数 , 总长度值
|
|
2402
|
+
var gs = getScale / coefficient,
|
|
2403
|
+
toldis = 1,
|
|
2404
|
+
isCent = false;
|
|
2405
|
+
if (gs < 1) {
|
|
2406
|
+
isCent = true;
|
|
2407
|
+
gs *= 10;
|
|
2408
|
+
}
|
|
2409
|
+
//计算比例尺数值和长度
|
|
2410
|
+
if (gs >= 5) {
|
|
2411
|
+
toldis = 5 * coefficient * 100;
|
|
2412
|
+
} else if (gs >= 2) {
|
|
2413
|
+
toldis = 2 * coefficient * 100;
|
|
2414
|
+
} else {
|
|
2415
|
+
toldis = 1 * coefficient * 100;
|
|
2416
|
+
}
|
|
2417
|
+
var scaleW = toldis / getScale;
|
|
2418
|
+
if (isCent) {
|
|
2419
|
+
scaleW /= 10;
|
|
2420
|
+
toldis /= 10;
|
|
2421
|
+
}
|
|
2422
|
+
//宽度矫正处理
|
|
2423
|
+
if (scaleW < 50) {
|
|
2424
|
+
toldis *= 1.5;
|
|
2425
|
+
scaleW = toldis / getScale;
|
|
2426
|
+
}
|
|
2427
|
+
//处理比例尺值显示
|
|
2428
|
+
toldis = toldis >= 1000 ? Math.round(toldis / 1000) + '\u516C\u91CC' : toldis + '\u7C73';
|
|
2429
|
+
var sliderShow = '\n <div id=\'' + t.props.mapId + '_zoom_slider_show\' \n style=\'position:absolute;z-index:100;width:' + (scaleW - 2) + 'px;\'\n >\n <div class=\'zoom_slider_show_scale\'>' + toldis + '</div>\n <div class=\'zoom_slider_show_bottom\'></div>\n </div>\n ';
|
|
2430
|
+
$('#' + t.props.mapId + '_root').append(sliderShow);
|
|
2431
|
+
}
|
|
2432
|
+
switch (t.props.showControl.type) {
|
|
2433
|
+
case 'all':
|
|
2434
|
+
case 'small':
|
|
2435
|
+
case 'pan':
|
|
2436
|
+
case 'zoom':
|
|
2437
|
+
$('#' + t.props.mapId + '_zoom_slider').css(_extends({}, location, {
|
|
2438
|
+
display: 'block'
|
|
2439
|
+
}));
|
|
2440
|
+
default:
|
|
2441
|
+
$('#' + t.props.mapId + '_zoom_slider_show').css(_extends({}, ls));
|
|
2442
|
+
break;
|
|
2443
|
+
}
|
|
2444
|
+
}
|
|
2445
|
+
//编辑图元
|
|
2446
|
+
|
|
2447
|
+
}, {
|
|
2448
|
+
key: 'doEdit',
|
|
2449
|
+
value: function doEdit(id) {
|
|
2450
|
+
var t = this;
|
|
2451
|
+
if (!t.editToolbar) {
|
|
2452
|
+
t.editToolbar = new esri.toolbars.Edit(t.state.gis);
|
|
2453
|
+
t.editToolbarC = new esri.toolbars.Edit(t.state.gis);
|
|
2454
|
+
var changeLabel = function changeLabel(point, eid, gcparam) {
|
|
2455
|
+
var label = '',
|
|
2456
|
+
cg = gcparam.attributes.config;
|
|
2457
|
+
//判断是不是html点
|
|
2458
|
+
if (!!gcparam.attributes.markerContent) {
|
|
2459
|
+
label = {
|
|
2460
|
+
html: t.Label[eid].html,
|
|
2461
|
+
offset: {
|
|
2462
|
+
x: cg.markerContentX || 100,
|
|
2463
|
+
y: cg.markerContentY || 30
|
|
2464
|
+
},
|
|
2465
|
+
position: point
|
|
2466
|
+
};
|
|
2467
|
+
} else {
|
|
2468
|
+
//判断是否有label
|
|
2469
|
+
if (gcparam.attributes.canShowLabel && cg.labelContent) {
|
|
2470
|
+
label = {
|
|
2471
|
+
html: t.Label[eid].html,
|
|
2472
|
+
//offset 需要处理 图片点位的位置(将点位偏移和宽度加入计算)
|
|
2473
|
+
offset: {
|
|
2474
|
+
x: (cg.labelPixelX || 0) + ((cg.markerContentX || -15) + (cg.width || 30) / 2),
|
|
2475
|
+
y: (cg.labelPixelY || 34) + (cg.markerContentY || -15)
|
|
2476
|
+
},
|
|
2477
|
+
position: point
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
if (label) {
|
|
2482
|
+
t.dealLabelGraphics(eid, label);
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
/*点位编辑事件*/
|
|
2486
|
+
//编辑关闭事件
|
|
2487
|
+
t.editToolbar.on('deactivate', function (e) {
|
|
2488
|
+
var eid = e.graphic.attributes.id;
|
|
2489
|
+
var gcparam = t.GM.getGraphicParam(eid);
|
|
2490
|
+
//关闭label移动限制开关
|
|
2491
|
+
t.canMoveLabel = false;
|
|
2492
|
+
t.mouseNowPosition.isCount = false;
|
|
2493
|
+
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
2494
|
+
var obj = {};
|
|
2495
|
+
if (eid == 'vtx-circleMove') {
|
|
2496
|
+
var param = t.getGraphic(t.editId);
|
|
2497
|
+
obj = {
|
|
2498
|
+
area: Math.PI * Math.pow(t.GM.getGraphic(t.editId).geometry.radius, 2),
|
|
2499
|
+
e: t.GM.getGraphic(t.editId),
|
|
2500
|
+
param: param,
|
|
2501
|
+
id: t.editId,
|
|
2502
|
+
geometry: t.GM.getGraphic(t.editId).geometry
|
|
2503
|
+
};
|
|
2504
|
+
} else {
|
|
2505
|
+
var _param = t.getGraphic(eid);
|
|
2506
|
+
obj = {
|
|
2507
|
+
e: e.graphic, param: _param,
|
|
2508
|
+
id: eid,
|
|
2509
|
+
geometry: e.graphic.geometry
|
|
2510
|
+
};
|
|
2511
|
+
switch (obj.geometry.type) {
|
|
2512
|
+
case 'polyline':
|
|
2513
|
+
obj.geometry = _extends({}, obj.geometry, {
|
|
2514
|
+
paths: obj.geometry.paths[0]
|
|
2515
|
+
});
|
|
2516
|
+
obj.distance = t.calculateDistance(obj.geometry.paths);
|
|
2517
|
+
break;
|
|
2518
|
+
case 'polygon':
|
|
2519
|
+
obj.geometry = _extends({}, obj.geometry, {
|
|
2520
|
+
rings: obj.geometry.rings[0]
|
|
2521
|
+
});
|
|
2522
|
+
obj.area = (0, _MapToolFunction.getPolygonArea)(obj.geometry.rings);
|
|
2523
|
+
break;
|
|
2524
|
+
}
|
|
2525
|
+
}
|
|
2526
|
+
t.props.editGraphicChange(obj);
|
|
2527
|
+
}
|
|
2528
|
+
if (eid == 'vtx-circleMove') {
|
|
2529
|
+
t.removeGraphic('vtx-circleMove', 'point');
|
|
2530
|
+
t.removeGraphic('vtx-circleRadius', 'point');
|
|
2531
|
+
if (t.zIndexGraphics.indexOf('vtx-circleMove') > -1) {
|
|
2532
|
+
t.zIndexGraphics.splice(t.zIndexGraphics.indexOf('vtx-circleMove'), 1);
|
|
2533
|
+
}
|
|
2534
|
+
if (t.zIndexGraphics.indexOf('vtx-circleRadius') > -1) {
|
|
2535
|
+
t.zIndexGraphics.splice(t.zIndexGraphics.indexOf('vtx-circleRadius'), 1);
|
|
2536
|
+
}
|
|
2537
|
+
}
|
|
2538
|
+
if (t.zIndexGraphics.indexOf(eid) > -1) {
|
|
2539
|
+
t.zIndexGraphics.splice(t.zIndexGraphics.indexOf(eid), 1);
|
|
2540
|
+
}
|
|
2541
|
+
t.editId = '';
|
|
2542
|
+
});
|
|
2543
|
+
//移动开始事件 开启开关
|
|
2544
|
+
t.editToolbar.on('graphic-move-start', function (e) {
|
|
2545
|
+
//label可以跟着点位移动,避免label直接跟着鼠标移动
|
|
2546
|
+
t.canMoveLabel = true;
|
|
2547
|
+
});
|
|
2548
|
+
//移动中事件
|
|
2549
|
+
t.editToolbar.on('graphic-move', function (e) {
|
|
2550
|
+
//计算鼠标点 与中心点的偏移值
|
|
2551
|
+
if (!t.mouseNowPosition.isCount) {
|
|
2552
|
+
t.mouseNowPosition.isCount = true;
|
|
2553
|
+
t.mouseNowPosition.px = t.mouseNowPosition.x - e.graphic.geometry.x;
|
|
2554
|
+
t.mouseNowPosition.py = t.mouseNowPosition.y - e.graphic.geometry.y;
|
|
2555
|
+
}
|
|
2556
|
+
var eid = e.graphic.attributes.id,
|
|
2557
|
+
position = new esri.geometry.Point({
|
|
2558
|
+
longitude: t.mouseNowPosition.x - t.mouseNowPosition.px,
|
|
2559
|
+
latitude: t.mouseNowPosition.y - t.mouseNowPosition.py,
|
|
2560
|
+
spatialReference: { wkid: t.grwkid }
|
|
2561
|
+
});
|
|
2562
|
+
//圆中心点的移动
|
|
2563
|
+
if (eid == 'vtx-circleMove') {
|
|
2564
|
+
t.GM.getGraphic('vtx-circleMove').setGeometry(position);
|
|
2565
|
+
var circleCenter = new esri.geometry.Circle({
|
|
2566
|
+
center: position,
|
|
2567
|
+
radius: t.GM.getGraphic(t.editId).geometry.radius
|
|
2568
|
+
});
|
|
2569
|
+
t.GM.getGraphic(t.editId).setGeometry(circleCenter);
|
|
2570
|
+
t.GM.getGraphic('vtx-circleRadius').setGeometry(new esri.geometry.Point({
|
|
2571
|
+
longitude: t.mouseNowPosition.x - t.mouseNowPosition.px - t.circleEditPXY.px,
|
|
2572
|
+
latitude: t.mouseNowPosition.y - t.mouseNowPosition.py - t.circleEditPXY.py,
|
|
2573
|
+
spatialReference: { wkid: t.grwkid }
|
|
2574
|
+
}));
|
|
2575
|
+
t.state.gis.graphics.refresh();
|
|
2576
|
+
return false;
|
|
2577
|
+
}
|
|
2578
|
+
var gcparam = t.GM.getGraphicParam(eid);
|
|
2579
|
+
changeLabel(position, eid, gcparam);
|
|
2580
|
+
});
|
|
2581
|
+
//移动结束后事件
|
|
2582
|
+
t.editToolbar.on('graphic-move-stop', function (e) {
|
|
2583
|
+
var eid = e.graphic.attributes.id;
|
|
2584
|
+
var gcparam = t.GM.getGraphicParam(eid);
|
|
2585
|
+
//关闭label移动限制开关
|
|
2586
|
+
t.canMoveLabel = false;
|
|
2587
|
+
t.mouseNowPosition.isCount = false;
|
|
2588
|
+
//判断是不是点
|
|
2589
|
+
if (gcparam.geometryType == 'point') {
|
|
2590
|
+
changeLabel(e.graphic.geometry, eid, gcparam);
|
|
2591
|
+
}
|
|
2592
|
+
//圆中心点的移动
|
|
2593
|
+
if (eid == 'vtx-circleMove') {
|
|
2594
|
+
t.GM.getGraphic('vtx-circleMove').setGeometry(e.graphic.geometry);
|
|
2595
|
+
var circleCenter = new esri.geometry.Circle({
|
|
2596
|
+
center: e.graphic.geometry,
|
|
2597
|
+
radius: t.GM.getGraphic(t.editId).geometry.radius
|
|
2598
|
+
});
|
|
2599
|
+
t.GM.getGraphic(t.editId).setGeometry(circleCenter);
|
|
2600
|
+
t.GM.getGraphic('vtx-circleRadius').setGeometry(new esri.geometry.Point({
|
|
2601
|
+
longitude: e.graphic.geometry.x - t.circleEditPXY.px,
|
|
2602
|
+
latitude: e.graphic.geometry.y - t.circleEditPXY.py,
|
|
2603
|
+
spatialReference: { wkid: t.grwkid }
|
|
2604
|
+
}));
|
|
2605
|
+
t.state.gis.graphics.refresh();
|
|
2606
|
+
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
2607
|
+
var param = t.getGraphic(t.editId);
|
|
2608
|
+
t.props.editGraphicChange({
|
|
2609
|
+
area: Math.PI * Math.pow(t.GM.getGraphic(t.editId).geometry.radius, 2),
|
|
2610
|
+
e: t.GM.getGraphic(t.editId),
|
|
2611
|
+
param: param,
|
|
2612
|
+
id: t.editId,
|
|
2613
|
+
geometry: t.GM.getGraphic(t.editId).geometry
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
return false;
|
|
2617
|
+
}
|
|
2618
|
+
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
2619
|
+
var _param2 = t.getGraphic(eid);
|
|
2620
|
+
t.props.editGraphicChange({
|
|
2621
|
+
e: e.graphic, param: _param2,
|
|
2622
|
+
id: eid,
|
|
2623
|
+
geometry: e.graphic.geometry
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
});
|
|
2627
|
+
//多折线 多边形 圆事件处理
|
|
2628
|
+
t.editToolbar.on('vertex-move-stop', function (e) {
|
|
2629
|
+
var eid = e.graphic.attributes.id;
|
|
2630
|
+
var gcparam = t.GM.getGraphicParam(eid);
|
|
2631
|
+
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
2632
|
+
var param = t.getGraphic(eid);
|
|
2633
|
+
var obj = {
|
|
2634
|
+
e: e.graphic, param: param,
|
|
2635
|
+
id: eid,
|
|
2636
|
+
geometry: e.graphic.geometry
|
|
2637
|
+
};
|
|
2638
|
+
switch (obj.geometry.type) {
|
|
2639
|
+
case 'polyline':
|
|
2640
|
+
obj.geometry = _extends({}, obj.geometry, {
|
|
2641
|
+
paths: obj.geometry.paths[0]
|
|
2642
|
+
});
|
|
2643
|
+
obj.distance = t.calculateDistance(obj.geometry.paths);
|
|
2644
|
+
break;
|
|
2645
|
+
case 'polygon':
|
|
2646
|
+
obj.geometry = _extends({}, obj.geometry, {
|
|
2647
|
+
rings: obj.geometry.rings[0]
|
|
2648
|
+
});
|
|
2649
|
+
obj.area = (0, _MapToolFunction.getPolygonArea)(obj.geometry.rings);
|
|
2650
|
+
break;
|
|
2651
|
+
}
|
|
2652
|
+
t.props.editGraphicChange(obj);
|
|
2653
|
+
}
|
|
2654
|
+
});
|
|
2655
|
+
//移动开始事件 开启开关 [圆半径]
|
|
2656
|
+
t.editToolbarC.on('graphic-move-start', function (e) {
|
|
2657
|
+
//label可以跟着点位移动,避免label直接跟着鼠标移动
|
|
2658
|
+
t.canMoveLabel = true;
|
|
2659
|
+
});
|
|
2660
|
+
//移动中事件 [圆半径]
|
|
2661
|
+
t.editToolbarC.on('graphic-move', function (e) {
|
|
2662
|
+
//计算鼠标点 与中心点的偏移值
|
|
2663
|
+
if (!t.mouseNowPosition.isCount) {
|
|
2664
|
+
t.mouseNowPosition.isCount = true;
|
|
2665
|
+
t.mouseNowPosition.px = t.mouseNowPosition.x - e.graphic.geometry.x;
|
|
2666
|
+
t.mouseNowPosition.py = t.mouseNowPosition.y - e.graphic.geometry.y;
|
|
2667
|
+
}
|
|
2668
|
+
var cgc = t.GM.getGraphic(t.editId),
|
|
2669
|
+
eid = e.graphic.attributes.id,
|
|
2670
|
+
position = new esri.geometry.Point({
|
|
2671
|
+
longitude: t.mouseNowPosition.x - t.mouseNowPosition.px,
|
|
2672
|
+
latitude: t.mouseNowPosition.y - t.mouseNowPosition.py,
|
|
2673
|
+
spatialReference: { wkid: t.grwkid }
|
|
2674
|
+
}),
|
|
2675
|
+
radius = t.calculatePointsDistance([cgc.geometry.center.x, cgc.geometry.center.y], [t.mouseNowPosition.x - t.mouseNowPosition.px, t.mouseNowPosition.y - t.mouseNowPosition.py]);
|
|
2676
|
+
t.circleEditPXY = {
|
|
2677
|
+
px: cgc.geometry.center.x - (t.mouseNowPosition.x - t.mouseNowPosition.px),
|
|
2678
|
+
py: cgc.geometry.center.y - (t.mouseNowPosition.y - t.mouseNowPosition.py)
|
|
2679
|
+
};
|
|
2680
|
+
cgc.setGeometry(new esri.geometry.Circle({
|
|
2681
|
+
center: new esri.geometry.Point(cgc.geometry.center.x, cgc.geometry.center.y),
|
|
2682
|
+
radius: radius
|
|
2683
|
+
}));
|
|
2684
|
+
t.GM.getGraphic('vtx-circleRadius').setGeometry(position);
|
|
2685
|
+
t.state.gis.graphics.refresh();
|
|
2686
|
+
});
|
|
2687
|
+
//移动结束后事件 [圆半径]
|
|
2688
|
+
t.editToolbarC.on('graphic-move-stop', function (e) {
|
|
2689
|
+
t.canMoveLabel = false;
|
|
2690
|
+
t.mouseNowPosition.isCount = false;
|
|
2691
|
+
var cgc = t.GM.getGraphic(t.editId),
|
|
2692
|
+
eid = e.graphic.attributes.id,
|
|
2693
|
+
position = new esri.geometry.Point({
|
|
2694
|
+
longitude: t.mouseNowPosition.x - t.mouseNowPosition.px,
|
|
2695
|
+
latitude: t.mouseNowPosition.y - t.mouseNowPosition.py,
|
|
2696
|
+
spatialReference: { wkid: t.grwkid }
|
|
2697
|
+
}),
|
|
2698
|
+
radius = t.calculatePointsDistance([cgc.geometry.center.x, cgc.geometry.center.y], [t.mouseNowPosition.x - t.mouseNowPosition.px, t.mouseNowPosition.y - t.mouseNowPosition.py]);
|
|
2699
|
+
t.circleEditPXY = {
|
|
2700
|
+
px: cgc.geometry.center.x - (t.mouseNowPosition.x - t.mouseNowPosition.px),
|
|
2701
|
+
py: cgc.geometry.center.y - (t.mouseNowPosition.y - t.mouseNowPosition.py)
|
|
2702
|
+
};
|
|
2703
|
+
cgc.setGeometry(new esri.geometry.Circle({
|
|
2704
|
+
center: new esri.geometry.Point(cgc.geometry.center.x, cgc.geometry.center.y),
|
|
2705
|
+
radius: radius
|
|
2706
|
+
}));
|
|
2707
|
+
t.GM.getGraphic('vtx-circleRadius').setGeometry(position);
|
|
2708
|
+
t.state.gis.graphics.refresh();
|
|
2709
|
+
if ('editGraphicChange' in t.props && typeof t.props.editGraphicChange == 'function') {
|
|
2710
|
+
var param = t.getGraphic(t.editId);
|
|
2711
|
+
t.props.editGraphicChange({
|
|
2712
|
+
area: Math.PI * Math.pow(t.GM.getGraphic(t.editId).geometry.radius, 2),
|
|
2713
|
+
e: t.GM.getGraphic(t.editId),
|
|
2714
|
+
param: param,
|
|
2715
|
+
id: t.editId,
|
|
2716
|
+
geometry: t.GM.getGraphic(t.editId).geometry
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
//取消上一次的编辑
|
|
2722
|
+
if (t.editId) {
|
|
2723
|
+
t.editToolbar.deactivate();
|
|
2724
|
+
t.editToolbarC.deactivate();
|
|
2725
|
+
}
|
|
2726
|
+
//获取图元对象
|
|
2727
|
+
var gc = t.GM.getGraphic(id);
|
|
2728
|
+
var gp = t.GM.getGraphicParam(id);
|
|
2729
|
+
if (!gc) return;
|
|
2730
|
+
switch (gp.geometryType) {
|
|
2731
|
+
case 'point':
|
|
2732
|
+
//将编辑的图元放在最上面
|
|
2733
|
+
t.czIndex(id);
|
|
2734
|
+
if (t.zIndexGraphics.indexOf(id) == -1) {
|
|
2735
|
+
t.zIndexGraphics.push(id);
|
|
2736
|
+
}
|
|
2737
|
+
t.editToolbar.activate(esri.toolbars.Edit.MOVE, gc);
|
|
2738
|
+
break;
|
|
2739
|
+
case 'polyline':
|
|
2740
|
+
case 'polygon':
|
|
2741
|
+
t.editToolbar.activate(esri.toolbars.Edit.EDIT_VERTICES, gc);
|
|
2742
|
+
break;
|
|
2743
|
+
case 'circle':
|
|
2744
|
+
// 移动圆的中心点 和 移动圆的半径点
|
|
2745
|
+
t.addPoint([{
|
|
2746
|
+
id: 'vtx-circleMove',
|
|
2747
|
+
longitude: gc.geometry.center.x,
|
|
2748
|
+
latitude: gc.geometry.center.y,
|
|
2749
|
+
url: 'http://api0.map.bdimg.com/images/node.gif',
|
|
2750
|
+
config: {
|
|
2751
|
+
width: 11,
|
|
2752
|
+
height: 11,
|
|
2753
|
+
markerContentY: -5.5,
|
|
2754
|
+
markerContentX: -5.5
|
|
2755
|
+
}
|
|
2756
|
+
}, {
|
|
2757
|
+
id: 'vtx-circleRadius',
|
|
2758
|
+
longitude: gc.geometry.rings[0][0][0],
|
|
2759
|
+
latitude: gc.geometry.rings[0][0][1],
|
|
2760
|
+
url: 'http://api0.map.bdimg.com/images/node.gif',
|
|
2761
|
+
config: {
|
|
2762
|
+
width: 11,
|
|
2763
|
+
height: 11,
|
|
2764
|
+
markerContentY: -5.5,
|
|
2765
|
+
markerContentX: -5.5
|
|
2766
|
+
}
|
|
2767
|
+
}]);
|
|
2768
|
+
t.circleEditPXY = {
|
|
2769
|
+
px: gc.geometry.center.x - gc.geometry.rings[0][0][0],
|
|
2770
|
+
py: gc.geometry.center.y - gc.geometry.rings[0][0][1]
|
|
2771
|
+
};
|
|
2772
|
+
t.czIndex('vtx-circleMove');
|
|
2773
|
+
t.czIndex('vtx-circleRadius');
|
|
2774
|
+
if (t.zIndexGraphics.indexOf('vtx-circleMove') == -1) {
|
|
2775
|
+
t.zIndexGraphics.push('vtx-circleMove');
|
|
2776
|
+
}
|
|
2777
|
+
if (t.zIndexGraphics.indexOf('vtx-circleRadius') == -1) {
|
|
2778
|
+
t.zIndexGraphics.push('vtx-circleRadius');
|
|
2779
|
+
}
|
|
2780
|
+
t.editToolbar.activate(esri.toolbars.Edit.MOVE, t.GM.getGraphic('vtx-circleMove'));
|
|
2781
|
+
t.editToolbarC.activate(esri.toolbars.Edit.MOVE, t.GM.getGraphic('vtx-circleRadius'));
|
|
2782
|
+
break;
|
|
2783
|
+
}
|
|
2784
|
+
//开启点编辑功能
|
|
2785
|
+
t.editId = id;
|
|
2786
|
+
}
|
|
2787
|
+
//关闭编辑
|
|
2788
|
+
|
|
2789
|
+
}, {
|
|
2790
|
+
key: 'endEdit',
|
|
2791
|
+
value: function endEdit() {
|
|
2792
|
+
var t = this;
|
|
2793
|
+
t.editToolbar.deactivate();
|
|
2794
|
+
//单独为了圆的
|
|
2795
|
+
t.editToolbarC.deactivate();
|
|
2796
|
+
}
|
|
2797
|
+
//绘制图元
|
|
2798
|
+
|
|
2799
|
+
}, {
|
|
2800
|
+
key: 'draw',
|
|
2801
|
+
value: function draw(obj) {
|
|
2802
|
+
var t = this;
|
|
2803
|
+
if (!t.drawToolbar) {
|
|
2804
|
+
t.drawToolbar = new esri.toolbars.Draw(t.state.gis, {
|
|
2805
|
+
drawTime: 90,
|
|
2806
|
+
showTooltips: false
|
|
2807
|
+
});
|
|
2808
|
+
t.drawToolbar.on('draw-complete', function (e) {
|
|
2809
|
+
//关闭绘制事件
|
|
2810
|
+
t.closeDraw();
|
|
2811
|
+
//返回参数
|
|
2812
|
+
var param = {};
|
|
2813
|
+
// 绘制内部管理的图元
|
|
2814
|
+
if (t.drawParam.geometryType == 'point') {
|
|
2815
|
+
t.addPoint([{
|
|
2816
|
+
id: t.drawParam.data.id,
|
|
2817
|
+
longitude: e.geometry.x,
|
|
2818
|
+
latitude: e.geometry.y,
|
|
2819
|
+
url: t.drawParam.parameter.url || _default2.default.mapServerURL + '/images/defaultMarker.png',
|
|
2820
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2821
|
+
}], 'point');
|
|
2822
|
+
//处理点返回参数
|
|
2823
|
+
param = {
|
|
2824
|
+
id: t.drawParam.data.id,
|
|
2825
|
+
attributes: {
|
|
2826
|
+
id: t.drawParam.data.id,
|
|
2827
|
+
url: t.drawParam.parameter.url || _default2.default.mapServerURL + '/images/defaultMarker.png',
|
|
2828
|
+
config: {
|
|
2829
|
+
width: t.drawParam.parameter.width || 30,
|
|
2830
|
+
height: t.drawParam.parameter.height || 30
|
|
2831
|
+
}
|
|
2832
|
+
},
|
|
2833
|
+
geometry: e.geometry,
|
|
2834
|
+
geometryType: 'point',
|
|
2835
|
+
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
2836
|
+
};
|
|
2837
|
+
}
|
|
2838
|
+
//线
|
|
2839
|
+
if (t.drawParam.geometryType == 'polyline') {
|
|
2840
|
+
t.addLine([{
|
|
2841
|
+
id: t.drawParam.data.id,
|
|
2842
|
+
paths: e.geometry.paths[0],
|
|
2843
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2844
|
+
}], 'polyline');
|
|
2845
|
+
//处理线返回参数
|
|
2846
|
+
|
|
2847
|
+
var _t$dealData4 = t.dealData(e.geometry.paths[0]),
|
|
2848
|
+
lnglatAry = _t$dealData4.lnglatAry,
|
|
2849
|
+
_extent = _t$dealData4._extent;
|
|
2850
|
+
|
|
2851
|
+
param = {
|
|
2852
|
+
lnglatAry: lnglatAry,
|
|
2853
|
+
id: t.drawParam.data.id,
|
|
2854
|
+
geometry: _extends({}, e.geometry, {
|
|
2855
|
+
paths: e.geometry.paths[0],
|
|
2856
|
+
_extent: _extent
|
|
2857
|
+
}),
|
|
2858
|
+
attributes: {
|
|
2859
|
+
id: t.drawParam.data.id,
|
|
2860
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2861
|
+
},
|
|
2862
|
+
distance: t.calculateDistance(e.geometry.paths[0]),
|
|
2863
|
+
geometryType: 'polyline',
|
|
2864
|
+
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
2865
|
+
};
|
|
2866
|
+
}
|
|
2867
|
+
if (t.drawParam.geometryType == 'polygon' || t.drawParam.geometryType == 'rectangle') {
|
|
2868
|
+
var rs = [].concat(_toConsumableArray(e.geometry.rings[0]));
|
|
2869
|
+
rs.pop();
|
|
2870
|
+
t.addPolygon([{
|
|
2871
|
+
id: t.drawParam.data.id,
|
|
2872
|
+
rings: rs,
|
|
2873
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2874
|
+
}], t.drawParam.geometryType);
|
|
2875
|
+
//处理面返回参数
|
|
2876
|
+
|
|
2877
|
+
var _t$dealData5 = t.dealData(e.geometry.rings[0]),
|
|
2878
|
+
_lnglatAry = _t$dealData5.lnglatAry,
|
|
2879
|
+
_extent2 = _t$dealData5._extent;
|
|
2880
|
+
|
|
2881
|
+
param = {
|
|
2882
|
+
lnglatAry: _lnglatAry,
|
|
2883
|
+
id: t.drawParam.data.id,
|
|
2884
|
+
geometry: _extends({}, e.geometry, {
|
|
2885
|
+
rings: e.geometry.rings[0],
|
|
2886
|
+
type: t.drawParam.geometryType,
|
|
2887
|
+
_extent: _extent2
|
|
2888
|
+
}),
|
|
2889
|
+
attributes: {
|
|
2890
|
+
id: t.drawParam.data.id,
|
|
2891
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2892
|
+
},
|
|
2893
|
+
area: (0, _MapToolFunction.getPolygonArea)(e.geometry.rings[0]),
|
|
2894
|
+
geometryType: t.drawParam.geometryType,
|
|
2895
|
+
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
2896
|
+
};
|
|
2897
|
+
}
|
|
2898
|
+
if (t.drawParam.geometryType == 'circle') {
|
|
2899
|
+
if (e.geometry._extent) {
|
|
2900
|
+
var radius = (0, _MapToolFunction.getDistance)([e.geometry._extent.xmin, e.geometry._extent.ymin], [e.geometry._extent.xmax, e.geometry._extent.ymax], t.state.gis, t.grwkid) / 2;
|
|
2901
|
+
radius = Math.sqrt(Math.pow(radius, 2) * 2) / 2;
|
|
2902
|
+
t.addCircle([{
|
|
2903
|
+
id: t.drawParam.data.id,
|
|
2904
|
+
longitude: (e.geometry._extent.xmin + e.geometry._extent.xmax) / 2,
|
|
2905
|
+
latitude: (e.geometry._extent.ymin + e.geometry._extent.ymax) / 2,
|
|
2906
|
+
radius: radius,
|
|
2907
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2908
|
+
}], t.drawParam.geometryType);
|
|
2909
|
+
param = {
|
|
2910
|
+
area: Math.PI * Math.pow(radius, 2),
|
|
2911
|
+
attributes: {
|
|
2912
|
+
id: t.drawParam.data.id,
|
|
2913
|
+
config: _extends({}, t.drawParam.parameter)
|
|
2914
|
+
},
|
|
2915
|
+
geometry: {
|
|
2916
|
+
type: t.drawParam.geometryType,
|
|
2917
|
+
x: (e.geometry._extent.xmin + e.geometry._extent.xmax) / 2,
|
|
2918
|
+
y: (e.geometry._extent.ymin + e.geometry._extent.ymax) / 2,
|
|
2919
|
+
radius: radius
|
|
2920
|
+
},
|
|
2921
|
+
geometryType: t.drawParam.geometryType,
|
|
2922
|
+
mapLayer: t.GM.getGraphic(t.drawParam.data.id)
|
|
2923
|
+
};
|
|
2924
|
+
}
|
|
2925
|
+
}
|
|
2926
|
+
// t.GM.setGraphicParam(t.drawParam.data.id,param);
|
|
2927
|
+
//绘制返回
|
|
2928
|
+
if ('drawEnd' in t.props && typeof t.props.drawEnd == 'function') {
|
|
2929
|
+
t.props.drawEnd(param);
|
|
2930
|
+
}
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
//避免连点
|
|
2934
|
+
t.closeDraw();
|
|
2935
|
+
$('#' + t.props.mapId + '_container').css({
|
|
2936
|
+
cursor: 'crosshair'
|
|
2937
|
+
});
|
|
2938
|
+
var drawParam = {};
|
|
2939
|
+
//初始化参数
|
|
2940
|
+
drawParam.geometryType = obj.geometryType || 'point';
|
|
2941
|
+
drawParam.parameter = obj.parameter ? _extends({}, obj.parameter) : {};
|
|
2942
|
+
drawParam.data = obj.data ? _extends({}, obj.data) : {};
|
|
2943
|
+
drawParam.data.id = (obj.data || {}).id || 'draw' + new Date().getTime();
|
|
2944
|
+
//缓存 绘制的数据
|
|
2945
|
+
t.drawParam = drawParam;
|
|
2946
|
+
//判断id是否存在
|
|
2947
|
+
var len = t.state.drawIds[drawParam.geometryType].indexOf(drawParam.data.id);
|
|
2948
|
+
if (len > -1) {
|
|
2949
|
+
//如果id存在 删除存在的图元,清除drawId中的id数据
|
|
2950
|
+
t.removeGraphic(drawParam.data.id);
|
|
2951
|
+
t.state.drawIds[drawParam.geometryType].splice(len, 1);
|
|
2952
|
+
}
|
|
2953
|
+
var lineSymbol = null,
|
|
2954
|
+
fillSymbol = null;
|
|
2955
|
+
if (drawParam.geometryType !== 'point') {
|
|
2956
|
+
//线类型
|
|
2957
|
+
var lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
2958
|
+
switch (drawParam.parameter.lineType) {
|
|
2959
|
+
case 'solid':
|
|
2960
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_SOLID;
|
|
2961
|
+
break;
|
|
2962
|
+
case 'dashed':
|
|
2963
|
+
lineStyle = esri.symbol.SimpleLineSymbol.STYLE_DASH;
|
|
2964
|
+
break;
|
|
2965
|
+
}
|
|
2966
|
+
//处理边框线颜色和透明度 使用rgba处理透明度
|
|
2967
|
+
var lineColor = null;
|
|
2968
|
+
//线和面圆的线透明参数不同
|
|
2969
|
+
if (drawParam.geometryType == 'polyline') {
|
|
2970
|
+
lineColor = new esri.Color(drawParam.parameter.color);
|
|
2971
|
+
lineColor.a = drawParam.parameter.pellucidity;
|
|
2972
|
+
} else {
|
|
2973
|
+
lineColor = new esri.Color(drawParam.parameter.lineColor);
|
|
2974
|
+
lineColor.a = drawParam.parameter.lineOpacity;
|
|
2975
|
+
}
|
|
2976
|
+
//生成线类型对象
|
|
2977
|
+
lineSymbol = new esri.symbol.SimpleLineSymbol(lineStyle, lineColor, drawParam.parameter.lineWidth);
|
|
2978
|
+
} else {
|
|
2979
|
+
//点的样式
|
|
2980
|
+
var markerSymbol = new esri.symbol.PictureMarkerSymbol(drawParam.parameter.url || _default2.default.mapServerURL + '/images/defaultMarker.png', drawParam.parameter.width || 30, drawParam.parameter.height || 30);
|
|
2981
|
+
//设置点偏移
|
|
2982
|
+
markerSymbol.setOffset((drawParam.parameter.markerContentX || -15) + (drawParam.parameter.width || 30) / 2, -((drawParam.parameter.markerContentY || -15) + (drawParam.parameter.height || 30) / 2));
|
|
2983
|
+
t.drawToolbar.setMarkerSymbol(markerSymbol);
|
|
2984
|
+
}
|
|
2985
|
+
//处理面 矩形 圆的样式
|
|
2986
|
+
if (drawParam.geometryType == 'polygon' || drawParam.geometryType == 'circle' || drawParam.geometryType == 'rectangle') {
|
|
2987
|
+
//创建面对象
|
|
2988
|
+
fillSymbol = new esri.symbol.SimpleFillSymbol();
|
|
2989
|
+
//添加边框线数据
|
|
2990
|
+
fillSymbol.setOutline(lineSymbol);
|
|
2991
|
+
//处理填充颜色和透明度 使用rgba处理透明度
|
|
2992
|
+
var dColor = new esri.Color(drawParam.parameter.color);
|
|
2993
|
+
dColor.a = drawParam.parameter.pellucidity;
|
|
2994
|
+
fillSymbol.setColor(dColor);
|
|
2995
|
+
//添加线的样式
|
|
2996
|
+
t.drawToolbar.setFillSymbol(fillSymbol);
|
|
2997
|
+
t.drawToolbar.setRespectDrawingVertexOrder(true);
|
|
2998
|
+
}
|
|
2999
|
+
//重新设置绘制类型和数据
|
|
3000
|
+
var geometryType = esri.toolbars.Draw.POINT;
|
|
3001
|
+
switch (drawParam.geometryType) {
|
|
3002
|
+
case 'point':
|
|
3003
|
+
geometryType = esri.toolbars.Draw.POINT;
|
|
3004
|
+
|
|
3005
|
+
break;
|
|
3006
|
+
case 'polyline':
|
|
3007
|
+
geometryType = esri.toolbars.Draw.POLYLINE;
|
|
3008
|
+
//添加线的样式
|
|
3009
|
+
t.drawToolbar.setLineSymbol(lineSymbol);
|
|
3010
|
+
break;
|
|
3011
|
+
case 'polygon':
|
|
3012
|
+
geometryType = esri.toolbars.Draw.POLYGON;
|
|
3013
|
+
break;
|
|
3014
|
+
case 'circle':
|
|
3015
|
+
geometryType = esri.toolbars.Draw.CIRCLE;
|
|
3016
|
+
break;
|
|
3017
|
+
case 'rectangle':
|
|
3018
|
+
geometryType = esri.toolbars.Draw.RECTANGLE;
|
|
3019
|
+
break;
|
|
3020
|
+
}
|
|
3021
|
+
t.drawToolbar.activate(geometryType);
|
|
3022
|
+
}
|
|
3023
|
+
//关闭绘制
|
|
3024
|
+
|
|
3025
|
+
}, {
|
|
3026
|
+
key: 'closeDraw',
|
|
3027
|
+
value: function closeDraw() {
|
|
3028
|
+
var t = this;
|
|
3029
|
+
if (t.drawToolbar) {
|
|
3030
|
+
$('#' + t.props.mapId + '_container').css({
|
|
3031
|
+
cursor: 'default'
|
|
3032
|
+
});
|
|
3033
|
+
//先关闭上次绘制的事件
|
|
3034
|
+
t.drawToolbar.finishDrawing();
|
|
3035
|
+
//销毁上次绘制的类型设定
|
|
3036
|
+
t.drawToolbar.deactivate();
|
|
3037
|
+
}
|
|
3038
|
+
}
|
|
3039
|
+
//点聚合
|
|
3040
|
+
|
|
3041
|
+
}, {
|
|
3042
|
+
key: 'cluster',
|
|
3043
|
+
value: function cluster(ids) {
|
|
3044
|
+
var t = this;
|
|
3045
|
+
//获取聚合点id 空则是全部点位
|
|
3046
|
+
t.clusterMarkers = t.clusterToolFunction(ids);
|
|
3047
|
+
//处理聚合点逻辑
|
|
3048
|
+
t.dealClusterPoint();
|
|
3049
|
+
}
|
|
3050
|
+
//处理聚合点逻辑
|
|
3051
|
+
|
|
3052
|
+
}, {
|
|
3053
|
+
key: 'dealClusterPoint',
|
|
3054
|
+
value: function dealClusterPoint() {
|
|
3055
|
+
var t = this;
|
|
3056
|
+
//当前窗口信息
|
|
3057
|
+
var ext = t.dealExtendBounds(t.state.gis.extent);
|
|
3058
|
+
t.clusterPs = [];
|
|
3059
|
+
//清除原来聚合点
|
|
3060
|
+
for (var i = 0; i < t.clusterPt.length; i++) {
|
|
3061
|
+
t.state.gis.graphics.remove(t.clusterPt[i].graphic);
|
|
3062
|
+
t.state.gis.graphics.remove(t.clusterPt[i].graphicText);
|
|
3063
|
+
}
|
|
3064
|
+
for (var _i11 = 0; _i11 < t.clusterMarkers.length; _i11++) {
|
|
3065
|
+
t.clusterMarkers[_i11].isCluster = false;
|
|
3066
|
+
}
|
|
3067
|
+
//处理后的聚合点位数据
|
|
3068
|
+
for (var _i12 = 0; _i12 < t.clusterMarkers.length; _i12++) {
|
|
3069
|
+
var gc = t.clusterMarkers[_i12].marker,
|
|
3070
|
+
distance = 4000000,
|
|
3071
|
+
newCluster = null;
|
|
3072
|
+
//过滤不是点的图元id
|
|
3073
|
+
if (gc.geometry.type !== 'point') {
|
|
3074
|
+
console.warning('\u8BBE\u7F6E\u805A\u5408\u7684\u56FE\u5143\u4E0D\u7B26\u53F7\u7C7B\u578B!');
|
|
3075
|
+
} else {
|
|
3076
|
+
//过滤窗口视线外的点位
|
|
3077
|
+
if (ext.contains(gc.geometry)) {
|
|
3078
|
+
//聚合点集合空时 创建一个集合
|
|
3079
|
+
if (t.clusterPs.length === 0) {
|
|
3080
|
+
t.createCluster(t.clusterMarkers[_i12]);
|
|
3081
|
+
} else {
|
|
3082
|
+
for (var j = 0; j < t.clusterPs.length; j++) {
|
|
3083
|
+
//判断点是否在聚合点范围内
|
|
3084
|
+
var d = t.calculatePointsDistance([gc.geometry.x, gc.geometry.y], [t.clusterPs[j].center.x, t.clusterPs[j].center.y]);
|
|
3085
|
+
//获取最优聚合点
|
|
3086
|
+
if (d < distance) {
|
|
3087
|
+
distance = d;
|
|
3088
|
+
newCluster = t.clusterPs[j];
|
|
3089
|
+
}
|
|
3090
|
+
}
|
|
3091
|
+
//存在聚合 就添加进聚合 没有聚合就新建一个自己的聚合
|
|
3092
|
+
if (newCluster && newCluster.extent.contains(gc.geometry)) {
|
|
3093
|
+
t.clusterMarkers[_i12].isCluster = true;
|
|
3094
|
+
newCluster.markers.push(t.clusterMarkers[_i12]);
|
|
3095
|
+
newCluster.isreal = true;
|
|
3096
|
+
} else {
|
|
3097
|
+
t.createCluster(t.clusterMarkers[_i12]);
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
}
|
|
3103
|
+
//添加cluster聚合点
|
|
3104
|
+
for (var _i13 = 0; _i13 < t.clusterPs.length; _i13++) {
|
|
3105
|
+
if (t.clusterPs[_i13].isreal) {
|
|
3106
|
+
//添加聚合集合点
|
|
3107
|
+
t.addClusterPoint(t.clusterPs[_i13]);
|
|
3108
|
+
} else {
|
|
3109
|
+
var m = t.clusterPs[_i13].markers[0];
|
|
3110
|
+
if (!m.marker.getNode()) {
|
|
3111
|
+
//存在html的label处理
|
|
3112
|
+
if (m.html) {
|
|
3113
|
+
t.dealLabelGraphics(m.id, m.html);
|
|
3114
|
+
}
|
|
3115
|
+
//添加回原有的点
|
|
3116
|
+
t.state.gis.graphics.add(m.marker);
|
|
3117
|
+
}
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
}
|
|
3121
|
+
//处理聚合点的添加
|
|
3122
|
+
|
|
3123
|
+
}, {
|
|
3124
|
+
key: 'addClusterPoint',
|
|
3125
|
+
value: function addClusterPoint(cluster) {
|
|
3126
|
+
var t = this;
|
|
3127
|
+
var len = cluster.markers.length,
|
|
3128
|
+
ids = [];
|
|
3129
|
+
var url = 'http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m4.png',
|
|
3130
|
+
w = 90;
|
|
3131
|
+
if (len < 50) {
|
|
3132
|
+
url = 'http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m3.png';
|
|
3133
|
+
w = 78;
|
|
3134
|
+
}
|
|
3135
|
+
if (len < 30) {
|
|
3136
|
+
url = 'http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m2.png';
|
|
3137
|
+
w = 66;
|
|
3138
|
+
}
|
|
3139
|
+
if (len < 20) {
|
|
3140
|
+
url = 'http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m1.png';
|
|
3141
|
+
w = 56;
|
|
3142
|
+
}
|
|
3143
|
+
if (len < 10) {
|
|
3144
|
+
url = 'http://api.map.baidu.com/library/TextIconOverlay/1.2/src/images/m0.png';
|
|
3145
|
+
w = 53;
|
|
3146
|
+
}
|
|
3147
|
+
//处理聚合中点位
|
|
3148
|
+
for (var i = 0; i < len; i++) {
|
|
3149
|
+
ids.push(cluster.markers[i].id);
|
|
3150
|
+
if (cluster.markers[i].marker.getNode()) {
|
|
3151
|
+
t.state.gis.graphics.remove(cluster.markers[i].marker);
|
|
3152
|
+
if (cluster.markers[i].html) {
|
|
3153
|
+
cluster.markers[i].html.html.remove();
|
|
3154
|
+
}
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
//添加聚合点
|
|
3158
|
+
var markerSymbol = new esri.symbol.PictureMarkerSymbol(url, w, w);
|
|
3159
|
+
//设置文字点位(记录聚合点数量)
|
|
3160
|
+
var text = new esri.symbol.TextSymbol(len).setColor(new esri.Color('#fff'));
|
|
3161
|
+
//文字居中
|
|
3162
|
+
text.setOffset(0.5, -5);
|
|
3163
|
+
//创建点位对象
|
|
3164
|
+
var graphic = new esri.Graphic(cluster.center, markerSymbol, { id: 'vtx-clusterPoint', ids: ids, cluster: cluster }),
|
|
3165
|
+
graphicText = new esri.Graphic(cluster.center, text, { id: 'vtx-clusterPoint', ids: ids, cluster: cluster });
|
|
3166
|
+
//添加聚合点位到地图
|
|
3167
|
+
t.state.gis.graphics.add(graphic);
|
|
3168
|
+
t.state.gis.graphics.add(graphicText);
|
|
3169
|
+
t.clusterPt.push({ graphic: graphic, graphicText: graphicText });
|
|
3170
|
+
}
|
|
3171
|
+
//新增cluster
|
|
3172
|
+
|
|
3173
|
+
}, {
|
|
3174
|
+
key: 'createCluster',
|
|
3175
|
+
value: function createCluster(m) {
|
|
3176
|
+
var t = this;
|
|
3177
|
+
var gc = m.marker;
|
|
3178
|
+
//不是集合里面的点
|
|
3179
|
+
if (!m.isCluster) {
|
|
3180
|
+
m.isCluster = true;
|
|
3181
|
+
t.clusterPs.push({
|
|
3182
|
+
extent: t.dealExtendBounds(gc._extent),
|
|
3183
|
+
center: gc.geometry,
|
|
3184
|
+
markers: [m],
|
|
3185
|
+
isreal: false
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
//处理聚合的间距
|
|
3190
|
+
|
|
3191
|
+
}, {
|
|
3192
|
+
key: 'dealExtendBounds',
|
|
3193
|
+
value: function dealExtendBounds(extent, area) {
|
|
3194
|
+
var t = this,
|
|
3195
|
+
bound = area || 60;
|
|
3196
|
+
var ne = new esri.geometry.Point(extent.xmax, extent.ymax),
|
|
3197
|
+
sw = new esri.geometry.Point(extent.xmin, extent.ymin),
|
|
3198
|
+
pixelNe = t.state.gis.toScreen(ne),
|
|
3199
|
+
pixelSw = t.state.gis.toScreen(sw);
|
|
3200
|
+
pixelNe.x += bound;
|
|
3201
|
+
pixelNe.y -= bound;
|
|
3202
|
+
pixelSw.x -= bound;
|
|
3203
|
+
pixelSw.y += bound;
|
|
3204
|
+
var newNe = t.state.gis.toMap(pixelNe),
|
|
3205
|
+
newSw = t.state.gis.toMap(pixelSw);
|
|
3206
|
+
return new esri.geometry.Extent(newSw.x, newSw.y, newNe.x, newNe.y, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
3207
|
+
}
|
|
3208
|
+
//聚合功能公共方法(获取图元集合)
|
|
3209
|
+
|
|
3210
|
+
}, {
|
|
3211
|
+
key: 'clusterToolFunction',
|
|
3212
|
+
value: function clusterToolFunction(arg) {
|
|
3213
|
+
var t = this;
|
|
3214
|
+
var ary = [];
|
|
3215
|
+
if (!arg) {
|
|
3216
|
+
var pointIds = t.state.pointIds;
|
|
3217
|
+
|
|
3218
|
+
ary = pointIds;
|
|
3219
|
+
} else {
|
|
3220
|
+
if (Object.prototype.toString.apply(arg) === '[object Array]') {
|
|
3221
|
+
ary = arg;
|
|
3222
|
+
} else if (typeof arg === 'string') {
|
|
3223
|
+
ary = arg.split(',');
|
|
3224
|
+
}
|
|
3225
|
+
}
|
|
3226
|
+
var markerList = [];
|
|
3227
|
+
for (var i = 0; i < ary.length; i++) {
|
|
3228
|
+
var obj = {
|
|
3229
|
+
id: ary[i],
|
|
3230
|
+
marker: t.GM.getGraphic(ary[i]),
|
|
3231
|
+
isCluster: false
|
|
3232
|
+
};
|
|
3233
|
+
if (t.Label[ary[i]]) {
|
|
3234
|
+
obj.html = t.Label[ary[i]];
|
|
3235
|
+
}
|
|
3236
|
+
markerList.push(obj);
|
|
3237
|
+
}
|
|
3238
|
+
return markerList;
|
|
3239
|
+
}
|
|
3240
|
+
//设置区域限制
|
|
3241
|
+
|
|
3242
|
+
}, {
|
|
3243
|
+
key: 'setAreaRestriction',
|
|
3244
|
+
value: function setAreaRestriction(areaRestriction) {
|
|
3245
|
+
var t = this;
|
|
3246
|
+
|
|
3247
|
+
var _t$dealData6 = t.dealData(areaRestriction),
|
|
3248
|
+
_et = _t$dealData6._extent;
|
|
3249
|
+
|
|
3250
|
+
t.areaRestriction = new esri.geometry.Extent(_extends({}, _et, { spatialReference: { wkid: t.grwkid }
|
|
3251
|
+
}));
|
|
3252
|
+
}
|
|
3253
|
+
//关闭区域限制
|
|
3254
|
+
|
|
3255
|
+
}, {
|
|
3256
|
+
key: 'clearAreaRestriction',
|
|
3257
|
+
value: function clearAreaRestriction() {
|
|
3258
|
+
var t = this;
|
|
3259
|
+
t.areaRestriction = null;
|
|
3260
|
+
}
|
|
3261
|
+
//区域限制逻辑
|
|
3262
|
+
|
|
3263
|
+
}, {
|
|
3264
|
+
key: 'dealAreaRestriction',
|
|
3265
|
+
value: function dealAreaRestriction(e) {
|
|
3266
|
+
var t = this;
|
|
3267
|
+
//如果在区域内,不处理
|
|
3268
|
+
if (t.areaRestriction.contains(e.extent.getCenter())) {
|
|
3269
|
+
return;
|
|
3270
|
+
}
|
|
3271
|
+
// if(t.containsExtent(t.areaRestriction,e.extent)){
|
|
3272
|
+
// return;
|
|
3273
|
+
// }
|
|
3274
|
+
var _t$areaRestriction = t.areaRestriction,
|
|
3275
|
+
xmin1 = _t$areaRestriction.xmin,
|
|
3276
|
+
xmax1 = _t$areaRestriction.xmax,
|
|
3277
|
+
ymin1 = _t$areaRestriction.ymin,
|
|
3278
|
+
ymax1 = _t$areaRestriction.ymax;
|
|
3279
|
+
var _e$extent = e.extent,
|
|
3280
|
+
xmin2 = _e$extent.xmin,
|
|
3281
|
+
xmax2 = _e$extent.xmax,
|
|
3282
|
+
ymin2 = _e$extent.ymin,
|
|
3283
|
+
ymax2 = _e$extent.ymax;
|
|
3284
|
+
|
|
3285
|
+
var x = e.extent.getCenter().x,
|
|
3286
|
+
y = e.extent.getCenter().y;
|
|
3287
|
+
if (x < xmin1) x = xmin1 + 0.1;
|
|
3288
|
+
if (x > xmax1) x = xmax1 - 0.1;
|
|
3289
|
+
if (y < ymin1) y = ymin1 + 0.1;
|
|
3290
|
+
if (y > ymax1) y = ymax1 - 0.1;
|
|
3291
|
+
var center = new esri.geometry.Point(x, y);
|
|
3292
|
+
t.state.gis.centerAt(center);
|
|
3293
|
+
}
|
|
3294
|
+
/*公共方法*/
|
|
3295
|
+
//判断extent1是否在extent2内部
|
|
3296
|
+
|
|
3297
|
+
}, {
|
|
3298
|
+
key: 'containsExtent',
|
|
3299
|
+
value: function containsExtent(e1, e2) {
|
|
3300
|
+
var xmin1 = e1.xmin,
|
|
3301
|
+
xmax1 = e1.xmax,
|
|
3302
|
+
ymin1 = e1.ymin,
|
|
3303
|
+
ymax1 = e1.ymax;
|
|
3304
|
+
var xmin2 = e2.xmin,
|
|
3305
|
+
xmax2 = e2.xmax,
|
|
3306
|
+
ymin2 = e2.ymin,
|
|
3307
|
+
ymax2 = e2.ymax;
|
|
3308
|
+
|
|
3309
|
+
return xmin2 > xmin1 && xmax2 < xmax1 && ymin2 > ymin1 && ymax2 < ymax1;
|
|
3310
|
+
}
|
|
3311
|
+
//将图元z-index设置成最高
|
|
3312
|
+
|
|
3313
|
+
}, {
|
|
3314
|
+
key: 'czIndex',
|
|
3315
|
+
value: function czIndex(id) {
|
|
3316
|
+
var t = this;
|
|
3317
|
+
$('#' + t.props.mapId + '_graphics_layer').append(t.GM.getGraphic(id).getNode());
|
|
3318
|
+
}
|
|
3319
|
+
}, {
|
|
3320
|
+
key: 'equalsPoint',
|
|
3321
|
+
value: function equalsPoint(a, b) {
|
|
3322
|
+
return a.x == b.x && a.y == b.y;
|
|
3323
|
+
}
|
|
3324
|
+
//计算2点间距离 单位m 精确到2位小数
|
|
3325
|
+
|
|
3326
|
+
}, {
|
|
3327
|
+
key: 'calculatePointsDistance',
|
|
3328
|
+
value: function calculatePointsDistance(fp, ep) {
|
|
3329
|
+
return (0, _MapToolFunction.getDistance)(fp, ep, this.state.gis, this.state.grwkid);
|
|
3330
|
+
}
|
|
3331
|
+
//计算多个点的距离(常用于线计算)
|
|
3332
|
+
|
|
3333
|
+
}, {
|
|
3334
|
+
key: 'calculateDistance',
|
|
3335
|
+
value: function calculateDistance(ps) {
|
|
3336
|
+
var t = this,
|
|
3337
|
+
totalDistance = 0;
|
|
3338
|
+
if (ps.length < 0) {
|
|
3339
|
+
return 0;
|
|
3340
|
+
}
|
|
3341
|
+
for (var i = 0; i < ps.length; i++) {
|
|
3342
|
+
if (i < ps.length - 1) {
|
|
3343
|
+
totalDistance += t.calculatePointsDistance(ps[i], ps[i + 1]);
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
return totalDistance;
|
|
3347
|
+
}
|
|
3348
|
+
//处理线和面的 经纬度数据
|
|
3349
|
+
|
|
3350
|
+
}, {
|
|
3351
|
+
key: 'dealData',
|
|
3352
|
+
value: function dealData(paths) {
|
|
3353
|
+
//区别点和圆的经纬度数据处理
|
|
3354
|
+
var lnglatAry = [],
|
|
3355
|
+
_extent = { xmax: 0, xmin: 0, ymax: 0, ymin: 0 },
|
|
3356
|
+
path = [];
|
|
3357
|
+
path = paths.map(function (item, index) {
|
|
3358
|
+
var lng = item[0],
|
|
3359
|
+
lat = item[1];
|
|
3360
|
+
if (lng > _extent.xmax) {
|
|
3361
|
+
_extent.xmax = lng;
|
|
3362
|
+
}
|
|
3363
|
+
if (lng < _extent.xmin || _extent.xmin == 0) {
|
|
3364
|
+
_extent.xmin = lng;
|
|
3365
|
+
}
|
|
3366
|
+
if (lat > _extent.ymax) {
|
|
3367
|
+
_extent.ymax = lat;
|
|
3368
|
+
}
|
|
3369
|
+
if (lat < _extent.ymin || _extent.ymin == 0) {
|
|
3370
|
+
_extent.ymin = lat;
|
|
3371
|
+
}
|
|
3372
|
+
lnglatAry.push({
|
|
3373
|
+
lngX: lng,
|
|
3374
|
+
latX: lat
|
|
3375
|
+
});
|
|
3376
|
+
return [lng, lat];
|
|
3377
|
+
});
|
|
3378
|
+
return { lnglatAry: lnglatAry, _extent: _extent, path: path };
|
|
3379
|
+
}
|
|
3380
|
+
//处理点位图元的添加 和 更新
|
|
3381
|
+
|
|
3382
|
+
}, {
|
|
3383
|
+
key: 'dealLabelGraphics',
|
|
3384
|
+
value: function dealLabelGraphics(id, label) {
|
|
3385
|
+
var t = this;
|
|
3386
|
+
if (label) {
|
|
3387
|
+
var position = (t.GM.getGraphic(id) || {}).geometry || label.position;
|
|
3388
|
+
//经纬度转top和left
|
|
3389
|
+
var tl = t.state.gis.toScreen(position),
|
|
3390
|
+
lbl = _extends({}, label);
|
|
3391
|
+
//渲染優化
|
|
3392
|
+
if (!(tl.y < -50 || tl.x < -50 || tl.y > t.state.gis.height || tl.x > t.state.gis.width)) {
|
|
3393
|
+
//设置label的位置(通过定位来实现)
|
|
3394
|
+
label.html.css({
|
|
3395
|
+
position: 'absolute',
|
|
3396
|
+
top: tl.y + (label.offset.y || 0) - t.labelLayer.y,
|
|
3397
|
+
left: tl.x + (label.offset.x || 0) - t.labelLayer.x
|
|
3398
|
+
});
|
|
3399
|
+
//添加点位到(地图)
|
|
3400
|
+
$('#' + t.htmlPointsId).append(label.html);
|
|
3401
|
+
lbl.add = true;
|
|
3402
|
+
} else {
|
|
3403
|
+
lbl.add = false;
|
|
3404
|
+
}
|
|
3405
|
+
//记录下label的dom对象,用于后期修改和删除(基本是删除)
|
|
3406
|
+
t.Label[id] = lbl;
|
|
3407
|
+
}
|
|
3408
|
+
}
|
|
3409
|
+
//点的跳动动画
|
|
3410
|
+
|
|
3411
|
+
}, {
|
|
3412
|
+
key: 'pointAnimation',
|
|
3413
|
+
value: function pointAnimation(id, marker) {
|
|
3414
|
+
var t = this;
|
|
3415
|
+
//null时关闭跳动
|
|
3416
|
+
if (!!marker) {
|
|
3417
|
+
if (t.animTimer[id]) {
|
|
3418
|
+
clearInterval(t.animTimer[id]);
|
|
3419
|
+
}
|
|
3420
|
+
t.animTimer[id] = setInterval(function () {
|
|
3421
|
+
//点被隐藏时,没有执行,定时不关
|
|
3422
|
+
if (marker.symbol) {
|
|
3423
|
+
var shape = _extends({}, marker.symbol);
|
|
3424
|
+
//初始数据 点位有变动,重新刷新数据
|
|
3425
|
+
if (!t.animCount[id] || shape.yoffset != t.animCount[id].now) {
|
|
3426
|
+
t.animCount[id] = {
|
|
3427
|
+
start: shape.yoffset,
|
|
3428
|
+
now: shape.yoffset,
|
|
3429
|
+
notation: -1
|
|
3430
|
+
};
|
|
3431
|
+
}
|
|
3432
|
+
if (t.animCount[id].now - t.animCount[id].start == 20) {
|
|
3433
|
+
t.animCount[id].notation = -1;
|
|
3434
|
+
}
|
|
3435
|
+
if (t.animCount[id].now - t.animCount[id].start == 0) {
|
|
3436
|
+
t.animCount[id].notation = 1;
|
|
3437
|
+
}
|
|
3438
|
+
shape.yoffset = t.animCount[id].now = t.animCount[id].now + t.animCount[id].notation * 2;
|
|
3439
|
+
marker.symbol.setOffset(shape.xoffset, shape.yoffset);
|
|
3440
|
+
t.state.gis.graphics.refresh();
|
|
3441
|
+
}
|
|
3442
|
+
}, 35);
|
|
3443
|
+
} else {
|
|
3444
|
+
clearInterval(t.animTimer[id]);
|
|
3445
|
+
}
|
|
3446
|
+
}
|
|
3447
|
+
}, {
|
|
3448
|
+
key: 'moveAnimation',
|
|
3449
|
+
value: function moveAnimation() {
|
|
3450
|
+
var t = this;
|
|
3451
|
+
if (t.moveToTimer) {
|
|
3452
|
+
clearInterval(t.moveToTimer);
|
|
3453
|
+
}
|
|
3454
|
+
t.moveToTimer = setInterval(function () {
|
|
3455
|
+
for (var i = 0; i < t.movePoints.length; i++) {
|
|
3456
|
+
t.movePoints[i].waitTime += 10;
|
|
3457
|
+
t.movePoints[i].deleteTime -= 10;
|
|
3458
|
+
}
|
|
3459
|
+
t.movePoints.sort(function (x, y) {
|
|
3460
|
+
return y.waitTime - x.waitTime;
|
|
3461
|
+
});
|
|
3462
|
+
var nowMovePoints = t.movePoints.slice(0, 10),
|
|
3463
|
+
deleteIndex = [];
|
|
3464
|
+
for (var _i14 = 0; _i14 < nowMovePoints.length; _i14++) {
|
|
3465
|
+
var _nowMovePoints$_i = nowMovePoints[_i14],
|
|
3466
|
+
id = _nowMovePoints$_i.id,
|
|
3467
|
+
rx = _nowMovePoints$_i.rx,
|
|
3468
|
+
ry = _nowMovePoints$_i.ry,
|
|
3469
|
+
waitTime = _nowMovePoints$_i.waitTime,
|
|
3470
|
+
deleteTime = _nowMovePoints$_i.deleteTime,
|
|
3471
|
+
ddeg = _nowMovePoints$_i.ddeg;
|
|
3472
|
+
|
|
3473
|
+
var gc = t.GM.getGraphic(id);
|
|
3474
|
+
if (!gc || !gc._graphicsLayer) {
|
|
3475
|
+
clearInterval(t.moveToTimer);
|
|
3476
|
+
} else {
|
|
3477
|
+
var gg = gc.geometry;
|
|
3478
|
+
var tx = gg.x + rx,
|
|
3479
|
+
ty = gg.y + ry;
|
|
3480
|
+
var lglt = new esri.geometry.Point(tx, ty);
|
|
3481
|
+
gc.geometry.setLatitude(ty);
|
|
3482
|
+
gc.geometry.setLongitude(tx);
|
|
3483
|
+
//设置完点位后 需要刷新下点位的显示范围
|
|
3484
|
+
gc._extent.update(tx, ty, tx, ty, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
3485
|
+
if (gc._extent._parts && gc._extent._parts[0]) {
|
|
3486
|
+
gc._extent._parts[0].extent.update(tx, ty, tx, ty, new esri.SpatialReference({ wkid: t.grwkid }));
|
|
3487
|
+
}
|
|
3488
|
+
// gc._extent._parts[0].extent = gc._extent.centerAt(lglt);
|
|
3489
|
+
gc._graphicsLayer.refresh();
|
|
3490
|
+
if (t.Label[id] && t.Label[id].add) {
|
|
3491
|
+
var tl = t.state.gis.toScreen(lglt);
|
|
3492
|
+
//设置label的位置(通过定位来实现)
|
|
3493
|
+
t.Label[id].html.css({
|
|
3494
|
+
position: 'absolute',
|
|
3495
|
+
top: tl.y + (t.Label[id].offset.y || 0) - t.labelLayer.y,
|
|
3496
|
+
left: tl.x + (t.Label[id].offset.x || 0) - t.labelLayer.x
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
t.GM.setGraphicParam(id, _extends({}, t.GM.getGraphicParam(id), { deg: ddeg }));
|
|
3500
|
+
t.movePoints[_i14].waitTime = 0;
|
|
3501
|
+
if (deleteTime <= 0) {
|
|
3502
|
+
deleteIndex.push(_i14);
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
deleteIndex.sort(function (a, b) {
|
|
3507
|
+
return b - a;
|
|
3508
|
+
});
|
|
3509
|
+
for (var _i15 = 0; _i15 < deleteIndex.length; _i15++) {
|
|
3510
|
+
t.movePoints.splice(deleteIndex[_i15], 1);
|
|
3511
|
+
}
|
|
3512
|
+
if (nowMovePoints.length == 0) {
|
|
3513
|
+
clearInterval(t.moveToTimer);
|
|
3514
|
+
}
|
|
3515
|
+
}, 10);
|
|
3516
|
+
}
|
|
3517
|
+
//点位移动动画效果
|
|
3518
|
+
|
|
3519
|
+
}, {
|
|
3520
|
+
key: 'moveTo',
|
|
3521
|
+
value: function moveTo(id, lnglat, delay, autoRotation, urlright, urlleft) {
|
|
3522
|
+
delay = delay || 3;
|
|
3523
|
+
var t = this,
|
|
3524
|
+
timer = 10;
|
|
3525
|
+
delay = eval(delay) * 1000;
|
|
3526
|
+
var count = delay / timer,
|
|
3527
|
+
gc = this.GM.getGraphic(id);
|
|
3528
|
+
var s = gc.geometry,
|
|
3529
|
+
e = new esri.geometry.Point(lnglat[0], lnglat[1]);
|
|
3530
|
+
if (t.equalsPoint(s, e)) {
|
|
3531
|
+
return false;
|
|
3532
|
+
} else {
|
|
3533
|
+
var ddeg = 0,
|
|
3534
|
+
url = null;
|
|
3535
|
+
//计算角度,旋转
|
|
3536
|
+
if (autoRotation) {
|
|
3537
|
+
//自己实现旋转
|
|
3538
|
+
ddeg = t.rotateDeg(gc.geometry, lnglat);
|
|
3539
|
+
if (urlleft && ddeg < -90 && ddeg > -270) {
|
|
3540
|
+
ddeg += 180;
|
|
3541
|
+
url = urlleft;
|
|
3542
|
+
} else {
|
|
3543
|
+
url = urlright;
|
|
3544
|
+
}
|
|
3545
|
+
gc.symbol.setUrl(url);
|
|
3546
|
+
gc.symbol.setAngle(ddeg);
|
|
3547
|
+
gc._graphicsLayer.refresh();
|
|
3548
|
+
}
|
|
3549
|
+
//拆分延迟移动定位
|
|
3550
|
+
var rx = (e.x - s.x) / count,
|
|
3551
|
+
ry = (e.y - s.y) / count;
|
|
3552
|
+
var isHave = false;
|
|
3553
|
+
for (var i = 0; i < t.movePoints.length; i++) {
|
|
3554
|
+
if (t.movePoints[i].id == id) {
|
|
3555
|
+
t.movePoints.splice(i, 1, {
|
|
3556
|
+
id: id, rx: rx, ry: ry,
|
|
3557
|
+
waitTime: 0,
|
|
3558
|
+
deleteTime: delay
|
|
3559
|
+
});
|
|
3560
|
+
isHave = true;
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
if (!isHave) {
|
|
3564
|
+
t.movePoints.push({
|
|
3565
|
+
id: id, rx: rx, ry: ry,
|
|
3566
|
+
waitTime: 0,
|
|
3567
|
+
deleteTime: delay
|
|
3568
|
+
});
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
//点位角度旋转(以指向东(右)为0°)
|
|
3573
|
+
|
|
3574
|
+
}, {
|
|
3575
|
+
key: 'rotateDeg',
|
|
3576
|
+
value: function rotateDeg(sp, ep) {
|
|
3577
|
+
var t = this;
|
|
3578
|
+
var spLngLat = sp;
|
|
3579
|
+
if (Array.isArray(sp)) {
|
|
3580
|
+
spLngLat = new esri.geometry.Point(sp[0], sp[1]);
|
|
3581
|
+
}
|
|
3582
|
+
var s = t.state.gis.toScreen(spLngLat),
|
|
3583
|
+
|
|
3584
|
+
//获取当前点位的经纬度
|
|
3585
|
+
e = t.state.gis.toScreen(new esri.geometry.Point(ep[0], ep[1])),
|
|
3586
|
+
deg = 0;
|
|
3587
|
+
if (e.x != s.x) {
|
|
3588
|
+
var tan = (e.y - s.y) / (e.x - s.x),
|
|
3589
|
+
atan = Math.atan(tan);
|
|
3590
|
+
deg = atan * 360 / (2 * Math.PI);
|
|
3591
|
+
//degree correction;
|
|
3592
|
+
if (e.x < s.x) {
|
|
3593
|
+
deg = -deg + 90 + 90;
|
|
3594
|
+
} else {
|
|
3595
|
+
deg = -deg;
|
|
3596
|
+
}
|
|
3597
|
+
deg = -deg;
|
|
3598
|
+
} else {
|
|
3599
|
+
var disy = e.y - s.y;
|
|
3600
|
+
var bias = 0;
|
|
3601
|
+
if (disy > 0) bias = -1;else bias = 1;
|
|
3602
|
+
if (disy == 0) bias = 0;
|
|
3603
|
+
deg = -bias * 90;
|
|
3604
|
+
}
|
|
3605
|
+
return deg;
|
|
3606
|
+
}
|
|
3607
|
+
//对比对象数据是否相等
|
|
3608
|
+
|
|
3609
|
+
}, {
|
|
3610
|
+
key: 'deepEqual',
|
|
3611
|
+
value: function deepEqual(a, b) {
|
|
3612
|
+
return _immutable2.default.is(_immutable2.default.fromJS(a), _immutable2.default.fromJS(b));
|
|
3613
|
+
}
|
|
3614
|
+
//数据解析(分析,新增,更新,删除对应的数据)
|
|
3615
|
+
|
|
3616
|
+
}, {
|
|
3617
|
+
key: 'dataMatch',
|
|
3618
|
+
value: function dataMatch(oldData, newData, type) {
|
|
3619
|
+
var onlyOldData = Set(oldData).subtract(Set(newData)).toJS();
|
|
3620
|
+
var onlyNewData = Set(newData).subtract(Set(oldData)).toJS();
|
|
3621
|
+
var onlyOldIDs = onlyOldData.map(function (item) {
|
|
3622
|
+
return item[type];
|
|
3623
|
+
});
|
|
3624
|
+
var onlyNewIDs = onlyNewData.map(function (item) {
|
|
3625
|
+
return item[type];
|
|
3626
|
+
});
|
|
3627
|
+
var updateDataIDs = Set(onlyOldIDs).intersect(Set(onlyNewIDs)).toJS();
|
|
3628
|
+
var updatedData = onlyNewData.filter(function (item) {
|
|
3629
|
+
return updateDataIDs.indexOf(item[type]) > -1;
|
|
3630
|
+
});
|
|
3631
|
+
var replacedData = onlyOldData.filter(function (item) {
|
|
3632
|
+
return updateDataIDs.indexOf(item[type]) > -1;
|
|
3633
|
+
});
|
|
3634
|
+
var deletedDataIDs = onlyOldIDs.filter(function (oldID) {
|
|
3635
|
+
return updateDataIDs.indexOf(oldID) == -1;
|
|
3636
|
+
});
|
|
3637
|
+
var addedData = onlyNewData.filter(function (item) {
|
|
3638
|
+
return updateDataIDs.indexOf(item[type]) == -1;
|
|
3639
|
+
});
|
|
3640
|
+
|
|
3641
|
+
return { deletedDataIDs: deletedDataIDs, addedData: addedData, updatedData: updatedData, replacedData: replacedData };
|
|
3642
|
+
}
|
|
3643
|
+
//处理需要增加图元的数据(避免意外问题)
|
|
3644
|
+
|
|
3645
|
+
}, {
|
|
3646
|
+
key: 'dealAdd',
|
|
3647
|
+
value: function dealAdd(ary, ids) {
|
|
3648
|
+
var ads = [],
|
|
3649
|
+
otherupds = [];
|
|
3650
|
+
for (var i = 0; i < ary.length; i++) {
|
|
3651
|
+
if (ids.indexOf(ary[i].id) > -1) {
|
|
3652
|
+
otherupds.push(ary[i]);
|
|
3653
|
+
} else {
|
|
3654
|
+
ads.push(ary[i]);
|
|
3655
|
+
}
|
|
3656
|
+
}
|
|
3657
|
+
return { ads: ads, otherupds: otherupds };
|
|
3658
|
+
}
|
|
3659
|
+
//处理需要更新图元的数据(避免意外问题)
|
|
3660
|
+
|
|
3661
|
+
}, {
|
|
3662
|
+
key: 'dealUpdate',
|
|
3663
|
+
value: function dealUpdate(ary, ids) {
|
|
3664
|
+
var upds = [],
|
|
3665
|
+
otherads = [];
|
|
3666
|
+
for (var i = 0; i < ary.length; i++) {
|
|
3667
|
+
if (ids.indexOf(ary[i].id) > -1) {
|
|
3668
|
+
upds.push(ary[i]);
|
|
3669
|
+
} else {
|
|
3670
|
+
otherads.push(ary[i]);
|
|
3671
|
+
}
|
|
3672
|
+
}
|
|
3673
|
+
return { upds: upds, otherads: otherads };
|
|
3674
|
+
}
|
|
3675
|
+
//渲染
|
|
3676
|
+
|
|
3677
|
+
}, {
|
|
3678
|
+
key: 'render',
|
|
3679
|
+
value: function render() {
|
|
3680
|
+
var t = this;
|
|
3681
|
+
var _map = this.props;
|
|
3682
|
+
return _react2.default.createElement('div', { id: _map.mapId, style: { width: '100%', height: '100%', backgroundColor: '#f1f1f1' } });
|
|
3683
|
+
}
|
|
3684
|
+
|
|
3685
|
+
//初始化
|
|
3686
|
+
|
|
3687
|
+
}, {
|
|
3688
|
+
key: 'componentDidMount',
|
|
3689
|
+
value: function componentDidMount() {
|
|
3690
|
+
var t = this;
|
|
3691
|
+
t.loadMapComplete.then(function () {
|
|
3692
|
+
t.init();
|
|
3693
|
+
});
|
|
3694
|
+
}
|
|
3695
|
+
//已加载组件,收到新的参数时调用
|
|
3696
|
+
|
|
3697
|
+
}, {
|
|
3698
|
+
key: 'componentWillReceiveProps',
|
|
3699
|
+
value: function componentWillReceiveProps(nextProps) {
|
|
3700
|
+
var _this5 = this;
|
|
3701
|
+
|
|
3702
|
+
var t = this;
|
|
3703
|
+
t.grwkid = nextProps.grwkid || 4326;
|
|
3704
|
+
//新参数处理方法
|
|
3705
|
+
var initData = function initData() {
|
|
3706
|
+
var t = _this5;
|
|
3707
|
+
//点/线旧数据
|
|
3708
|
+
var _t$state3 = t.state,
|
|
3709
|
+
pointIds = _t$state3.pointIds,
|
|
3710
|
+
lineIds = _t$state3.lineIds,
|
|
3711
|
+
polygonIds = _t$state3.polygonIds,
|
|
3712
|
+
circleIds = _t$state3.circleIds,
|
|
3713
|
+
drawIds = _t$state3.drawIds;
|
|
3714
|
+
var point = drawIds.point,
|
|
3715
|
+
polyline = drawIds.polyline,
|
|
3716
|
+
polygon = drawIds.polygon,
|
|
3717
|
+
circle = drawIds.circle,
|
|
3718
|
+
rectangle = drawIds.rectangle;
|
|
3719
|
+
//点/线新数据
|
|
3720
|
+
|
|
3721
|
+
var _nextProps$mapPoints = nextProps.mapPoints,
|
|
3722
|
+
mapPoints = _nextProps$mapPoints === undefined ? [] : _nextProps$mapPoints,
|
|
3723
|
+
_nextProps$mapLines = nextProps.mapLines,
|
|
3724
|
+
mapLines = _nextProps$mapLines === undefined ? [] : _nextProps$mapLines,
|
|
3725
|
+
_nextProps$mapPolygon = nextProps.mapPolygons,
|
|
3726
|
+
mapPolygons = _nextProps$mapPolygon === undefined ? [] : _nextProps$mapPolygon,
|
|
3727
|
+
_nextProps$mapCircles = nextProps.mapCircles,
|
|
3728
|
+
mapCircles = _nextProps$mapCircles === undefined ? [] : _nextProps$mapCircles,
|
|
3729
|
+
_nextProps$customized = nextProps.customizedBoundary,
|
|
3730
|
+
customizedBoundary = _nextProps$customized === undefined ? [] : _nextProps$customized,
|
|
3731
|
+
isOpenTrafficInfo = nextProps.isOpenTrafficInfo,
|
|
3732
|
+
boundaryName = nextProps.boundaryName,
|
|
3733
|
+
heatMapData = nextProps.heatMapData,
|
|
3734
|
+
mapVisiblePoints = nextProps.mapVisiblePoints,
|
|
3735
|
+
setVisiblePoints = nextProps.setVisiblePoints,
|
|
3736
|
+
setCenter = nextProps.setCenter,
|
|
3737
|
+
mapCenter = nextProps.mapCenter,
|
|
3738
|
+
setZoomLevel = nextProps.setZoomLevel,
|
|
3739
|
+
mapZoomLevel = nextProps.mapZoomLevel,
|
|
3740
|
+
setCluster = nextProps.setCluster,
|
|
3741
|
+
mapCluster = nextProps.mapCluster,
|
|
3742
|
+
isRangingTool = nextProps.isRangingTool,
|
|
3743
|
+
mapRangingTool = nextProps.mapRangingTool,
|
|
3744
|
+
isRemove = nextProps.isRemove,
|
|
3745
|
+
mapRemove = nextProps.mapRemove,
|
|
3746
|
+
mapDraw = nextProps.mapDraw,
|
|
3747
|
+
isDraw = nextProps.isDraw,
|
|
3748
|
+
isCloseDraw = nextProps.isCloseDraw,
|
|
3749
|
+
editGraphicId = nextProps.editGraphicId,
|
|
3750
|
+
isDoEdit = nextProps.isDoEdit,
|
|
3751
|
+
isEndEdit = nextProps.isEndEdit,
|
|
3752
|
+
mapPointCollection = nextProps.mapPointCollection,
|
|
3753
|
+
isclearAllPointCollection = nextProps.isclearAllPointCollection,
|
|
3754
|
+
isSetAreaRestriction = nextProps.isSetAreaRestriction,
|
|
3755
|
+
areaRestriction = nextProps.areaRestriction,
|
|
3756
|
+
isClearAreaRestriction = nextProps.isClearAreaRestriction,
|
|
3757
|
+
isClearAll = nextProps.isClearAll;
|
|
3758
|
+
// 等待地图加载
|
|
3759
|
+
|
|
3760
|
+
if (!t.state.mapCreated) return;
|
|
3761
|
+
/*添加海量点*/
|
|
3762
|
+
if (mapPointCollection instanceof Array && t.props.mapPointCollection instanceof Array && !t.deepEqual(mapPointCollection, t.props.mapPointCollection)) {
|
|
3763
|
+
var _t$dataMatch = t.dataMatch(t.props.mapPointCollection, mapPointCollection, 'id'),
|
|
3764
|
+
deletedDataIDs = _t$dataMatch.deletedDataIDs,
|
|
3765
|
+
addedData = _t$dataMatch.addedData,
|
|
3766
|
+
updatedData = _t$dataMatch.updatedData;
|
|
3767
|
+
|
|
3768
|
+
t.clearPointCollection(deletedDataIDs);
|
|
3769
|
+
t.addPointCollection(addedData);
|
|
3770
|
+
t.updatePointCollection(updatedData);
|
|
3771
|
+
}
|
|
3772
|
+
if (typeof isclearAllPointCollection == 'boolean' && isclearAllPointCollection || isclearAllPointCollection && isclearAllPointCollection !== t.props.isclearAllPointCollection) {
|
|
3773
|
+
t.clearAllPointCollection();
|
|
3774
|
+
}
|
|
3775
|
+
/*点数据处理
|
|
3776
|
+
pointData[2]相同的点,执行刷新
|
|
3777
|
+
pointData[1]的数据在idsForGraphicId中不存在的,执行新增
|
|
3778
|
+
pointData[0]数据中多余的id,执行删除
|
|
3779
|
+
*/
|
|
3780
|
+
if (mapPoints instanceof Array && t.props.mapPoints instanceof Array && !t.deepEqual(mapPoints, t.props.mapPoints)) {
|
|
3781
|
+
var oldMapPoints = t.props.mapPoints;
|
|
3782
|
+
var newMapPoints = mapPoints;
|
|
3783
|
+
//过滤编辑的图元
|
|
3784
|
+
if (!!t.editId) {
|
|
3785
|
+
oldMapPoints = t.props.mapPoints.filter(function (item) {
|
|
3786
|
+
return item.id !== editGraphicId;
|
|
3787
|
+
});
|
|
3788
|
+
newMapPoints = mapPoints.filter(function (item) {
|
|
3789
|
+
return item.id !== editGraphicId;
|
|
3790
|
+
});
|
|
3791
|
+
}
|
|
3792
|
+
|
|
3793
|
+
var _t$dataMatch2 = t.dataMatch(oldMapPoints, newMapPoints, 'id'),
|
|
3794
|
+
_deletedDataIDs = _t$dataMatch2.deletedDataIDs,
|
|
3795
|
+
_addedData = _t$dataMatch2.addedData,
|
|
3796
|
+
_updatedData = _t$dataMatch2.updatedData;
|
|
3797
|
+
|
|
3798
|
+
var _t$dealAdd = t.dealAdd(_addedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
3799
|
+
ads = _t$dealAdd.ads,
|
|
3800
|
+
otherupds = _t$dealAdd.otherupds;
|
|
3801
|
+
|
|
3802
|
+
var _t$dealUpdate = t.dealUpdate(_updatedData, [].concat(_toConsumableArray(pointIds), _toConsumableArray(point))),
|
|
3803
|
+
upds = _t$dealUpdate.upds,
|
|
3804
|
+
otherads = _t$dealUpdate.otherads;
|
|
3805
|
+
//删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3806
|
+
|
|
3807
|
+
|
|
3808
|
+
var _iteratorNormalCompletion = true;
|
|
3809
|
+
var _didIteratorError = false;
|
|
3810
|
+
var _iteratorError = undefined;
|
|
3811
|
+
|
|
3812
|
+
try {
|
|
3813
|
+
for (var _iterator = _deletedDataIDs[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
3814
|
+
var id = _step.value;
|
|
3815
|
+
|
|
3816
|
+
t.removeGraphic(id, 'point');
|
|
3817
|
+
}
|
|
3818
|
+
//增加
|
|
3819
|
+
} catch (err) {
|
|
3820
|
+
_didIteratorError = true;
|
|
3821
|
+
_iteratorError = err;
|
|
3822
|
+
} finally {
|
|
3823
|
+
try {
|
|
3824
|
+
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
3825
|
+
_iterator.return();
|
|
3826
|
+
}
|
|
3827
|
+
} finally {
|
|
3828
|
+
if (_didIteratorError) {
|
|
3829
|
+
throw _iteratorError;
|
|
3830
|
+
}
|
|
3831
|
+
}
|
|
3832
|
+
}
|
|
3833
|
+
|
|
3834
|
+
t.addPoint([].concat(_toConsumableArray(ads), _toConsumableArray(otherads)));
|
|
3835
|
+
//更新
|
|
3836
|
+
t.updatePoint([].concat(_toConsumableArray(upds), _toConsumableArray(otherupds)));
|
|
3837
|
+
}
|
|
3838
|
+
/*
|
|
3839
|
+
面数据处理
|
|
3840
|
+
先全删除,再新增
|
|
3841
|
+
*/
|
|
3842
|
+
if (mapPolygons instanceof Array && t.props.mapPolygons instanceof Array && !t.deepEqual(mapPolygons, t.props.mapPolygons)) {
|
|
3843
|
+
var oldMapPolygons = t.props.mapPolygons;
|
|
3844
|
+
var newMapPolygons = mapPolygons;
|
|
3845
|
+
if (!!t.editId) {
|
|
3846
|
+
oldMapPolygons = t.props.mapPolygons.filter(function (item) {
|
|
3847
|
+
return item.id !== editGraphicId;
|
|
3848
|
+
});
|
|
3849
|
+
newMapPolygons = mapPolygons.filter(function (item) {
|
|
3850
|
+
return item.id !== editGraphicId;
|
|
3851
|
+
});
|
|
3852
|
+
}
|
|
3853
|
+
|
|
3854
|
+
var _t$dataMatch3 = t.dataMatch(oldMapPolygons, newMapPolygons, 'id'),
|
|
3855
|
+
_deletedDataIDs2 = _t$dataMatch3.deletedDataIDs,
|
|
3856
|
+
_addedData2 = _t$dataMatch3.addedData,
|
|
3857
|
+
_updatedData2 = _t$dataMatch3.updatedData;
|
|
3858
|
+
|
|
3859
|
+
var _t$dealAdd2 = t.dealAdd(_addedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
3860
|
+
_ads = _t$dealAdd2.ads,
|
|
3861
|
+
_otherupds = _t$dealAdd2.otherupds;
|
|
3862
|
+
|
|
3863
|
+
var _t$dealUpdate2 = t.dealUpdate(_updatedData2, [].concat(_toConsumableArray(rectangle), _toConsumableArray(polygon), _toConsumableArray(polygonIds))),
|
|
3864
|
+
_upds = _t$dealUpdate2.upds,
|
|
3865
|
+
_otherads = _t$dealUpdate2.otherads;
|
|
3866
|
+
//删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3867
|
+
|
|
3868
|
+
|
|
3869
|
+
var _iteratorNormalCompletion2 = true;
|
|
3870
|
+
var _didIteratorError2 = false;
|
|
3871
|
+
var _iteratorError2 = undefined;
|
|
3872
|
+
|
|
3873
|
+
try {
|
|
3874
|
+
for (var _iterator2 = _deletedDataIDs2[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
|
3875
|
+
var _id = _step2.value;
|
|
3876
|
+
|
|
3877
|
+
t.removeGraphic(_id, 'polygon');
|
|
3878
|
+
}
|
|
3879
|
+
//增加
|
|
3880
|
+
} catch (err) {
|
|
3881
|
+
_didIteratorError2 = true;
|
|
3882
|
+
_iteratorError2 = err;
|
|
3883
|
+
} finally {
|
|
3884
|
+
try {
|
|
3885
|
+
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
|
3886
|
+
_iterator2.return();
|
|
3887
|
+
}
|
|
3888
|
+
} finally {
|
|
3889
|
+
if (_didIteratorError2) {
|
|
3890
|
+
throw _iteratorError2;
|
|
3891
|
+
}
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
|
|
3895
|
+
t.addPolygon([].concat(_toConsumableArray(_ads), _toConsumableArray(_otherads)));
|
|
3896
|
+
//更新
|
|
3897
|
+
t.updatePolygon([].concat(_toConsumableArray(_upds), _toConsumableArray(_otherupds)));
|
|
3898
|
+
}
|
|
3899
|
+
/*
|
|
3900
|
+
圆数据处理
|
|
3901
|
+
先全删除,再新增
|
|
3902
|
+
*/
|
|
3903
|
+
if (mapCircles instanceof Array && t.props.mapCircles instanceof Array && !t.deepEqual(mapCircles, t.props.mapCircles)) {
|
|
3904
|
+
var oldMapCircles = t.props.mapCircles;
|
|
3905
|
+
var newMapCircles = mapCircles;
|
|
3906
|
+
if (!!t.editId) {
|
|
3907
|
+
oldMapCircles = t.props.mapCircles.filter(function (item) {
|
|
3908
|
+
return item.id !== editGraphicId;
|
|
3909
|
+
});
|
|
3910
|
+
newMapCircles = mapCircles.filter(function (item) {
|
|
3911
|
+
return item.id !== editGraphicId;
|
|
3912
|
+
});
|
|
3913
|
+
}
|
|
3914
|
+
|
|
3915
|
+
var _t$dataMatch4 = t.dataMatch(oldMapCircles, newMapCircles, 'id'),
|
|
3916
|
+
_deletedDataIDs3 = _t$dataMatch4.deletedDataIDs,
|
|
3917
|
+
_addedData3 = _t$dataMatch4.addedData,
|
|
3918
|
+
_updatedData3 = _t$dataMatch4.updatedData;
|
|
3919
|
+
|
|
3920
|
+
var _t$dealAdd3 = t.dealAdd(_addedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
3921
|
+
_ads2 = _t$dealAdd3.ads,
|
|
3922
|
+
_otherupds2 = _t$dealAdd3.otherupds;
|
|
3923
|
+
|
|
3924
|
+
var _t$dealUpdate3 = t.dealUpdate(_updatedData3, [].concat(_toConsumableArray(circleIds), _toConsumableArray(circle))),
|
|
3925
|
+
_upds2 = _t$dealUpdate3.upds,
|
|
3926
|
+
_otherads2 = _t$dealUpdate3.otherads;
|
|
3927
|
+
//删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3928
|
+
|
|
3929
|
+
|
|
3930
|
+
var _iteratorNormalCompletion3 = true;
|
|
3931
|
+
var _didIteratorError3 = false;
|
|
3932
|
+
var _iteratorError3 = undefined;
|
|
3933
|
+
|
|
3934
|
+
try {
|
|
3935
|
+
for (var _iterator3 = _deletedDataIDs3[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
|
3936
|
+
var _id2 = _step3.value;
|
|
3937
|
+
|
|
3938
|
+
t.removeGraphic(_id2, 'circle');
|
|
3939
|
+
}
|
|
3940
|
+
//增加
|
|
3941
|
+
} catch (err) {
|
|
3942
|
+
_didIteratorError3 = true;
|
|
3943
|
+
_iteratorError3 = err;
|
|
3944
|
+
} finally {
|
|
3945
|
+
try {
|
|
3946
|
+
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
|
3947
|
+
_iterator3.return();
|
|
3948
|
+
}
|
|
3949
|
+
} finally {
|
|
3950
|
+
if (_didIteratorError3) {
|
|
3951
|
+
throw _iteratorError3;
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
|
|
3956
|
+
t.addCircle([].concat(_toConsumableArray(_ads2), _toConsumableArray(_otherads2)));
|
|
3957
|
+
//更新
|
|
3958
|
+
t.updateCircle([].concat(_toConsumableArray(_upds2), _toConsumableArray(_otherupds2)));
|
|
3959
|
+
}
|
|
3960
|
+
/*
|
|
3961
|
+
线数据处理
|
|
3962
|
+
先全删除,再新增
|
|
3963
|
+
*/
|
|
3964
|
+
if (mapLines instanceof Array && t.props.mapLines instanceof Array && !t.deepEqual(mapLines, t.props.mapLines)) {
|
|
3965
|
+
var oldMapLines = t.props.mapLines;
|
|
3966
|
+
var newMapLines = mapLines;
|
|
3967
|
+
if (!!t.editId) {
|
|
3968
|
+
oldMapLines = t.props.mapLines.filter(function (item) {
|
|
3969
|
+
return item.id !== editGraphicId;
|
|
3970
|
+
});
|
|
3971
|
+
newMapLines = mapLines.filter(function (item) {
|
|
3972
|
+
return item.id !== editGraphicId;
|
|
3973
|
+
});
|
|
3974
|
+
}
|
|
3975
|
+
|
|
3976
|
+
var _t$dataMatch5 = t.dataMatch(oldMapLines, newMapLines, 'id'),
|
|
3977
|
+
_deletedDataIDs4 = _t$dataMatch5.deletedDataIDs,
|
|
3978
|
+
_addedData4 = _t$dataMatch5.addedData,
|
|
3979
|
+
_updatedData4 = _t$dataMatch5.updatedData;
|
|
3980
|
+
|
|
3981
|
+
var _t$dealAdd4 = t.dealAdd(_addedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
3982
|
+
_ads3 = _t$dealAdd4.ads,
|
|
3983
|
+
_otherupds3 = _t$dealAdd4.otherupds;
|
|
3984
|
+
|
|
3985
|
+
var _t$dealUpdate4 = t.dealUpdate(_updatedData4, [].concat(_toConsumableArray(lineIds), _toConsumableArray(polyline))),
|
|
3986
|
+
_upds3 = _t$dealUpdate4.upds,
|
|
3987
|
+
_otherads3 = _t$dealUpdate4.otherads;
|
|
3988
|
+
//删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
3989
|
+
|
|
3990
|
+
|
|
3991
|
+
var _iteratorNormalCompletion4 = true;
|
|
3992
|
+
var _didIteratorError4 = false;
|
|
3993
|
+
var _iteratorError4 = undefined;
|
|
3994
|
+
|
|
3995
|
+
try {
|
|
3996
|
+
for (var _iterator4 = _deletedDataIDs4[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
|
3997
|
+
var _id3 = _step4.value;
|
|
3998
|
+
|
|
3999
|
+
t.removeGraphic(_id3, 'line');
|
|
4000
|
+
}
|
|
4001
|
+
//增加
|
|
4002
|
+
} catch (err) {
|
|
4003
|
+
_didIteratorError4 = true;
|
|
4004
|
+
_iteratorError4 = err;
|
|
4005
|
+
} finally {
|
|
4006
|
+
try {
|
|
4007
|
+
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
|
4008
|
+
_iterator4.return();
|
|
4009
|
+
}
|
|
4010
|
+
} finally {
|
|
4011
|
+
if (_didIteratorError4) {
|
|
4012
|
+
throw _iteratorError4;
|
|
4013
|
+
}
|
|
4014
|
+
}
|
|
4015
|
+
}
|
|
4016
|
+
|
|
4017
|
+
t.addLine([].concat(_toConsumableArray(_ads3), _toConsumableArray(_otherads3)));
|
|
4018
|
+
//更新
|
|
4019
|
+
t.updateLine([].concat(_toConsumableArray(_upds3), _toConsumableArray(_otherupds3)));
|
|
4020
|
+
}
|
|
4021
|
+
//画其他特例线专用
|
|
4022
|
+
if (customizedBoundary instanceof Array && t.props.customizedBoundary instanceof Array && !t.deepEqual(customizedBoundary, t.props.customizedBoundary)) {
|
|
4023
|
+
var _t$dataMatch6 = t.dataMatch(t.props.customizedBoundary, customizedBoundary, 'id'),
|
|
4024
|
+
_deletedDataIDs5 = _t$dataMatch6.deletedDataIDs,
|
|
4025
|
+
_addedData5 = _t$dataMatch6.addedData,
|
|
4026
|
+
_updatedData5 = _t$dataMatch6.updatedData;
|
|
4027
|
+
//删在增之前,(因为增加后会刷新pointIds的值,造成多删的问题)
|
|
4028
|
+
|
|
4029
|
+
|
|
4030
|
+
var _iteratorNormalCompletion5 = true;
|
|
4031
|
+
var _didIteratorError5 = false;
|
|
4032
|
+
var _iteratorError5 = undefined;
|
|
4033
|
+
|
|
4034
|
+
try {
|
|
4035
|
+
for (var _iterator5 = _deletedDataIDs5[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
|
|
4036
|
+
var _id4 = _step5.value;
|
|
4037
|
+
|
|
4038
|
+
t.removeGraphic(_id4, 'line');
|
|
4039
|
+
}
|
|
4040
|
+
} catch (err) {
|
|
4041
|
+
_didIteratorError5 = true;
|
|
4042
|
+
_iteratorError5 = err;
|
|
4043
|
+
} finally {
|
|
4044
|
+
try {
|
|
4045
|
+
if (!_iteratorNormalCompletion5 && _iterator5.return) {
|
|
4046
|
+
_iterator5.return();
|
|
4047
|
+
}
|
|
4048
|
+
} finally {
|
|
4049
|
+
if (_didIteratorError5) {
|
|
4050
|
+
throw _iteratorError5;
|
|
4051
|
+
}
|
|
4052
|
+
}
|
|
4053
|
+
}
|
|
4054
|
+
|
|
4055
|
+
t.addLine(_addedData5);
|
|
4056
|
+
t.updateLine(_updatedData5);
|
|
4057
|
+
}
|
|
4058
|
+
//绘制边界线
|
|
4059
|
+
// if(boundaryName instanceof Array && !t.deepEqual(boundaryName,t.props.boundaryName)){
|
|
4060
|
+
// let newBDName = Set(boundaryName);
|
|
4061
|
+
// let oldBDName = Set(t.props.boundaryName);
|
|
4062
|
+
// let removedBoundaryName = oldBDName.subtract(newBDName).toJS();
|
|
4063
|
+
// let addedBoundaryName = newBDName.subtract(oldBDName).toJS();
|
|
4064
|
+
// t.removeBaiduBoundary(removedBoundaryName);
|
|
4065
|
+
// t.addBaiduBoundary(addedBoundaryName);
|
|
4066
|
+
// }
|
|
4067
|
+
// 获取热力图
|
|
4068
|
+
if (heatMapData && !t.deepEqual(heatMapData, t.props.heatMapData)) {
|
|
4069
|
+
t.heatMapOverlay(heatMapData);
|
|
4070
|
+
}
|
|
4071
|
+
//图元编辑调用
|
|
4072
|
+
if (typeof isDoEdit == 'boolean' && isDoEdit || isDoEdit && isDoEdit !== t.props.isDoEdit) {
|
|
4073
|
+
t.doEdit(editGraphicId);
|
|
4074
|
+
}
|
|
4075
|
+
//关闭图元编辑
|
|
4076
|
+
if (typeof isEndEdit == 'boolean' && isEndEdit || isEndEdit && isEndEdit !== t.props.isEndEdit) {
|
|
4077
|
+
t.endEdit();
|
|
4078
|
+
}
|
|
4079
|
+
//开启图元绘制
|
|
4080
|
+
if (typeof isDraw == 'boolean' && isDraw || isDraw && isDraw !== t.props.isDraw) {
|
|
4081
|
+
t.draw(mapDraw);
|
|
4082
|
+
}
|
|
4083
|
+
//关闭图元绘制
|
|
4084
|
+
if (typeof isCloseDraw == 'boolean' && isCloseDraw || isCloseDraw && isCloseDraw !== t.props.isCloseDraw) {
|
|
4085
|
+
t.closeDraw();
|
|
4086
|
+
}
|
|
4087
|
+
//设置中心点
|
|
4088
|
+
if (typeof setCenter == 'boolean' && setCenter || setCenter && setCenter !== t.props.setCenter) {
|
|
4089
|
+
t.setCenter(mapCenter);
|
|
4090
|
+
}
|
|
4091
|
+
//设置点聚合
|
|
4092
|
+
if (typeof setCluster == 'boolean' && setCluster || setCluster && setCluster !== t.props.setCluster) {
|
|
4093
|
+
t.cluster(mapCluster);
|
|
4094
|
+
}
|
|
4095
|
+
//设置比例尺
|
|
4096
|
+
if (typeof setZoomLevel == 'boolean' && setZoomLevel || setZoomLevel && setZoomLevel !== t.props.setZoomLevel) {
|
|
4097
|
+
t.setZoomLevel(mapZoomLevel);
|
|
4098
|
+
}
|
|
4099
|
+
//设置最优视野
|
|
4100
|
+
if (typeof setVisiblePoints == 'boolean' && setVisiblePoints || setVisiblePoints && setVisiblePoints !== t.props.setVisiblePoints) {
|
|
4101
|
+
t.setVisiblePoints(mapVisiblePoints);
|
|
4102
|
+
}
|
|
4103
|
+
//测距工具调用
|
|
4104
|
+
if (typeof isRangingTool == 'boolean' && isRangingTool || isRangingTool && isRangingTool !== t.props.isRangingTool) {
|
|
4105
|
+
t.vtxRangingTool(mapRangingTool);
|
|
4106
|
+
}
|
|
4107
|
+
// //开关路况
|
|
4108
|
+
// if(isOpenTrafficInfo){
|
|
4109
|
+
// t.openTrafficInfo();
|
|
4110
|
+
// }else{
|
|
4111
|
+
// t.hideTrafficInfo();
|
|
4112
|
+
// }
|
|
4113
|
+
//设置区域限制
|
|
4114
|
+
if (typeof isSetAreaRestriction == 'boolean' && isSetAreaRestriction || isSetAreaRestriction && isSetAreaRestriction !== t.props.isSetAreaRestriction && areaRestriction && !!areaRestriction[0] && !!areaRestriction[1]) {
|
|
4115
|
+
t.setAreaRestriction(areaRestriction);
|
|
4116
|
+
}
|
|
4117
|
+
//关闭区域限制
|
|
4118
|
+
if (typeof isClearAreaRestriction == 'boolean' && isClearAreaRestriction || isClearAreaRestriction && isClearAreaRestriction !== t.props.isClearAreaRestriction) {
|
|
4119
|
+
t.clearAreaRestriction();
|
|
4120
|
+
}
|
|
4121
|
+
//清空地图
|
|
4122
|
+
if (typeof isClearAll == 'boolean' && isClearAll || isClearAll && isClearAll !== t.props.isClearAll) {
|
|
4123
|
+
t.clearAll();
|
|
4124
|
+
}
|
|
4125
|
+
//删除指定图元
|
|
4126
|
+
if (typeof isRemove == 'boolean' && isRemove || isRemove && isRemove !== t.props.isRemove) {
|
|
4127
|
+
mapRemove.map(function (item, index) {
|
|
4128
|
+
t.removeGraphic(item.id, item.type);
|
|
4129
|
+
});
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
//graphics对象存在 直接处理数据,不存在 延迟处理数据
|
|
4133
|
+
if (!t.state.gis || !t.state.gis.graphics) {
|
|
4134
|
+
if (t.loadTimer) {
|
|
4135
|
+
clearTimeout(t.loadTimer);
|
|
4136
|
+
}
|
|
4137
|
+
t.loadTimer = setTimeout(function () {
|
|
4138
|
+
initData();
|
|
4139
|
+
}, 300);
|
|
4140
|
+
} else {
|
|
4141
|
+
initData();
|
|
4142
|
+
}
|
|
4143
|
+
}
|
|
4144
|
+
}, {
|
|
4145
|
+
key: 'componentWillUnmount',
|
|
4146
|
+
value: function componentWillUnmount() {
|
|
4147
|
+
//关闭moveTo定时
|
|
4148
|
+
var t = this;
|
|
4149
|
+
if (t.moveToTimer) {
|
|
4150
|
+
clearInterval(t.moveToTimer);
|
|
4151
|
+
}
|
|
4152
|
+
//关闭animation定时
|
|
4153
|
+
for (var j in t.animTimer) {
|
|
4154
|
+
if (t.animTimer[j]) {
|
|
4155
|
+
clearInterval(t.animTimer[j]);
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
window.VtxMap[t.state.mapId] = null;
|
|
4159
|
+
}
|
|
4160
|
+
}]);
|
|
4161
|
+
|
|
4162
|
+
return ArcgisMap;
|
|
4163
|
+
}(_react2.default.Component);
|
|
4164
|
+
|
|
4165
|
+
exports.default = ArcgisMap;
|
|
4166
|
+
module.exports = exports['default'];
|