-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboardGridNew.html
582 lines (514 loc) · 21.2 KB
/
dashboardGridNew.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
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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<style>
* {
margin: 0;
padding: 0;
font-family: var(--calcite-sans-family);
}
.wrapper {
display: grid;
grid-template-columns: [col] 2fr [col] 5fr;
grid-template-rows: [row] auto [row] auto [row] 1fr [row] 1fr;
/* grid-column-gap: 10px;
grid-row-gap: 10px; */
grid-gap: 10px;
background-color: #e3e3e3;
color: #444;
height: 100vh;
width: 100vw;
padding: 10px;
}
.box {
border-radius: 0px;
padding: 0px;
font-size: 150%;
}
.box .box {
color: #444;
}
.centerView {
grid-column: 2;
grid-row: 1 / 5;
grid-row-gap: 10px;
display: grid;
grid-template-rows: auto 10fr auto;
}
.dataToggle {
grid-column: 1;
grid-row: 1;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
padding: 0px;
background-color: #f8f8f8;
font-size: clamp(7pt, 1.5vh, 1.5vh);
text-align: left;
}
.advCount {
grid-column: 1;
grid-row: 2;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
padding: 0px;
background-color: #f8f8f8;
font-size: clamp(7pt, 1.5vh, 1.5vh);
text-align: center;
}
.advLists {
grid-column: 1;
grid-row: 3 / 5;
padding: 0px;
background-color: #f8f8f8;
font-size: clamp(7pt, 1.5vh, 1.5vh);
text-align: left;
/* height: calc((100vh / 2) - 31px); */
}
.indicatorHeading {
grid-column: 1;
grid-row: 1 / 2;
padding: 0px;
background-color: #ECECEC;
font-size: clamp(7pt, 1.5vh, 1.5vh);
text-align: center;
}
.indicatorBody {
grid-column: 1;
grid-row: 2 / 3;
padding: 0px;
background-color: #f8f8f8;
display: flex;
justify-content: center;
align-items: center;
font-size: 5vh;
font-weight: bold;
}
.indicatorToggle {
grid-column: 1;
grid-row: 2 / 3;
padding: 5px;
background-color: #f8f8f8;
display: flex;
justify-content: space-evenly;
align-items: center;
font-size: 2vh;
}
.selectedCounty {
grid-column: 1;
grid-row: 1 / 2;
font-size: clamp(8pt, 1.8vh, 1.8vh);
font-weight: 700;
padding: 5px;
text-align: center;
font-family: "Avenir Next", "Avenir", "Hevetica Neue", "DejaVu Sans Condensed", "Helvetica", sans-serif;
background-color: rgb(0, 60, 97);
color: white !important;
text-align: center;
z-index: 1
}
.mapDiv {
grid-column: 1;
grid-row: 2 / 4;
background-color: #f8f8f8;
font-size: 1.5vh;
}
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
.underRecruitment>.indicatorHeading {
font-size: 1.5vh;
}
.list-group-item.active {
background-color: rgb(0, 60, 97) !important;
}
button.right {
float: right;
}
span {
font-size: clamp(8pt, 1.8vh, 1.8vh);
}
</style>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://js.arcgis.com/4.25/esri/themes/light/main.css">
<script type="module" src="https://js.arcgis.com/calcite-components/1.0.0-beta.97/calcite.esm.js"></script>
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/1.0.0-beta.97/calcite.css" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous">
</script>
<script src="https://code.jquery.com/jquery-3.6.2.min.js"
integrity="sha256-2krYZKh//PcchRtd+H+VyyQoZ/e3EcrkxhM8ycwASPA=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://js.arcgis.com/4.25/"></script>
<script>
var view
var arrOrg = []
var countyName
var initLoad = 0
var initExtent
var org_Table
var initCounties
var initZip
var radioVar = 0
function zoomAdvFunc() {}
require(["esri/config", "esri/WebMap", "esri/Map", "esri/views/MapView", "esri/layers/FeatureLayer",
"esri/core/reactiveUtils", "esri/Graphic", "esri/geometry/Point", "esri/geometry/Polygon",
"esri/widgets/Legend", "esri/widgets/Home", "esri/Viewpoint"
], (
esriConfig, WebMap, Map, MapView, FeatureLayer, reactiveUtils, Graphic, Point, Polygon, Legend,
Home, Viewpoint) => {
// Moved Here
function clearSelection() {
countyName = ''
view.graphics.removeAll()
$(".selectedCounty").html("Click map to select a county")
$("#clearBtn").hide()
orgDataQuery(countyName)
view.goTo(initExtent);
}
function orgDataQuery(county = '') {
$("#advList").empty()
if (arrOrg.length == 0) {
initCounties = []
initZip = []
org_Table.queryFeatures().then((results) => {
$.each(results.features, (key, val) => {
let resultInit = val.attributes.Service_Area___County;
let CountiesInit = resultInit.split(",").map((item) => {
return item.trim();
});
initCounties = initCounties.concat(CountiesInit);
let resultInitZip = val.attributes.Service_Area___Zip_Codes;
let ZipInit = resultInitZip.split(",").map((item) => {
return item.trim();
});
initZip = initZip.concat(ZipInit);
arrOrg.push({
OrgType: val.attributes.Organization_type,
Name: val.attributes.Name,
Address: val.attributes.Address,
Contact: val.attributes.Contact_Name,
Phone: val.attributes.Contact_Phone,
Email: val.attributes.Email,
County: val.attributes.Service_Area___County,
Zip: val.attributes.Service_Area___Zip_Codes,
Services: val.attributes.Services,
Descr: val.attributes.Description,
OrgEx: val.attributes.Organic_exclusively_,
Display: val.attributes.Ready_to_Display
})
})
function onlyUnique(value, index, array) {
return array.indexOf(value) === index;
}
// usage example:
initCounties = initCounties.filter(onlyUnique);
initCounties.sort();
initZip = initZip.filter(onlyUnique);
initZip.sort();
zoomAdv(initCounties)
orgDataResults(county)
})
} else {
orgDataResults(county)
}
}
function orgDataResults(county = '') {
let arr = []
if (radioVar == 0) {
var field = 'County'
} else {
var field = 'Zip'
}
if (county == '') {
arr = alasql(
"SELECT OrgType, Name, Address, Contact, Phone, Email, County, Zip, Services, Descr FROM ? ORDER BY Name",
[arrOrg])
} else {
arr = alasql(
"SELECT OrgType, Name, Address, Contact, Phone, Email, County, Zip, Services, Descr FROM ? WHERE " + field +" LIKE '%" +
county +
"%' ORDER BY SymTitle, AcademicName", [arrOrg])
}
$.each(arr, (key, val) => {
$("#advList").append(popListOrg(val))
})
$("#advHC").text(arr.length)
}
function popListOrg(val) {
let listTxt
if (radioVar == 0) {
listTxt = "<li id='" + val.Name +
"' class='list-group-item' data-result-id='" + val.County + "'><span data-result-title='" +
val.County + "'>" + val.Name +
"</span><br>Org Type: " + val.OrgType + "<br>Counties: " + val.County + "</li>"
} else {
listTxt = "<li id='" + val.Name +
"' class='list-group-item' data-result-id='" + val.Zip + "'><span data-result-title='" +
val.Zip + "'>" + val.Name +
"</span><br>Org Type: " + val.OrgType + "<br>Counties: " + val.County + "</li>"
}
return listTxt
}
// End
esriConfig.apiKey =
"AAPK81f0d351c3594c2b8cd4832bde9a5807jQ1T-g3D3qxEvv_NMG7d29O7RjEFW3zUK5A325tz4uSUmfCc2C5GJ8NOi4-35lN-";
const counties = new FeatureLayer({
url: "https://services.arcgis.com/0xnwbwUttaTjns4i/arcgis/rest/services/ANR_Footprint_New/FeatureServer/6",
visible: false
})
org_Table = new FeatureLayer({
url: "https://services.arcgis.com/0xnwbwUttaTjns4i/arcgis/rest/services/Org_resource_map/FeatureServer/0",
visible: false
})
const webmap = new WebMap({
portalItem: {
// autocasts as new PortalItem()
id: "9b1f64a8c9664d46971dc0ee9de05dda"
}
});
view = new MapView({
map: webmap,
container: "viewDiv",
constraints: {
snapToZoom: false
}
});
const listNode = document.getElementById("advList");
const btn = document.createElement('div');
btn.classList.add("esri-widget--button")
btn.classList.add("esri-icon-legend")
btn.title = "Legend"
btn.id = "legendBtn"
const clrbtn = document.createElement('div');
clrbtn.classList.add("esri-widget--button")
clrbtn.classList.add("esri-icon-trash")
clrbtn.style.display = "none"
clrbtn.title = "Clear Selection"
clrbtn.id = "clearBtn"
let legend = new Legend({
view: view,
visible: false
});
view.ui.add(legend, "top-right");
let homeWidget = new Home({
view: view
});
// adds the home widget to the top left corner of the MapView
view.ui.add(homeWidget, "top-left");
view.ui.add(btn, 'top-left');
view.ui.add(clrbtn, 'top-left');
webmap.when(() => {
layer = webmap.layers.at(2);
layer.outFields = ["*"];
counties.load().then(() => {
console.log("Adding table");
// Add table to the webmap's table collection
webmap.layers.add(counties)
counties
.when(() => {
return counties.queryExtent();
})
.then((response) => {
initExtent = response.extent.expand(1.2)
view.goTo(initExtent);
let vp = new Viewpoint({
targetGeometry: initExtent
});
// Sets the model's viewpoint to the Viewpoint based on a polygon geometry
homeWidget.viewpoint = vp;
});
});
})
reactiveUtils.when(() => !view?.updating, () => {
if (initLoad == 0) {
orgDataQuery(countyName)
initLoad = 1
}
})
view.on("click", (event) => {
// only include graphics from hurricanesLayer in the hitTest
const opts = {
include: view.layerViews.items[radioVar].layer
}
let symbol = {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [0, 255, 255, 0.2],
style: "solid",
outline: { // autocasts as new SimpleLineSymbol()
color: [0, 255, 255, 1],
width: 1
}
};
view.hitTest(event, opts).then((response) => {
// check if a feature is returned from the hurricanesLayer
if (response.results.length) {
const graphic = response.results[0].graphic;
graphic.symbol = symbol
if (radioVar == 0){
countyName = graphic.attributes.name
$(".selectedCounty").html(countyName +
" County"
)
} else {
countyName = graphic.attributes.POSTCODE
$(".selectedCounty").html("Zip Code: " +countyName
)
}
$("#clearBtn").show()
orgDataQuery(countyName)
view.graphics.removeAll()
view.graphics.add(graphic)
}
});
});
listNode.addEventListener("click", onListClickHandler);
function onListClickHandler(event) {
const target = event.target;
let resultId = target.getAttribute("data-result-id");
const resulttitle = target.getAttribute("data-result-title");
if (resultId != null) {
resultId
} else {
resultId = resulttitle
}
const myArray = resultId.split(",").map((item) => {
return item.trim();
});
zoomAdv(myArray)
}
function zoomAdv(counties) {
view.graphics.removeAll()
view.layerViews.items[radioVar].layer.queryFeatures().then((results) => {
$.each(results.features, (key, val) => {
$.each(counties, (key2, val2) => {
if (radioVar == 0) {
if (val.attributes.name == val2) {
let pt = new Polygon({
rings: val.geometry.rings,
spatialReference: val.geometry
.spatialReference
});
let symbol = {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [0, 60, 97, 1],
style: "solid",
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255, 0.5],
width: 0.5
}
};
graphic = new Graphic(pt, symbol);
view.graphics.add(graphic);
$("#clearBtn").show()
}
} else {
if (val.attributes.POSTCODE == val2) {
let pt = new Polygon({
rings: val.geometry.rings,
spatialReference: val.geometry
.spatialReference
});
let symbol = {
type: "simple-fill", // autocasts as new SimpleFillSymbol()
color: [0, 60, 97, 1],
style: "solid",
outline: { // autocasts as new SimpleLineSymbol()
color: [255, 255, 255, 0.5],
width: 0.5
}
};
graphic = new Graphic(pt, symbol);
view.graphics.add(graphic);
$("#clearBtn").show()
}
}
})
})
})
}
zoomAdvFunc = zoomAdv
$(document).ready(() => {
$("ul.adv").on("click", "li", function () {
$("li").removeClass("active");
$(this).toggleClass("active");
});
$("#legendBtn").on("click", () => {
if (legend.visible == true) {
legend.visible = false
} else {
legend.visible = true
}
});
$("#clearBtn").on("click", () => {
clearSelection()
if (radioVar == 0) {
zoomAdv(initCounties)
} else {
zoomAdv(initZip)
}
})
$('#radioDiv input:radio').on("click", function () {
if ($(this).val() === 'county') {
radioVar = 0
view.layerViews.items[1].layer.visible = true
view.layerViews.items[2].layer.visible = false
zoomAdv(initCounties)
} else if ($(this).val() === 'point') {
radioVar = 2
view.layerViews.items[2].layer.visible = true
view.layerViews.items[1].layer.visible = false
zoomAdv(initZip)
}
});
});
});
</script>
</head>
<body>
<div class="wrapper">
<div class="box dataToggle">
<div class="indicatorHeading">Choose data</div>
<div id="radioDiv" class="indicatorToggle">
<div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="countyRadio" value="county"
checked>
<label class="form-check-label" for="countyRadio">
County
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="flexRadioDefault" id="pointRadio" value="point">
<label class="form-check-label" for="pointRadio">
Zip Code
</label>
</div>
</div>
</div>
<div class="box advCount">
<div class="indicatorHeading">Organizations</div>
<div id="advHC" class="indicatorBody">20</div>
</div>
<div class="box advLists">
<div style="overflow-y: scroll; height: 100%">
<ul id="advList" class="list-group adv">
</ul>
</div>
</div>
<div class="box centerView">
<div class="box selectedCounty">Click map to select a county</div>
<div class="box mapDiv">
<div id="viewDiv">
</div>
</div>
</div>
</div>
</body>
</html>