-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2-dotDensityVisulizationMap.html
More file actions
225 lines (214 loc) · 6.09 KB
/
2-dotDensityVisulizationMap.html
File metadata and controls
225 lines (214 loc) · 6.09 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<title>Dot density </title>
<!-- Load the ArcGIS Maps SDK for JavaScript from CDN -->
<script type="module" src="https://js.arcgis.com/5.0/"></script>
<style>
html,
body {
height: 100%;
margin: 0;
}
</style>
</head>
<body class="calcite-mode-dark">
<arcgis-map item-id="56b5bd522c52409c90d902285732e9f1">
<arcgis-zoom slot="top-left"></arcgis-zoom>
<arcgis-expand slot="top-left" group="top-left">
<arcgis-legend></arcgis-legend>
</arcgis-expand>
<arcgis-expand slot="top-left" group="top-left">
<arcgis-bookmarks></arcgis-bookmarks>
</arcgis-expand>
</arcgis-map>
<script type="module">
const [FeatureLayer, DotDensityRenderer] = await $arcgis.import([
"@arcgis/core/layers/FeatureLayer.js",
"@arcgis/core/renderers/DotDensityRenderer.js",
]);
const dotDensityRenderer = new DotDensityRenderer({
dotValue: 100,
outline: null,
referenceScale: 577790, // 1:577,790 view scale
legendOptions: {
unit: "people",
},
attributes: [
{
field: "B03002_003E",
color: "#f23c3f",
label: "White (non-Hispanic)",
},
{
field: "B03002_012E",
color: "#e8ca0d",
label: "Hispanic",
},
{
field: "B03002_004E",
color: "#00b6f1",
label: "Black or African American",
},
{
field: "B03002_006E",
color: "#32ef94",
label: "Asian",
},
{
field: "B03002_005E",
color: "#ff7fe9",
label: "American Indian/Alaskan Native",
},
{
field: "B03002_007E",
color: "#e2c4a5",
label: "Pacific Islander/Hawaiian Native",
},
{
field: "B03002_008E",
color: "#ff6a00",
label: "Other race",
},
{
field: "B03002_009E",
color: "#96f7ef",
label: "Two or more races",
},
],
});
// Add renderer to the layer and define a popup template
const url =
"https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/ACS_Population_by_Race_and_Hispanic_Origin_Boundaries/FeatureServer/2";
const layer = new FeatureLayer({
url: url,
minScale: 20000000,
maxScale: 35000,
title: "Current Population Estimates (ACS)",
popupTemplate: {
title: "{County}, {State}",
content: [
{
type: "media",
mediaInfos: [
{
title: "Current Population Estimates (ACS)",
type: "bar-chart",
value: {
fields: [
"B03002_003E",
"B03002_012E",
"B03002_004E",
"B03002_006E",
"B03002_005E",
"B03002_007E",
"B03002_008E",
"B03002_008E",
"B03002_009E",
],
tooltipField: "<field name>",
},
},
],
},
{
type: "fields",
},
],
fieldInfos: [
{
fieldName: "B03002_003E",
label: "White (non-Hispanic)",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_012E",
label: "Hispanic",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_004E",
label: "Black or African American",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_006E",
label: "Asian",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_005E",
label: "American Indian/Alaskan Native",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_007E",
label: "Pacific Islander/Hawaiian Native",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_008E",
label: "Other race",
format: {
digitSeparator: true,
places: 0,
},
},
{
fieldName: "B03002_009E",
label: "Two or more races",
format: {
digitSeparator: true,
places: 0,
},
},
],
},
renderer: dotDensityRenderer,
});
// get the arcgis-map component element and wait for it to be ready
const viewElement = document.querySelector("arcgis-map");
viewElement.constraints = {
maxScale: 35000,
};
viewElement.popup = {
dockEnabled: true,
dockOptions: {
position: "top-right",
breakpoint: false,
},
};
// Set the default highlight option with a solid dark color
// The default highlight option is used by the popup
viewElement.highlights = [
{
name: "default",
fillOpacity: 0,
color: [255, 255, 255],
},
];
await viewElement.viewOnReady();
viewElement.map.add(layer);
</script>
</body>
</html>