-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
167 lines (158 loc) · 6.26 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
<title>链家可视化</title>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.2/esri/css/main.css">
<script src="https://js.arcgis.com/4.2/"></script>
<!--<link rel="stylesheet" href="http://localhost/jsapi/4.2/esri/css/main.css">-->
<!--<script src="http://localhost/jsapi/4.2/"></script>-->
<script>
require([
'esri/layers/FeatureLayer', 'esri/Graphic',
'esri/layers/support/LabelClass',
'esri/symbols/LabelSymbol3D',
'esri/symbols/TextSymbol3DLayer',
"esri/Map",
"esri/views/SceneView",
"esri/widgets/Search",
"esri/geometry/Point",
"esri/geometry/Polyline",
"esri/geometry/Polygon",
"esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleFillSymbol",
"esri/layers/GraphicsLayer",
'esri/config',
"dojo/dom",
"dojo/on", "esri/layers/MapImageLayer", "esri/renderers/SimpleRenderer",
"esri/symbols/PolygonSymbol3D",
"esri/symbols/ExtrudeSymbol3DLayer", "esri/layers/TileLayer", "esri/Basemap", "esri/WebMap",
"dojo/domReady!"
], function (FeatureLayer, Graphic, LabelClass, LabelSymbol3D, TextSymbol3DLayer, Map, SceneView, Search, Point, Polyline, Polygon, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, GraphicsLayer, esriConfig, dom, on, MapImageLayer, SimpleRenderer, PolygonSymbol3D, ExtrudeSymbol3DLayer, TileLayer, Basemap, WebMap) {
esriConfig.request.corsEnabledServers.push("server.arcgisonline.com");
graphicsLayer = new GraphicsLayer();
renderer = new SimpleRenderer({
symbol: new PolygonSymbol3D({
symbolLayers: [new ExtrudeSymbol3DLayer()]
}),
visualVariables: [{
type: "size",
field: "avgprice",
stops: [
{
value: 160,
size: 500
},
{
value: 4000,
size: 1500
}]
}, {
type: "color",
field: "unitprice",
stops: [
{
value: 18937.0,
color: [77, 247, 61]
},
{
value: 147247.0,
color: 'red'
}]
}]
});
var template = {
title: "小区名称: {name}",
content: "<ul><li>房源数量:{count}</li>"
+ "<li>总价平均:{avgprice} 万元</li>"
+ "<li>均价:{unitprice} 元/㎡</li>"
+ "<li>平均面积:{area} 平方米</li>"
+ "<li>平均关注者:{followers} 人</li>"
+ "<li>平均交易时间:{lasttrade} </li>" +
"</ul>",
fieldInfos: [{
fieldName: "name"
}, {
fieldName: 'count'
}, {
fieldName: 'avgprice'
}, {
fieldName: "unitprice"
}, {
fieldName: "area"
}, {
fieldName: "followers"
}, {
fieldName: "lasttrade"
}]
};
graphicsLayer.renderer = renderer
graphicsLayer.popupTemplate = template
map = new Map({
basemap: 'topo',
ground: "world-elevation",
layers: [graphicsLayer]
});
view = new SceneView({
map: map,
container: "viewDiv",
center: [116.3314279277704, 39.977584565],
zoom: 13
});
view.on('click', function (e) {
console.log(e)
})
var xhr = new XMLHttpRequest()
xhr.open('get', 'resblock.json')
xhr.onload = function () {
var result = JSON.parse(xhr.responseText)
var graphics_array = []
result.forEach(function (e) {
var g = new Graphic()
g.geometry = new Polygon(buildPolygonFromPt({
longitude: e[3] - 0.010875198921709739,
latitude: e[4] - 0.008736196697576304
}))
g.attributes = {
"count": e[1],
'avgprice': e[2],
'name': e[0],
'unitprice': e[5],
'area': e[6],
'followers': e[7],
'lasttrade': e[8]
};
graphics_array.push(g)
})
graphicsLayer.addMany(graphics_array)
}
xhr.send()
function buildPolygonFromPt(pt) {
var temp = {rings: [[]], spatialReference: {wkid: 4326}}
var step = 0.001
temp.rings[0].push([pt.longitude - step, pt.latitude - step])
temp.rings[0].push([pt.longitude - step, pt.latitude + step])
temp.rings[0].push([pt.longitude + step, pt.latitude + step])
temp.rings[0].push([pt.longitude + step, pt.latitude - step])
temp.rings[0].push([pt.longitude - step, pt.latitude - step])
return temp
}
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>