forked from Esri/arcgis-dijit-layer-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
225 lines (179 loc) · 6.09 KB
/
index.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
<!DOCTYPE HTML>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<title>LayerList Dijit</title>
<link rel="stylesheet" type="text/css" href="http://jsdev.arcgis.com/3.14/esri/css/esri.css">
<link rel="stylesheet" href="/git/arcgis-js-api/dijit/themes/claro/claro.css">
<link rel="stylesheet" type="text/css" href="js/LayerList/css/LayerList.css">
<style type="text/css">
body {
margin: 40px;
padding: 20px;
}
.container {
position: relative;
padding: 10px;
border: 1px solid #eee;
-webkit-border-radius: 3px;
border-radius: 3px;
}
#map {
width: 100%;
height: 500px;
position: relative;
}
#LayerListContainer {
width: 280px;
height: 500px;
background: #eee;
position: absolute;
top: 10px;
right: 10px;
z-index: 99;
overflow-x: hidden;
overflow-y: auto;
}
.change-options {
list-style: none;
margin: 20px;
padding: 0;
}
.esriIconSettings2{
padding: 10px;
}
</style>
</head>
<body class="claro">
<div class="container">
<div id="map" class="map">
</div>
<div id="LayerListContainer">
<div id="LayerList"></div>
</div>
<h2>Change Options</h2>
<ul class="change-options">
<li>Theme:
<input id="theme_form" type="text" value="esriLayerList" />
</li>
<li>Visible:
<input id="visible_form" type="checkbox" checked />
</li>
<li>Show Legend:
<input id="show_legend" type="checkbox" />
</li>
<li>Show Opacity Slider:
<input id="show_opacity_slider" type="checkbox" />
</li>
</ul>
<p><a href="https://github.com/esri/arcgis-dijit-layer-list">Documentation & Download</a>
</p>
</div>
<script type="text/javascript">
var package_path = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var dojoConfig = {
//locale: "ar",
// The locationPath logic below may look confusing but all its doing is
// enabling us to load the api from a CDN and load local modules from the correct location.
packages: [{
name: "application",
location: package_path + '/js'
}]
};
</script>
<script src="http://jsdev.arcgis.com/3.14/" type="text/javascript"></script>
<script type="text/javascript">
var map, myWidget;
require([
"dojo/_base/lang",
"esri/config",
"application/LayerList",
"esri/arcgis/utils",
"dojo/on",
"dojo/dom",
"dojo/dom-construct"
], function (
lang,
esriConfig,
LayerList,
arcgisUtils,
on,
dom, domConstruct
) {
// esriConfig.defaults.io.proxyUrl = "/proxy/proxy.php";
/* Sample apps */
// 62c2a1a6ac8f4329b34d3dcf7ad47099 - devext
// b591577a424242e8ae4667de053c3ffa - csv layer
// df8bcc10430f48878b01c96e907a1fc3 - wildfire
// c46382e26f81477ca0046d376b2989fa - georss
// e90e7933b68a43988b04fe800d0330ba - wms
// 72748e2e531f400cbe5a7560f768bdb8 - federal lands
// arcgisUtils.arcgisUrl = "http://kd.mapsdevext.arcgis.com/sharing/rest/content/items";
/* Create webmap */
arcgisUtils.createMap('df8bcc10430f48878b01c96e907a1fc3', "map", {
mapOptions: {
//Optionally define additional map config here for example you can
//turn the slider off, display info windows, disable wraparound 180, slider position and more.
}
}).then(lang.hitch(this, function (response) {
map = response.map;
var layers = arcgisUtils.getLegendLayers(response);
// turn off sublayers for a specific layer
// layers[1].subLayers = false;
/* Optionally add settings icon and custom content to first layer */
var first = layers.length - 1;
var firstLayer = layers[first];
// optional button
firstLayer.button = domConstruct.create("div", {
className: "esriIcon esriIconSettings2"
});
on(firstLayer.button, "click", function () {
alert("hello world.");
});
// custom content
firstLayer.content = domConstruct.create("div", {
innerHTML: "Here is some custom content."
});
/* Create widget */
myWidget = new LayerList({
map: map,
layers: layers
}, "LayerList");
myWidget.startup();
/* These are some test events */
on(myWidget, 'load', lang.hitch(this, function (evt) {
console.log("load", evt);
}));
on(myWidget, 'toggle', lang.hitch(this, function (evt) {
console.log("toggle", evt);
}));
/* Demo page events */
on(dom.byId('theme_form'), 'keyup', lang.hitch(this, function (evt) {
console.log(evt.target.value);
myWidget.set("theme", evt.target.value);
}));
on(dom.byId('visible_form'), 'change', lang.hitch(this, function (evt) {
myWidget.set("visible", evt.target.checked);
}));
on(dom.byId('show_legend'), 'change', lang.hitch(this, function (evt) {
myWidget.set("showLegend", evt.target.checked);
}));
on(dom.byId('show_opacity_slider'), 'change', lang.hitch(this, function (evt) {
myWidget.set("showOpacitySlider", evt.target.checked);
}));
}), lang.hitch(this, function (error) {
//an error occurred - notify the user. In this example we pull the string from the
//resource.js file located in the nls folder because we've set the application up
//for localization. If you don't need to support mulitple languages you can hardcode the
//strings here and comment out the call in index.html to get the localization strings.
if (this.config && this.config.i18n) {
alert(this.config.i18n.map.error + ": " + error.message);
} else {
alert("Unable to create map: " + error.message);
}
}));
});
</script>
</body>
</html>