forked from Esri/arcgis-dijit-layer-list
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.html
213 lines (180 loc) · 5.98 KB
/
map.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
<!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" 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;
}
</style>
</head>
<body class="claro">
<div class="container">
<div id="map" class="map">
</div>
<div id="LayerListContainer">
<div id="LayerList"></div>
</div>
<p><a href="https://github.com/esri/arcgis-dijit-layer-list">Documentation & Download</a>
</p>
<div>
<input type='button' value="Add Service" id='addService'>
</div>
</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",
"esri/map",
"esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/FeatureLayer",
"esri/layers/GeoRSSLayer",
"esri/layers/ArcGISTiledMapServiceLayer",
"esri/layers/ArcGISImageServiceLayer",
"esri/symbols/SimpleFillSymbol",
"esri/layers/GraphicsLayer",
"esri/geometry/Circle",
"esri/graphic"
], function (
lang,
esriConfig,
LayerList,
arcgisUtils,
on,
dom,
Map,
ArcGISDynamicMapServiceLayer,
FeatureLayer,
GeoRSSLayer,
ArcGISTiledMapServiceLayer,
ArcGISImageServiceLayer,
SimpleFillSymbol,
GraphicsLayer,
Circle,
Graphic
) {
// RUN DIRECT MAP SERVICE
var map = new Map("map", {
basemap: "topo",
center: [-100.45, 37.75],
zoom: 5
});
// //Takes a URL to a non cached map service.
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer", {
"opacity": 0.5,
"id": "Census - dynamicMapServiceLayer"
});
map.addLayer(dynamicMapServiceLayer);
// //Complex multi-level dyanmic service Only visible when zoomed in very tight.. Naperville Illinois (West Chicago)
var complexMultilevelDynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Water_Network/MapServer", {
"opacity": 0.5,
"id": "Naperville - complexMultilevelDynamicMapServiceLayer"
});
map.addLayer(complexMultilevelDynamicMapServiceLayer);
// //Tiled Service
var tiled = new ArcGISTiledMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/WorldTimeZones/MapServer");
map.addLayer(tiled);
// //Feature Service North of LA
var fl = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/0", {
id: "world-regions",
opacity: 0.5
});
map.addLayer(fl);
// GeoRSS Yellowstone and Sahara areas.
var georssUrl = "https://dl.dropboxusercontent.com/u/2654618/data-mixed.xml";
var georss = new GeoRSSLayer(georssUrl);
georss.on("load", function () {
domStyle.set("loading", "display", "none");
// create an info template
// set the info template for the feature layers that make up the GeoRSS layer
// the GeoRSS layer contains one feature layer for each geometry type
var layers = georss.getFeatureLayers();
arrayUtils.forEach(layers, function (l) {
});
});
map.addLayer(georss);
//Image Service / Toronto
var imageServiceLayer = new ArcGISImageServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Toronto/ImageServer", {
opacity: 0.75
});
map.addLayer(imageServiceLayer);
//GRAPHICS Layer on click
var symbol = new SimpleFillSymbol().setColor(null).outline.setColor("blue");
var gl = new GraphicsLayer({
id: "circles"
});
var geodesic = dom.byId("geodesic");
map.addLayer(gl);
map.on("click", function (e) {
var radius = map.extent.getWidth() / 10;
var circle = new Circle({
center: e.mapPoint,
geodesic: true,
radius: radius
});
var graphic = new Graphic(circle, symbol);
gl.add(graphic);
});
myWidget = new LayerList({
map: map,
layers: map._layers
}, "LayerList");
myWidget.startup();
// END RUN DIRECT MAP SERVICE
document.getElementById('addService').onclick=function(){
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Infrastructure/MapServer", {
"opacity": 0.5,
"id": "AddedLayer"
});
map.addLayer(dynamicMapServiceLayer);
};
});
</script>
</body>
</html>