-
Notifications
You must be signed in to change notification settings - Fork 471
Expand file tree
/
Copy pathSpatial data gallery.html
More file actions
369 lines (308 loc) · 17.4 KB
/
Spatial data gallery.html
File metadata and controls
369 lines (308 loc) · 17.4 KB
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
<!DOCTYPE html>
<html lang="en">
<head>
<title>Spatial data gallery - Azure Maps Web SDK Samples</title>
<meta charset="utf-8" />
<link rel="shortcut icon" href="/favicon.ico"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="This sample shows all the different types of spatial data files that can be read with the spatial IO module." />
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, KML, KMZ, GeoRSS, GPX, GML, GeoJSON, CSV, ogc, spatial data, spatial io module, geoxml, earthquakes, USGS" />
<meta name="author" content="Microsoft Azure Maps" /><meta name="version" content="1.0" />
<meta name="screenshot" content="screenshot.jpg" />
<!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
<link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
<!-- Add reference to the Azure Maps Spatial IO module. -->
<script src="https://atlas.microsoft.com/sdk/javascript/spatial/0/atlas-spatial.min.js"></script>
<script>
var map, datasource, layer, imageLayers = [], imageIcons = [], loadingIcon, statsOuput;
var proxyServiceUrl = 'https://samples.azuremaps.com/api/GetDataFromUrl?url=';
function getMap() {
loadingIcon = document.getElementById('loadingIcon');
statsOuput = document.getElementById('statsOuput');
//Initialize a map instance.
map = new atlas.Map('myMap', {
view: 'Auto',
language: 'Auto',
//Add authentication details for connecting to Azure Maps.
authOptions: {
// Use SAS token for authentication
authType: 'sas',
getToken: function (resolve, reject, map) {
// URL to your authentication service that retrieves a SAS Token
var tokenServiceUrl = 'https://samples.azuremaps.com/api/GetAzureMapsSasToken';
fetch(tokenServiceUrl).then(r => r.text()).then(token => resolve(token));
}
//Alternatively, use an Azure Maps key. Get an Azure Maps key at https://azure.com/maps. NOTE: The primary key should be used as the key.
//authType: 'subscriptionKey',
//subscriptionKey: '[YOUR_AZURE_MAPS_KEY]'
}
});
//Wait until the map resources are ready.
map.events.add('ready', function () {
//Create a data source and add it to the map.
datasource = new atlas.source.DataSource();
map.sources.add(datasource);
//Add a simple data layer for rendering the data.
layer = new atlas.layer.SimpleDataLayer(datasource);
map.layers.add(layer);
});
}
function loadData(url, isAbsolute) {
if (!isAbsolute) {
url = 'https://samples.azuremaps.com' + url;
}
loadingIcon.style.display = '';
statsOuput.innerHTML = '';
datasource.clear();
//Remove any previously loaded icon images.
if (imageIcons.length > 0) {
for (var i = 0; i < imageIcons.length; i++) {
map.imageSprite.remove(imageIcons[i]);
}
imageIcons = [];
}
//Remove any previously loaded ground overlays.
if (imageLayers.length > 0) {
map.layers.remove(imageLayers);
imageLayers = [];
}
//Read a data file from a URL or pass in a raw string.
atlas.io.read(url, {
//Proxy service for accessing cross domain assets that may not have CORs enabled.
proxyService: proxyServiceUrl,
capturePathWaypoints: true
}).then(async r => {
if (r) {
//Check to see if there are any icons in the data set that need to be loaded into the map resources.
if (r.icons) {
//For each icon image, create a promise to add it to the map, then run the promises in parrallel.
var imagePromises = [];
//The keys are the names of each icon image.
imageIcons = Object.keys(r.icons);
if (imageIcons.length !== 0) {
imageIcons.forEach(function (key) {
imagePromises.push(map.imageSprite.add(key, r.icons[key]));
});
await Promise.all(imagePromises);
}
}
//Load all features.
if (r.features && r.features.length > 0) {
datasource.add(r.features);
}
//Load all ground overlays.
if (r.groundOverlays && r.groundOverlays.length > 0) {
map.layers.add(r.groundOverlays);
imageLayers = r.groundOverlays;
}
//If bounding box information is known for data, set the map view to it.
if (r.bbox) {
map.setCamera({ bounds: r.bbox, padding: 50 });
}
writeStats(r.stats);
loadingIcon.style.display = 'none';
}
});
}
//Write reading stats and errors for each file read.
function writeStats(stats) {
var result = [];
if (stats) {
if (stats.numCharecters) {
result.push('\r\nFile size: ', Math.ceil(stats.numCharecters / 1024), ' KB');
}
if (stats.numPoints) {
result.push('\r\n# of Points: ', stats.numPoints);
}
if (stats.numLineStrings) {
result.push('\r\n# of LineStrings: ', stats.numLineStrings);
}
if (stats.numPolygons) {
result.push('\r\n# of Polygons: ', stats.numPolygons);
}
if (stats.numPositions) {
result.push('\r\n# of Positions: ', stats.numPositions);
}
if (stats.numNetworkLinks) {
result.push('\r\n# of Network Links: ', stats.numNetworkLinks);
}
if (stats.numGroundOverlays) {
result.push('\r\n# of Ground Overlays ', stats.numGroundOverlays);
}
result.push('\r\nProcessing time (ms): ', stats.processingTime, '\r\n\r\n');
}
statsOuput.value = result.join('');
}
function openTab(elm, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
elm.className += " active";
}
</script>
<style>
#myMap {
position: relative;
width: calc(100% - 375px);
min-width: 290px;
height: 600px;
float: left;
}
.sidePanel {
width: 325px;
height: 580px;
float: left;
margin-right: 10px;
}
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 6px 8px;
transition: 0.3s;
font-size: 14px;
}
.tab button:hover {
background-color: #ddd;
}
.tab button.active {
background-color: #ccc;
}
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
#statsOuput {
width: 275px;
height: 200px;
overflow-y: auto;
padding: 10px;
}
</style>
</head>
<body onload="getMap()">
<fieldset class="sidePanel">
<legend>Spatial data gallery</legend>
This sample shows all the different types of spatial data files that can be read with the spatial IO module using the <b>atlas.io.read</b> function.
<br /><br />
<div class="tab">
<!-- <button class="tablinks active" onclick="openTab(this, 'External')">External Feeds</button> -->
<button class="tablinks" active onclick="openTab(this, 'KML')">KML</button>
<button class="tablinks" onclick="openTab(this, 'KMZ')">KMZ</button>
<button class="tablinks" onclick="openTab(this, 'GPX')">GPX</button>
<button class="tablinks" onclick="openTab(this, 'GeoRSS')">GeoRSS</button>
<button class="tablinks" onclick="openTab(this, 'GML')">GML</button>
<button class="tablinks" onclick="openTab(this, 'SpatialCSV')">Spatial CSV</button>
<button class="tablinks" onclick="openTab(this, 'GeoJSON')">GeoJSON</button>
<button class="tablinks" onclick="openTab(this, 'Stats')">Stats</button>
</div>
<div id="External" class="tabcontent" style="display:block;">
These files are hosted on other domains.
<br /><br />
<!--<b>Proxied feeds</b>
<br /><br />
These feeds are hosted on endpoints that don't have CORs enabled. A proxy service is used to make the cross domain request possible.
<ul>
<li><a href="javascript:void(0);" onclick="loadData('https://www.brianabbott.net/media/kml/NYC-Transit.kmz', true);">New York City Metro (KMZ)</a></li>
</ul>-->
<b>CORs enabled feeds</b>
<ul>
<li><a href="javascript:void(0);" onclick="loadData('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.atom', true);">USGS Earthquakes Feed (GeoRSS)</a></li>
<li><a href="javascript:void(0);" onclick="loadData('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month_age.kml', true);">USGS Earthquakes Feed (KML)</a></li>
</ul>
</div>
<div id="KML" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/2007SanDiegoCountyFires.kml');">2007 San Diego Fires</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/nhc_active.kml')">Active Tropical Cyclones</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/AWOIS_Wrecks.kml')">AWOIS Wrecks</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/BalloonStyle.kml')">Balloon Style</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/BalloonStyle2.kml')">Balloon Style 2</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/esfr-trip-track-20080407.xml');">Bike trip</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/GroundOverlay.kml');">Ground Overlay</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/internet_users_2005_choropleth.kml');">Internet Users 2005 Choropleth</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/internet_users_2005_choropleth_3D.kml')">Internet Users 2005 Choropleth 3D</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/LiquidTelcom.kml')">Liquid Telcom</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/London%20Tube%20Lines.kml');">London Tube Lines</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/London%20stations.kml');">London Tube Stations</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/Pentagon.kml')">Pentagon</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/PhotoPins.kml')">Photo pins</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kml/WMSGroundOverlay.kml')">WMS Ground Overlay</a></li>
</ul>
</div>
<div id="KMZ" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/RecreationSitePoint.kmz');">Recreation Site Point</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/shuckstack-fire-tower.kmz');">Shuckstack fire tower</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/CivilWarSites.kmz')">Civil War Sites</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/Hurricane_Evacuation_Routes.kmz')">Hurricane Evacuation Routes</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/internet_users_2005_bars.kmz')">Internet Users 2005 Bars</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/qfaults.kmz')">Earthquake Faults</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Kmz/QPF24hr_Day3_latest.kmz')">24hr Quantitative Precipitation Forecasts</a></li>
</ul>
</div>
<div id="GPX" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/Gpx/BikeRoute.xml');">Bike Route</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Gpx/Route66Attractions.xml');">Route 66 Attractions</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Gpx/Tourist_locations_UK-England.xml');">UK Tourist Locations</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Gpx/gps_points.xml')">GPS Points</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/Gpx/race-gps-trace.gpx')">Race GPS trace</a></li>
</ul>
</div>
<div id="GeoRSS" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/GeoRSS/WifiLocations.xml');">Wifi Locations</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/GeoRSS/eqs7day-M2.5.xml')">Earthquakes</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/GeoRSS/SampleGeoRSS.xml');">Sample GeoRSS</a></li>
</ul>
</div>
<div id="GML" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/GML/FEMA_Hazard_WFS_2.0.0.xml')">FEMA Hazard WFS</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/GML/USGS_FC_WFS_GML.xml')">USGS WFS GML</a></li>
</ul>
</div>
<div id="SpatialCSV" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/SpatialCSV/Airports.pipe')">Airports (pipe)</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/SpatialCSV/Chicago_Bike_Racks.csv')">Chicago Bike Racks (csv)</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/SpatialCSV/Chicago_Narcotics.csv')">Chicago Narcotics (csv)</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/SpatialCSV/Chicago_Police_Stations.csv')">Chicago Police Stations (csv)</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/SpatialCSV/hurricane_barry_track.csv')">Hurricane Barry track (csv)</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/SpatialCSV/WAEcologicalSites.tab')">WA Ecological Sites (tab)</a></li>
</ul>
</div>
<div id="GeoJSON" class="tabcontent">
<ul>
<li><a href="javascript:void(0);" onclick="loadData('/data/geojson/GpsTrace.json')">GPS Trace</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/geojson/SamplePoiDataSet.json')">Sample POI Data Set</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/geojson/US_States_500k.json')">US States</a></li>
<li><a href="javascript:void(0);" onclick="loadData('/data/geojson/USGS_M7EarthquakeContours.json')">Earthquake Contours</a></li>
</ul>
</div>
<div id="Stats" class="tabcontent">
<textarea id="statsOuput"></textarea>
</div>
</fieldset>
<div id="myMap"></div>
<img id="loadingIcon" src="/images/loadingIcon.gif" style="position:absolute;top:270px;left:calc(50% - 30px);display:none;" />
</body>
</html>