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
<html>
<head>
<meta charset="utf-8" />
<title>
Point styles for cities
</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 {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#cityStyle {
background-color: white;
text-align: center;
padding: 10px;
font-size: 0.9em;
}
#cityStyle label {
padding-right: 10px;
cursor: pointer;
}
</style>
<script>
require([
"geoscene/WebScene",
"geoscene/layers/FeatureLayer",
"geoscene/views/SceneView",
"geoscene/widgets/Legend"
], (WebScene, FeatureLayer, SceneView, Legend) => {
// Load the webscene with buildings
const webscene = new WebScene({
portalItem: {
// autocasts as new PortalItem()
id: "711ddecedece4fd88b728bfe4322c22b"
}
});
const view = new SceneView({
container: "viewDiv",
map: webscene,
environment: {
lighting: {
directShadowsEnabled: true,
ambientOcclusionEnabled: true
}
}
});
// verticalOffset shifts the symbol vertically
const verticalOffset = {
screenLength: 40,
maxWorldLength: 200,
minWorldLength: 35
};
// Function that automatically creates the symbol for the points of interest
function getUniqueValueSymbol(name, color) {
return {
type: "point-3d",
symbolLayers: [
{
type: "icon",
resource: {
href: name
},
size: 20,
outline: {
color: "white",
size: 2
}
}
],
verticalOffset: verticalOffset,
callout: {
type: "line",
color: "white",
size: 2,
border: {
color: color
}
}
};
}
const pointsRenderer = {
type: "unique-value",
field: "Type",
uniqueValueInfos: [
{
value: "Museum",
symbol: getUniqueValueSymbol(
"https://developers.geoscene.cn/javascript/latest/sample-code/visualization-point-styles/live/Museum.png",
"#D13470"
)
},
{
value: "Restaurant",
symbol: getUniqueValueSymbol(
"https://developers.geoscene.cn/javascript/latest/sample-code/visualization-point-styles/live/Restaurant.png",
"#F97C5A"
)
},
{
value: "Church",
symbol: getUniqueValueSymbol(
"https://developers.geoscene.cn/javascript/latest/sample-code/visualization-point-styles/live/Church.png",
"#884614"
)
},
{
value: "Hotel",
symbol: getUniqueValueSymbol(
"https://developers.geoscene.cn/javascript/latest/sample-code/visualization-point-styles/live/Hotel.png",
"#56B2D6"
)
},
{
value: "Park",
symbol: getUniqueValueSymbol(
"https://developers.geoscene.cn/javascript/latest/sample-code/visualization-point-styles/live/Park.png",
"#40C2B4"
)
}
]
};
const pointsLayer = new FeatureLayer({
url: "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/LyonPointsOfInterest/FeatureServer",
title: "Touristic attractions",
elevationInfo: {
mode: "relative-to-scene"
},
renderer: pointsRenderer,
outFields: ["*"],
screenSizePerspectiveEnabled: true,
labelingInfo: [
{
labelExpressionInfo: {
value: "{Name}"
},
symbol: {
type: "label-3d",
symbolLayers: [
{
type: "text",
material: {
color: "white"
},
halo: {
size: 1,
color: [50, 50, 50]
},
size: 10
}
]
}
}
]
});
pointsLayer.featureReduction = {
type: "selection"
};
webscene.add(pointsLayer);
// add functionality on the controls for selection, perspective, callout lines and relative-to-scene elevation mode
document
.getElementById("cityStyle")
.addEventListener("change", (event) => {
if (event.target.id === "declutter") {
const type = {
type: "selection"
};
pointsLayer.featureReduction = event.target.checked ? type : null;
}
});
view.ui.add(document.getElementById("cityStyle"), "top-right");
});
</script>
</head>
<body>
<div id="viewDiv" class="geoscene-widget"></div>
<div id="cityStyle">
<input type="checkbox" id="declutter" name="mode" checked />
<label for="declutter">Declutter view</label>
</div>
</body>
</html>