-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
203 lines (168 loc) · 7.99 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
<!--
| Copyright 2015 ESRI (UK) Limited
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Nearest Widget</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" />
<!-- ESRI CSS -->
<link rel="stylesheet" type="text/css" href="//js.arcgis.com/3.12/esri/css/esri.css" />
<!-- Nearest CSS -->
<link rel="stylesheet" type="text/css" href="js/resources/Nearest.css" />
<link rel="stylesheet" type="text/css" href="js/resources/NearestLayer.css" />
<link rel="stylesheet" type="text/css" href="js/resources/NearestItem.css" />
<style type="text/css">
a:hover,a:focus {
text-decoration: none;
}
</style>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var package_path = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'));
var dojoConfig = {
async: true,
has: { "native-xhr2": false },
packages: [{
name: "app",
location: package_path + '/js'
}]
};
</script>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script src="//js.arcgis.com/3.12/"></script>
<script type="text/javascript">
require([
"esri/geometry/Point", "esri/SpatialReference", "app/Nearest", "esri/map", "dojo/topic", "esri/InfoTemplate", "esri/graphic", "dojo/fx/Toggler", "esri/graphicsUtils", "esri/config"],
function (Point, SpatialReference, Nearest, Map, topic, InfoTemplate, Graphic, Toggler, graphicsUtils, esriConfig) {
esriConfig.defaults.io.corsEnabledServers.push("route.arcgis.com");
var location = new Point(-0.8065892, 51.801983199999995, new SpatialReference({ wkid: 4326 })),
nearest = new Nearest({
webmapId: "0713c71403f94013a399ab54910ec8bf",
location: location,
searchRadius: 50,
findNearestMode: "geodesic",
layerOptions: [
{
itemId: "fe37166bf13143d19a91d6e9bf96c8c5",
searchRadius: 50,
maxResults: 5,
showOnMap: true,
showCounters: true
},
{
itemId: "ee34ad1a6d7a4069a4d65e4927528dd7",
searchRadius: 50,
maxResults: 1,
showOnMap: true,
showCounters: true
}
]
}, "nearestWidget");
nearest.startup();
var nearestSingle = new Nearest({
webmapId: "a33fdad34af2419dbdb378e156c333f2",
location: location,
searchRadius: 1,
maxResults: 1,
display: "fixed",
findNearestMode: "geodesic",
nearestTaskType: "client",
layerOptions: [
{
itemId: "51e2ddafa02c4a32bc32c4da978df046",
searchRadius: 1,
maxResults: 1,
showOnMap: true,
showCounters: false,
showDistance: false
}
]
}, "singleNearest");
nearestSingle.startup();
map = new Map("map", {
center: [-0.8055515, 51.8003171],
zoom: 3,
basemap: "topo"
});
topic.subscribe("Nearest::show-feature", function (feature, renderer) {
map.graphics.clear();
var g = new Graphic(feature.feature.geometry, null, feature.feature.attributes, feature.feature.infoTemplate);
var symbol = renderer.getSymbol(g);
g.setSymbol(symbol);
map.graphics.add(g);
if (feature.feature.geometry.type === "point") {
map.centerAndZoom(feature.feature.geometry, 11);
}
else {
map.setExtent(feature.feature.geometry.getExtent().expand(0.75), true);
}
});
topic.subscribe("Nearest::show-layer", function (features, renderer, expanded) {
map.graphics.clear();
if (expanded) {
var i = 0, iL = features.length, geoms = [];
for (i = 0; i < iL; i++) {
map.graphics.add(new Graphic(features[i].feature.geometry, renderer.renderer.symbol, features[i].feature.attributes, features[i].feature.infoTemplate));
geoms.push(features[i].feature);
}
var myFeatureExtent = graphicsUtils.graphicsExtent(geoms);
map.setExtent(myFeatureExtent, true);
}
});
});
</script>
</head>
<body class="claro">
<div class="container">
<!-- Jumbotron -->
<div class="jumbotron">
<h1>Nearest Widget</h1>
<p class="lead">Some examples of using the Nearest widget with Bootstrap CSS for style.</p>
</div>
<!-- Example row of columns -->
<div class="row">
<div class="col-lg-7">
<div id="map"></div>
</div>
<div class="col-lg-5">
<div id="singleNearest"></div>
<div id="bins"></div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<h2>List with 2 layers</h2>
<div id="nearestWidget"></div>
</div>
</div>
<!-- Site footer -->
<footer class="footer">
<p>© Company 2014</p>
</footer>
</div>
<!-- /container -->
</body>
</html>