-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapImageWithoutSub.html
107 lines (91 loc) · 2.88 KB
/
MapImageWithoutSub.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<title>MapImageLayer - Toggle sublayer visibility - 4.14</title>
<link rel="stylesheet"
href="https://js.arcgis.com/4.14/esri/themes/light/main.css" />
<script src="https://js.arcgis.com/4.14/"></script>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/MapImageLayer"
],
function(Map, MapView, MapImageLayer) {
/*****************************************************************
* Create a MapImageLayer instance pointing to a Map Service
* containing data about US Cities, Counties, States and Highways.
* Define sublayers with visibility for each layer in Map Service.
*****************************************************************/
var layer = new MapImageLayer({
url: "https://services1.arcgis.com/Ezk9fcjSUkeadg6u/ArcGIS/rest/services/ALWaterBodiesTileLayer/MapServer",
});
/*****************************************************************
* Add the layer to a map
*****************************************************************/
var map = new Map({
basemap: "topo",
layers: [layer]
});
var view = new MapView({
container: "viewDiv",
map: map,
zoom: 4,
center: [-99, 39]
});
});
</script>
<style>
html,
body {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
#viewDiv {
position: absolute;
right: 0;
left: 0;
top: 0;
bottom: 60px;
}
.footer {
position: absolute;
bottom: 0;
height: 60px;
width: 100%;
}
.sublayers {
margin: 0 auto;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
overflow: auto;
}
.sublayers-item {
flex-grow: 4;
background-color: rgba(34, 111, 14, 0.5);
color: #fff;
margin: 1px;
width: 50%;
padding: 20px;
overflow: auto;
text-align: center;
cursor: pointer;
font-size: 0.9em;
}
.visible-layer {
color: #fff;
background-color: #226f0e;
}
</style>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>