This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 128
/
Read Geospatial XML Files from Same Domain.html
94 lines (84 loc) · 5.34 KB
/
Read Geospatial XML Files from Same Domain.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Read Geospatial XML Files from Same Domain - Bing Maps 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 how to load geospatial XML data from locally hosted files." />
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, Bing, Bing Maps" />
<meta name="author" content="Microsoft Bing Maps" />
<meta name="screenshot" content="screenshot.jpg" />
<script>
var map, layer;
function GetMap() {
map = new Microsoft.Maps.Map('#myMap', {
zoom: 1
});
//Load the GeoXml module.
Microsoft.Maps.loadModule('Microsoft.Maps.GeoXml', function () {
//Create an instance of the GeoXmlLayer.
layer = new Microsoft.Maps.GeoXmlLayer();
//Add the layer to the map.
map.layers.insert(layer);
});
}
function readXml(xmlUrl) {
//Set the URL of the geo XML file as the data source of the layer.
layer.setDataSource(xmlUrl, true);
}
</script>
</head>
<body>
<div id="myMap" style="position:relative;width:100%;min-width:290px;height:600px;background-color:gray"></div>
<div style="margin-top:10px;">
GeoRSS:
<input type="button" value="Countries" onclick="readXml('/data/georss/Countries.xml');" />
<input type="button" value="Sample File" onclick="readXml('/data/georss/SampleGeoRSS.xml');" />
<input type="button" value="Wifi Locations" onclick="readXml('/data/georss/WifiLocations.xml');" />
<br />
GPX:
<input type="button" value="Bike Route" onclick="readXml('/data/gpx/BikeRoute.xml');" />
<input type="button" value="Route 66 Attractions" onclick="readXml('/data/gpx/Route66Attractions.xml');" />
<input type="button" value="UK Tourist Locations" onclick="readXml('/data/gpx/Tourist_locations_UK-England.xml');" />
<br />
KML:
<input type="button" value="2007 San Diego Fires" onclick="readXml('/data/kml/2007SanDiegoCountyFires.kml');" />
<input type="button" value="Countries" onclick="readXml('/data/kml/Countries.kml');" />
<input type="button" value="London Tube Lines" onclick="readXml('/data/kml/London%20Tube%20Lines.kml');" />
<input type="button" value="London Tube Stations" onclick="readXml('/data/kml/London%20stations.kml');" />
<input type="button" value="Sample File" onclick="readXml('/data/kml/SampleKml.kml');" />
<input type="button" value="Sample File 2" onclick="readXml('/data/kml/esfr-trip-track-20080407.xml');" />
<input type="button" value="Ground Overlay" onclick="readXml('/data/kml/GroundOverlay.kml');" />
<input type="button" value="Internet Users 2005 Choropleth" onclick="readXml('/data/kml/internet_users_2005_choropleth.kml');" />
<br />
KMZ:
<input type="button" value="Recreation Site Point" onclick="readXml('/data/kmz/RecreationSitePoint.kmz');" />
<input type="button" value="Shuckstack fire tower" onclick="readXml('/data/kmz/shuckstack-fire-tower.kmz');" />
<br />
<br />
Layer Options: <br />
<input type="button" onclick="layer.clear();" value="Clear" />
<input type="button" onclick="layer.setVisible(false);" value="Hide" />
<input type="button" onclick="layer.setVisible(true);" value="Show" />
</div>
<fieldset style="width:800px;margin-top:10px;">
<legend>GeoXmlLayer - Local Data Sample</legend>
This sample shows how to load geospatial XML data from locally hosted files.<br />
<b>Note:</b> Not all file and mime types are enabled in all servers. If using .NET, it is recommended to add the following to the web.config file:
<br />
<br />
<system.webServer><br /> <staticContent><br /> <mimeMap fileExtension=".json" mimeType="application/json" /><br /> <mimeMap fileExtension=".geojson" mimeType="application/json" /><br /> <mimeMap fileExtension=".gpx" mimeType="application/xml" /><br /> <mimeMap fileExtension=".georss" mimeType="application/xml" /><br /> <mimeMap fileExtension=".kml" mimeType="application/vnd.google-earth.kml+xml" /><br /> <mimeMap fileExtension=".kmz" mimeType="application/vnd.google-earth.kmz" /><br /> </staticContent><br/><system.webServer>
</fieldset>
<script>
// Dynamic load the Bing Maps Key and Script
// Get your own Bing Maps key at https://www.microsoft.com/maps
(async () => {
let script = document.createElement("script");
let bingKey = await fetch("https://samples.azuremaps.com/api/GetBingMapsKey").then(r => r.text()).then(key => { return key });
script.setAttribute("src", `https://www.bing.com/api/maps/mapcontrol?callback=GetMap&key=${bingKey}`);
document.body.appendChild(script);
})();
</script>
</body>
</html>