-
Notifications
You must be signed in to change notification settings - Fork 0
/
elevation.html
161 lines (152 loc) · 6.33 KB
/
elevation.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/>
<title>Elevation Profile: Create Features</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.16/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.16/esri/css/esri.css">
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="https://js.arcgis.com/3.16/"></script>
<style>
html, body {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
label {
font-family: arial;
color: white;
font-size: 14px;
display: block;
padding-bottom: 5px;
}
select {
display: block;
}
#info {
min-height: 100px;
min-width: 200px;
right: 5px;
top: 5px;
margin: 5px;
padding: 10px;
position: absolute;
width: 10%;
z-index: 40;
border: solid 2px #666;
border-radius: 4px;
background-color: #666;
}
#map {
padding: 0px;
}
</style>
<script>
require([
"esri/map",
"esri/toolbars/draw",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/CartographicLineSymbol",
"esri/graphic",
"esri/units",
"esri/dijit/ElevationProfile",
"esri/Color",
"dojo/dom",
"dojo/on",
"dojo/domReady!"
], function(
Map,
Draw,
SimpleLineSymbol,
CartographicLineSymbol,
Graphic,
Units,
ElevationsProfileWidget,
Color,
dom,
on
) {
var tb, epWidget, lineSymbol;
var map = new Map("map", {
basemap: "hybrid",
center: [-121.91458,37.879753],
zoom: 17
});
map.on("load", init);
function init() {
var eleList = ["Polyline", "FreehandPolyline"];
for (var ele in eleList) {
on(dom.byId(eleList[ele]), "click", function (evt) {
initToolbar(evt.target.id.toLowerCase());
});
}
on(dom.byId("unitsSelect"), "change", function (evt) {
if (epWidget) {
epWidget.set("measureUnits", evt.target.options[evt.target.selectedIndex].value);
}
})
// lineSymbol used for freehand polyline and line.
lineSymbol = new CartographicLineSymbol(
CartographicLineSymbol.STYLE_SOLID,
new Color([255, 0, 0]), 2,
CartographicLineSymbol.CAP_ROUND,
CartographicLineSymbol.JOIN_MITER, 2
);
var profileParams = {
map: map,
profileTaskUrl: "https://elevation.arcgis.com/arcgis/rest/services/Tools/ElevationSync/GPServer",
scalebarUnits: Units.MILES
};
epWidget = new ElevationsProfileWidget(profileParams, dom.byId("profileChartNode"));
epWidget.startup();
}
function initToolbar(toolName) {
epWidget.clearProfile(); //Clear profile
map.graphics.clear();
tb = new Draw(map);
tb.on("draw-end", addGraphic);
tb.activate(toolName);
map.disableMapNavigation();
}
function addGraphic(evt) {
//deactivate the toolbar and clear existing graphics
tb.deactivate();
map.enableMapNavigation();
var symbol = lineSymbol;
map.graphics.add(new Graphic(evt.geometry, symbol));
epWidget.set("profileGeometry", evt.geometry);
var sel = dom.byId("unitsSelect");
if (sel) {
var val = sel.options[sel.selectedIndex].value;
epWidget.set("measureUnits", val);
}
}
})
</script>
</head>
<body class="claro">
<div id="info">
<label>Digitize a route:</label>
<button id="Polyline" type="button">Polyline</button>
<button id="FreehandPolyline" type="button">Freehand Polyline</button>
<label>Select unit measure:</label>
<select id="unitsSelect">
<option value="esriMiles">Miles</option>
<option value="esriKilometers">Kilometers</option>
<option value="esriMeters">Meters</option>
<option value="esriNauticalMiles">Nautical Miles</option>
<option value="esriYards">Yards</option>
<option value="esriFeet">Feet</option>
</select>
</div>
<div id="mainContainer" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:true" style="width:100%;height:100%">
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'" style="height:100%"></div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'" style="background-color: #666;">
<div id="profileChartNode"></div>
</div>
</div>
</body>
</html>