index.html
12.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>双评价</title>
<!-- 引入element样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入arcgis样式 -->
<link rel="stylesheet" href="/frontweb/js/arcgis_js_api/esri/css/main.css">
<style>
html, body, #app {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="app">
<!-- <div id="line-button" class="esri-widget esri-widget--button esri-interactive" title="画线">
<span class="esri-icon-polyline"></span>
</div>
<div id="area-button" class="esri-widget esri-widget--button esri-interactive" title="画面">
<span class="esri-icon-polygon"></span>
</div>
<div id="point-button" class="esri-widget esri-widget--button esri-interactive" title="画点">
<span class="esri-icon-radio-checked"></span>
</div>
<div id="circle-button" class="esri-widget esri-widget--button esri-interactive" title="画圆">
<span class="esri-icon-radio-unchecked"></span>
</div>
<div id="rectangle-button" class="esri-widget esri-widget--button esri-interactive" title="画矩形">
<span class="esri-icon-checkbox-unchecked"></span>
</div> -->
<div id="timeSliderDiv"></div>
</div>
<script>
window.projectName = '/frontweb'
window.mapBaseUrl = window.location.origin + window.projectName
</script>
<!-- 引入element组件库 -->
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="/frontweb/js/jquery-1.8.3.js"></script>
<script src="/frontweb/js/arcgis_js_api/init.js"></script>
<script>
window.onload = function () {
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/FeatureLayer",
"esri/layers/TileLayer",
"esri/views/2d/draw/Draw",
"esri/Graphic",
"esri/geometry/Polyline",
"esri/geometry/Polygon",
"esri/geometry/Point",
"esri/layers/GraphicsLayer",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/TextSymbol",
"esri/Color",
"esri/widgets/Legend",
"esri/widgets/ScaleBar",
"esri/widgets/Search",
// "esri/widgets/TimeSlider",
"dojo/domReady!"
], function(Map, MapView, FeatureLayer, TileLayer, Draw, Graphic,
Polyline, Polygon,Point, GraphicsLayer, SimpleLineSymbol, SimpleFillSymbol,
TextSymbol, Color, Legend, ScaleBar, Search) {
var map = new Map();
// const tileLayer = new TileLayer({
// url: 'http://xagh.org.cn:6080/arcgis/rest/services/MyMapService1111/MapServer'
// });
const kfqMap = new FeatureLayer({
url: 'https://xagh.org.cn:6443/arcgis/rest/services/%E5%8C%BA%E5%88%92%E7%BA%BF/%E5%BC%80%E5%8F%91%E5%8C%BA84/MapServer/0'
})
const xzqMap = new FeatureLayer({
// url: 'https://xagh.org.cn:6443/arcgis/rest/services/%E5%8C%BA%E5%88%92%E7%BA%BF/%E8%A1%8C%E6%94%BF%E5%8C%BA84/MapServer/0',
url: 'http://xagh.org.cn:6080/arcgis/rest/services/MyMapService1111/MapServer/0',
//*** ADD ***//
// definitionExpression: "ELEV_GAIN < 250",
//*** ADD ***//
renderer: {
type: "simple",
symbol: {
type: "simple-line",
color: "rgba(0, 77, 168, 0.3)",
width: "2px"
}
},
labelingInfo: [{
symbol: {
type: "text",
color: "#000",
haloColor: "#5E8D74",
haloSize: "2px",
font: {
size: "12px",
family: "NSimSun",
style: "normal",
weight: "normal"
}
},
labelPlacement: "above-center",
labelExpressionInfo: {
expression: "[XZQMC]"
}
}],
//*** ADD ***//
// outFields: ["XZQDM", "XZQMC","KZMJ","JSMJ"],
outFields: ["*"],
//*** ADD ***//
popupTemplate: { // Enable a popup
title: "{XZQMC}", // Show attribute value
content: [{
type: "fields",
fieldInfos:[{
fieldName: "KZMJ",
label: "面积",
visible: true,
format:{
digitSeparator: true, //设置千分位符
places: 0 //小数点保留0位(四舍五入到整数)
}
}]
}, {
type: 'text',
text: "{XZQMC}: {KZMJ}"
}]
}
})
const graphicsLayer = new GraphicsLayer()
// var point = {
// type: "point",
// longitude: 108.80657463861,
// latitude: 34.0005930608889
// };
// var simpleMarkerSymbol = {
// type: "simple-marker",
// color: [226, 119, 40], // orange
// outline: {
// color: [255, 255, 255], // white
// width: 1
// }
// };
// var pointGraphic = new Graphic({
// geometry: point,
// symbol: simpleMarkerSymbol
// });
// graphicsLayer.add(pointGraphic);
// map.add(tileLayer)
// map.add(kfqMap, 0)
map.add(xzqMap, 0)
var view = new MapView({
container: "app",
map: map,
center: [108.7, 34.2], // longitude, latitude
zoom: 14
});
var polySym = {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [140, 140, 222, 0.5],
outline: {
color: [0, 0, 0, 0.5],
width: 2
}
}
view.on('click', function (evt) {
console.log(evt)
view.hitTest(evt).then(function (response) {
var result = response.results[0];
if (result && result.graphic) {
console.log(result);
if (result.graphic.layer != graphicsLayer) {
console.log('graphicsLayer不一致')
return
}
var graphic = result.graphic
//自定义高亮
//这里的几何图形是面状,配置graphic的symbol为fillSymbol
// graphic.symbol = {
// type: "simple-fill",
// color: "red",
// outline: {
// color: [128, 128, 128, 0.5],
// width: "0.5px"
// }
// };
// graphicsLayer.removeAll();//清除上一次点击目标
// graphicsLayer.add(graphic);//添加新的点击目标
}
})
})
view.when(function () {
// var draw = new Draw({
// view: view
// });
// //绑定线按钮绘制事件
// var drawLineButton = document.getElementById("line-button");
// drawLineButton.onclick = function() {
// view.graphics.removeAll();//清楚之前的绘制
// enableCreateLine(draw, view);
// };
// //绑定面按钮绘制事件
// var drawAreaButton = document.getElementById("area-button");
// drawAreaButton.onclick = function() {
// view.graphics.removeAll();//清楚之前的绘制
// enableCreateArea(draw, view);
// };
// //绑定面按钮绘制事件
// var drawPointButton = document.getElementById("point-button");
// drawPointButton.onclick = function() {
// enableCreatePoint(draw, view);
// };
// //绑定面按钮绘制事件
// var drawCircleButton = document.getElementById("circle-button");
// drawCircleButton.onclick = function() {
// enableCreateCircle(draw, view);
// };
// //绑定面按钮绘制事件
// var drawRectangleButton = document.getElementById("rectangle-button");
// drawRectangleButton.onclick = function() {
// enableCreateRectangle(draw, view);
// };
var legend = new Legend({
view: view,
layerInfos: [
{
layer: xzqMap,
title: "NY Educational Attainment"
}
]
});
view.ui.add(legend, "bottom-right");
var scalebar = new ScaleBar({
view: view
});
view.ui.add(scalebar, "bottom-left");
// var editorWidget = new Editor({
// view: view
// });
// view.ui.add(editorWidget, "top-right");
var search = new Search({
view: view
});
view.ui.add(search, "top-right");
// var timeSlider = new TimeSlider({
// container: "timeSliderDiv",
// view: view,
// // show data within a given time range
// // in this case data within one year
// mode: "time-window",
// fullTimeExtent: { // entire extent of the timeSlider
// start: new Date(2000, 0, 1),
// end: new Date(2010, 0, 1)
// },
// values:[ // location of timeSlider thumbs
// new Date(2000, 0, 1),
// new Date(2001, 1, 1)
// ]
// });
// view.ui.add(timeSlider, "manual");
// 获取rings path
const getRings = (path = []) => {
let rings = []
path.forEach(item => {
item.forEach(pathItem => {
pathItem.forEach(childPathItem => {
rings.push(childPathItem)
})
})
})
return rings
}
// 构建Graphic
const createGraphic = (rings, graphicsLayer, area) => {
const polygon = new Polygon({ spatialReference: { wkid: 4545 }, rings: rings })
const dangerSymbol = {
type: "simple-fill",
color: "#f21a1a",
outline: {
color: [128, 128, 128, 0.5],
width: "0.5px"
}
}
const warnSymbol = {
type: "simple-fill",
color: "#f7b131",
outline: {
color: [128, 128, 128, 0.5],
width: "0.5px"
}
}
const normalSymbol = {
type: "simple-fill",
color: "#c1eec1",
outline: {
color: [128, 128, 128, 0.5],
width: "0.5px"
}
}
let symbol = normalSymbol
if (Number([2, 5].includes(area.gid))) {
symbol = warnSymbol
} else if (Number([8].includes(area.gid))) {
symbol = dangerSymbol
}
graphicsLayer.add(new Graphic(polygon, symbol))
}
$.ajax({
url: 'http://293087k6t6.qicp.vip/gtkjgh/common/getAllQuxianList',
type: 'GET',
contentType: 'application/json;charset=UTF-8',
success: function name(res) {
const data = Array.isArray(res.data) && res.data
data.forEach(item => {
const path = JSON.parse(item.geom).coordinates
const rings = getRings(path)
createGraphic(rings, graphicsLayer, item)
})
map.add(graphicsLayer)
}
})
});
})
// new Vue({
// el: '#app',
// data () {
// return {
// text: '主要按钮',
// }
// },
// mounted() {
// require([
// "esri/Map",
// "esri/views/MapView",
// "dojo/domReady!"
// ], function (Map, MapView) {
// // const map = new Map({
// // basemap: 'streets'
// // })
// const map = new Map()
// const view = new MapView({
// container: 'map',
// map: map,
// zoom: 4,
// center: [15, 65]
// })
// })
// },
// methods: {
// handleClick () {
// }
// },
// })
}
</script>
</body>
</html>