-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzureMapWithLeaflet.html
76 lines (64 loc) · 2.87 KB
/
AzureMapWithLeaflet.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<!-- Add references to the Leaflet JS map control resources. -->
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin=""></script>
<script type='text/javascript'>
var map;
function onLocationFound(e) {
var radius = e.accuracy / 2;
L.marker(e.latlng)
.addTo(map)
.bindPopup("You are within " + radius + " meters from this point")
.openPopup();
L.circle(e.latlng, radius).addTo(map);
}
function satelliteImagery() {
return "https://atlas.microsoft.com/map/imagery/png?api-version=1&style=satellite&tileSize=512&zoom={z}&x={x}&y={y}&subscription-key={subscriptionKey}";
}
function roadMapTiles() {
return "https://atlas.microsoft.com/map/tile/png?api-version=1&layer=basic&style=main&TileFormat=pbf&tileSize=512&zoom={z}&x={x}&y={y}&subscription-key={subscriptionKey}";
}
function GetMap() {
var subscriptionKey = '[[[***YOUR-KEY-HERE***]]]';
var satellite = L.tileLayer(satelliteImagery(), {
attribution: '© ' + new Date().getFullYear() + ' Microsoft, © 1992 - ' + new Date().getFullYear() + ' TomTom',
maxZoom: 18,
tileSize: 512,
zoomOffset: -1,
id: 'azureSatelliteMaps',
crossOrigin: true,
subscriptionKey: subscriptionKey
});
var roads = L.tileLayer(roadMapTiles(), {
attribution: '© ' + new Date().getFullYear() + ' Microsoft, © 1992 - ' + new Date().getFullYear() + ' TomTom',
maxZoom: 18,
tileSize: 512,
zoomOffset: -1,
id: 'azureRoadMaps',
crossOrigin: true,
subscriptionKey: subscriptionKey
});
map = L.map('myMap', { layers: [roads] });
map.locate({ setView: true });
map.on('locationfound', onLocationFound);
var baseMaps = {
"Azure Satellite Imagery": satellite,
"Azure Roads": roads
};
L.control.layers(baseMaps, null, { collapsed: false }).addTo(map);
}
</script>
</head>
<body onload="GetMap()">
<div id="myMap" style="position:relative;width:900px;height:600px;"></div>
</body>
</html>