-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathindex.html
305 lines (245 loc) · 11.4 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
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>Directional Line Symbol</title>
<link rel="stylesheet" href="http://js.arcgis.com/3.18/esri/css/esri.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.15/dijit/themes/claro/claro.css">
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
font-family: Arial, Calibri;
}
#map {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
position: relative;
}
#options {
position: absolute;
z-index: 1000;
bottom: 0;
left: 0;
font-size: 0.8em;
background-color: rgba(0,0,0,0.7);
width: 100%;
padding: 8px 0 10px 20px;
color: #FFF;
font-weight: bold;
}
#options select {
height: 25px;
border-radius: 5px;
margin-right: 20px;
}
#options button, .esriPrintButton {
height: 25px;
/*border-radius: 5px;*/
margin: 0 10px 0 0;
background: #e5e5e5;
border: 1px solid #b5b5b5;
color: #333;
padding: 0 10px;
}
.esriPrintButton .dijitButtonNode {
border: none;
color: #333;
font-weight: normal;
margin-top: 3px;
}
.esriPrintout {
color: #FFF;
}
#stats {
position: absolute;
bottom: 15px;
left: 20px;
font-size: 1.1em;
z-index: 1000;
}
.esriPrint {
display: inline;
padding: 0;
}
</style>
<script>
var dojoConfig = {
parseOnLoad: false,
async: true,
tlmSiblingOfDojo: false
};
</script>
<script src="http://js.arcgis.com/3.18/"></script>
<script type="text/javascript">
var map;
var drawToolbar;
var directionalSymbols = [];
require(["esri/map", "esri/Color", "esri/layers/GraphicsLayer", "esri/graphic", "esri/geometry/Polyline", "esri/geometry/Polygon", "./dls/DirectionalLineSymbol.js",
"esri/symbols/SimpleMarkerSymbol", "esri/symbols/PictureMarkerSymbol", "esri/symbols/SimpleLineSymbol", "esri/symbols/SimpleFillSymbol", "esri/toolbars/draw", "esri/dijit/Print", "esri/config", "esri/request",
"dojo/ready", "dojo/dom", "dojo/on"],
function (Map, Color, GraphicsLayer, Graphic, Polyline, Polygon, DirectionalLineSymbol,
SimpleMarkerSymbol, PictureMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, Draw, Print, config, request,
ready, dom, on) {
ready(function () {
//for the sample print server
esriConfig.defaults.io.corsEnabledServers.push("sampleserver6.arcgisonline.com");
map = new Map("map", {
center: [133, -25],
zoom: 4,
basemap: "gray",
minZoom: 3
});
map.on("load", function () {
var graphicsLayer = new GraphicsLayer({ id: "graphicsLayer" });
map.addLayer(graphicsLayer);
//example using a picture marker symbol.
var picSymbol = new PictureMarkerSymbol();
picSymbol.setUrl("dls/filled-arrow.png");
picSymbol.setHeight(12);
picSymbol.setWidth(12);
//add a basic polyline
var basicOptions = {
style: SimpleLineSymbol.STYLE_SOLID,
color: new Color([0, 0, 0]),
width: 2,
directionSymbol: picSymbol,
directionPixelBuffer: 40,
showStartSymbol: true
};
var basicSymbol = new DirectionalLineSymbol(basicOptions);
var basicPolyline = new Polyline([[119, -23], [126, -20], [134, -22], [133, -12], [133.2, -12.3]]);
var bg = new Graphic(basicPolyline, basicSymbol, {}, null);
graphicsLayer.add(bg);
directionalSymbols.push(basicSymbol);
//add a polyline with 3 paths
var advOptions = {
style: SimpleLineSymbol.STYLE_DASH,
color: new Color([51, 102, 255]),
width: 2,
directionSymbol: "arrow1",
directionPixelBuffer: 60,
directionColor: new Color([204, 51, 0]),
directionSize: 14
};
var advSymbol = new DirectionalLineSymbol(advOptions);
var advPolyline = new Polyline([[[119, -28], [126, -25], [134, -27], [140, -20]],
[[119, -30], [126, -27], [134, -29], [140, -22]],
[[140, -24], [134, -31], [126, -29], [119, -32]]]);
var ag = new Graphic(advPolyline, advSymbol, {}, null);
graphicsLayer.add(ag);
directionalSymbols.push(advSymbol);
var pgOptions = {
style: SimpleLineSymbol.STYLE_SOLID,
color: new Color([51, 102, 255]),
width: 2,
directionSymbol: "arrow2",
directionPixelBuffer: 30,
directionColor: new Color([41, 82, 204]),
directionScale: 0.8
};
var pgSymbol = new DirectionalLineSymbol(pgOptions);
var polygonSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, pgSymbol, new Color([0, 255, 0, 0.4]));
var polygon = new Polygon([[143, -26], [152, -29], [146, -36], [138, -33], [143, -26]]);
var pg = new Graphic(polygon, polygonSymbol, {}, null);
graphicsLayer.add(pg);
directionalSymbols.push(pgSymbol);
var drawOptions = {
style: SimpleLineSymbol.STYLE_SOLID,
color: new Color([255, 102, 0]),
width: 1,
directionScale: 0.7,
directionSymbol: "arrow3",
directionPixelBuffer: 50,
directionColor: new Color([0, 153, 51])
};
var drawLineSymbol = new DirectionalLineSymbol(drawOptions);
directionalSymbols.push(drawLineSymbol);
drawToolbar = new Draw(map);
var drawFillSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_FORWARD_DIAGONAL, drawLineSymbol, new Color([102, 0, 102, 0.4]));
drawToolbar.setLineSymbol(drawLineSymbol);
drawToolbar.setFillSymbol(drawFillSymbol);
drawToolbar.on("draw-end", function (e) {
this.deactivate();
var symbol = e.geometry.type === "polyline" ? drawLineSymbol : drawFillSymbol;
var g = new Graphic(e.geometry, symbol, {}, null);
graphicsLayer.add(g);
});
});
//set up the print dijit to point to the arcgis sample print task. No formatting or anything set up so it looks pretty nasty.
var printer = new Print({
map: map,
url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"
}, dom.byId("print-map"));
printer.startup();
on(dom.byId("animation-repeat"), "change", function () {
//set up animation repeat for all of the DirectionalLineSymbol's created earlier
for (var i = 0, len = directionalSymbols.length; i < len; i++) {
directionalSymbols[i].stopAnimation();
var duration = parseInt(dom.byId("animation-duration").value);
if (this.value) {
directionalSymbols[i].animateDirection(this.value, duration);
}
}
});
on(dom.byId("animation-duration"), "change", function () {
//set up animation duration for all of the DirectionalLineSymbol's created earlier
var repeat = dom.byId("animation-repeat").value;
if (!repeat) return;
for (var i = 0, len = directionalSymbols.length; i < len; i++) {
directionalSymbols[i].stopAnimation();
directionalSymbols[i].animateDirection(repeat, this.value);
}
});
on(dom.byId("draw-polyline"), "click", function () {
drawToolbar.activate(Draw.POLYLINE);
});
on(dom.byId("draw-freehand"), "click", function () {
drawToolbar.activate(Draw.FREEHAND_POLYLINE);
});
on(dom.byId("draw-polygon"), "click", function () {
drawToolbar.activate(Draw.POLYGON);
});
on(dom.byId("draw-fh-polygon"), "click", function () {
drawToolbar.activate(Draw.FREEHAND_POLYGON);
});
});
});
</script>
</head>
<body>
<div id="map">
<div id="options">
<label>Animation repeat:</label>
<select id="animation-repeat">
<option value="">no animation</option>
<option value="1">1</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="Infinity">Infinity</option>
</select>
<label>Animation duration:</label>
<select id="animation-duration">
<option value="150">150</option>
<option value="250">250</option>
<option value="350" selected="selected">350</option>
<option value="450">450</option>
</select>
<button id="draw-polyline">Draw polyline</button>
<button id="draw-freehand">Draw freehand polyline</button>
<button id="draw-polygon">Draw polygon</button>
<button id="draw-fh-polygon">Draw freehand polygon</button>
<span id="print-map"></span>
</div>
</div>
</body>
</html>