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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
GeoScene Developer Guide: Class breaks (3D)
</title>
<link rel="stylesheet" href="https://js.geoscene.cn/4.23/geoscene/themes/light/main.css" />
<script src="https://js.geoscene.cn/4.23/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"geoscene/config",
"geoscene/Map",
"geoscene/layers/GeoJSONLayer",
"geoscene/views/SceneView",
"geoscene/Basemap",
"geoscene/layers/TileLayer",
"geoscene/widgets/Legend",
], function(geosceneConfig,Map, GeoJSONLayer, SceneView, Basemap, TileLayer, Legend) {
geosceneConfig.apiKey = "YOUR_API_KEY";
const map = new Map({
basemap: new Basemap({
baseLayers: [
new TileLayer({
url:
"https://tiles.geoscene.cn/tiles/nGt4QxSblgDfeJn9/arcgis/rest/services/VintageShadedRelief/MapServer",
opacity: 0.7,
minScale: 0,
}),
],
}),
ground: {
surfaceColor: [255, 255, 255],
},
});
const view = new SceneView({
container: "viewDiv",
camera: {
position: [-96.22, 15.26, 20000000],
heading: 0,
tilt: 0,
},
qualityProfile: "high",
map: map,
alphaCompositingEnabled: true,
environment: {
background: {
type: "color",
color: [0, 0, 0, 0],
},
lighting: {
date:
"Sun Jul 15 2018 21:04:41 GMT+0200 (Central European Summer Time)",
},
starsEnabled: false,
atmosphereEnabled: false,
},
highlightOptions: {
fillOpacity: 0,
color: "#ffffff",
},
constraints: {
altitude: {
min: 400000,
},
},
});
const url =
"https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson";
const earthquakesLayer = new GeoJSONLayer({
url: url,
copyright: "USGS Earthquakes",
screenSizePerspectiveEnabled: false,
title: "Earthquakes in the last 30 days",
popupTemplate: {
title: "Earthquake Info",
content:
"Magnitude <b>{mag}</b> {type} hit <b>{place}</b> on <b>{time}</b>",
fieldInfos: [
{
fieldName: "time",
format: {
dateFormat: "short-date-short-time",
},
},
],
},
});
map.add(earthquakesLayer);
//每个地震类别的符号由多个符号图层组成
const baseSymbolLayer = {
type: "icon",
resource: { primitive: "circle" },
material: { color: [245, 116, 73, 0.9] },
size: 3,
};
const secondSymbolLayer = {
type: "icon",
resource: { primitive: "circle" },
material: { color: [245, 116, 73, 0] },
outline: { color: [245, 116, 73, 0.7], size: 1 },
size: 20,
};
const thirdSymbolLayer = {
type: "icon",
resource: { primitive: "circle" },
material: { color: [245, 116, 73, 0] },
outline: { color: [245, 116, 73, 0.5], size: 1 },
size: 40,
};
const renderer = {
type: "class-breaks",
field: "mag",
legendOptions: {
title: "Legend",
},
classBreakInfos: [
{
minValue: -2,
maxValue: 5,
symbol: {
type: "point-3d",
symbolLayers: [baseSymbolLayer],
},
label: "Magnitude < 5",
},
{
minValue: 5,
maxValue: 7,
symbol: {
type: "point-3d",
symbolLayers: [baseSymbolLayer, secondSymbolLayer],
},
label: "Magnitude between 5 and 7",
},
{
minValue: 7,
maxValue: 10,
symbol: {
type: "point-3d",
symbolLayers: [
baseSymbolLayer,
secondSymbolLayer,
thirdSymbolLayer,
],
},
label: "Magnitude larger than 7",
},
],
};
earthquakesLayer.renderer = renderer;
const legend = new Legend({
view: view,
})
view.ui.add(legend, "top-right")
})
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>