Repository navigation
Expand file tree
/
Copy pathmap.js
More file actions
108 lines (84 loc) · 2.75 KB
/
Copy pathmap.js
File metadata and controls
108 lines (84 loc) · 2.75 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
require([
"esri/config",
"esri/WebMap",
"esri/views/MapView",
"esri/widgets/ScaleBar",
"esri/widgets/Legend",
"esri/widgets/Home",
"esri/widgets/LayerList",
"esri/widgets/BasemapToggle",
"esri/widgets/BasemapGallery",
"esri/widgets/Search"
], (esriConfig, WebMap, MapView, ScaleBar, Legend, Home, LayerList, BasemapToggle, BasemapGallery, Search) => {
esriConfig.apikey = "AAPKb65e0f9459e54524983d875ea23edb66IPXwyWdAtPXJM6BLx1WnCOHBtU-yslIHaLa2HvstGhbY8KK1_pbrIDvvKuWThivG";
const webmap = new WebMap({
portalItem: {
id: "46473f7635e34c7dbf948195b8dd9c4f"
}
})
const view = new MapView({
container: "viewDiv",
map: webmap
});
const homeBtn = new Home({
view: view
})
view.ui.add(homeBtn, "top-left");
const legend = new Legend({
view: view
})
view.ui.add(legend, "bottom-right");
const scalebar = new ScaleBar({
view: view,
unit: "metric",
style: "ruler"
})
view.ui.add(scalebar, "bottom-left");
view.ui.add("basemap-btn", "top-right");
view.ui.add("layerList-Btn", "top-right");
const basemapToggle = new BasemapToggle({
view: view,
nextBasemap: "satellite"
})
const basemapGallery = new BasemapGallery({
view: view,
source: {
query: {
}
}
})
view.ui.add(basemapGallery, "top-right");
view.ui.add(basemapToggle, "bottom-right");
const layerList = new LayerList({
view: view
})
view.ui.add(layerList, "top-right");
document
.getElementById("layerList-Btn")
.addEventListener("click", function () {
toggleButton("layerList")
})
document
.getElementById("basemap-btn")
.addEventListener("click", function () {
toggleButton("gallery");
})
const searchWid = new Search({
view: view
})
view.ui.add(searchWid, "bottom-left");
function toggleButton(item) {
const layerListEl = document.getElementsByClassName("esri-layer-list")[0];
const galleryEl = document.getElementsByClassName("esri-basemap-gallery")[0];
let currentProp;
if (item == "layerList") {
currentProp = layerListEl.style.getPropertyValue("display");
layerListEl.style.setProperty("display", currentProp == "block" ? "none" : "block");
galleryEl.style.setProperty("display", "none");
} else if (item == "gallery") {
currentProp = galleryEl.style.getPropertyValue("display");
galleryEl.style.setProperty("display", currentProp == "block" ? "none" : "block");
layerListEl.style.setProperty("display", "none");
}
}
})