-
Notifications
You must be signed in to change notification settings - Fork 442
/
Azure Maps Leaflet options.html
186 lines (171 loc) · 10 KB
/
Azure Maps Leaflet options.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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Azure Maps Leaflet options - 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 how the different options of Azure Maps tile layer can be used in the Leaflet JS map control." />
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, tiles, raster, leaflet, leaflet.js, leafletjs" />
<meta name="author" content="Microsoft Azure Maps" /><meta name="version" content="1.0" />
<meta name="screenshot" content="screenshot.jpg" />
<!-- Add references to the Leaflet JS map control resources. -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A==" crossorigin="" />
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA==" crossorigin=""></script>
<!-- Add reference to the Azure Maps Leaflet plugin. -->
<script src="/lib/azure-maps/azure-maps-leaflet.min.js"></script>
<script>
var map, layer;
function getMap() {
//Create a map instance.
map = L.map('myMap', {
center: [0, 0],
zoom: 2
});
//Alternatively, create an instance of the Azure Maps Tile Layer and add it to the map.
layer = new L.TileLayer.AzureMaps({
//Add authentication details for connecting to Azure Maps.
authOptions: {
//Use Microsoft Entra ID authentication.
authType: 'anonymous',
clientId: 'e6b6ab59-eb5d-4d25-aa57-581135b927f0', //Your Azure Maps client id for accessing your Azure Maps account.
getToken: function (resolve, reject, map) {
//URL to your authentication service that retrieves an Microsoft Entra ID Token.
var tokenServiceUrl = 'https://samples.azuremaps.com/api/GetAzureMapsToken';
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]'
}
});
map.addLayer(layer);
}
function tilesetIdUpdated(elm) {
layer.setTilesetId(elm.selectedOptions[0].text);
}
function languageUpdated(elm) {
var lang = elm.options[elm.selectedIndex].value
layer.setLanguage(lang);
}
function trafficFlowThicknessUpdated(elm) {
layer.setTrafficFlowThickness(elm.value);
}
</script>
</head>
<body onload="getMap()">
<div id="myMap" style="position:relative;width:100%;min-width:290px;height:600px;"></div>
<div style="position:absolute;top:15px;right:15px;border-radius:5px;background-color:#fff;padding:5px;z-index:1000">
<table>
<tr>
<td>Tileset ID:</td>
<td>
<select onchange="tilesetIdUpdated(this)">
<option selected="selected">microsoft.base.road</option>
<option>microsoft.base.darkgrey</option>
<option>microsoft.imagery</option>
<option>microsoft.weather.infrared.main</option>
<option>microsoft.weather.radar.main</option>
<option>microsoft.base.hybrid.road</option>
<option>microsoft.base.labels.road</option>
<option>microsoft.traffic.flow.absolute</option>
<option>microsoft.traffic.flow.reduced-sensitivity</option>
<option>microsoft.traffic.flow.relative</option>
<option>microsoft.traffic.flow.relative-delay</option>
<option>microsoft.traffic.incident.night</option>
<option>microsoft.traffic.incident.s1</option>
<option>microsoft.traffic.incident.s2</option>
<option>microsoft.traffic.incident.s3</option>
</select>
</td>
</tr>
<tr>
<td>Language:</td>
<td>
<select onchange="languageUpdated(this)">
<option value="NGT">Neutral Ground Truth (NGT)</option>
<option value="NGT-Latn">Neutral Ground Truth - Latin exonyms (NGT-Latn)</option>
<option value="ar">Arabic (ar)</option>
<option value="bg">Bulgarian (bg)</option>
<option value="bg-BG">Bulgarian (Bulgaria) (bg-BG)</option>
<option value="ca-ES">Catalan (Spain) (ca-ES)</option>
<option value="cs">Czech (cs)</option>
<option value="cs-CZ">Czech (Czech Republic) (cs-CZ)</option>
<option value="da">Danish (da)</option>
<option value="da-DK">Danish (Denmark) (da-DK)</option>
<option value="nl">Dutch (Netherlands) (nl)</option>
<option value="nl-NL">Dutch (Netherlands) (nl-NL)</option>
<option value="en">English (en)</option>
<option value="en-AU">English (Australia) (en-AU)</option>
<option value="en-CA">English (Canada) (en-CA)</option>
<option value="en-GB">English (United Kingdom) (en-GB)</option>
<option value="en-NZ">English (New Zealand) (en-NZ)</option>
<option value="en-US" selected="selected">English (United States) (en-US)</option>
<option value="fi">Finnish (fi)</option>
<option value="fi-FI">Finnish (Finland) (fi-FI)</option>
<option value="fr">French (fr)</option>
<option value="fr-FR">French (France) (fr-FR)</option>
<option value="de">German (de)</option>
<option value="de-DE">German (Germany) (de-DE)</option>
<option value="el">Greek (el)</option>
<option value="el-GR">Greek (el-GR)</option>
<option value="hu">Hungarian (hu)</option>
<option value="hu-HU">Hungarian (hu-HU)</option>
<option value="id">Indonesian (id)</option>
<option value="id-ID">Indonesian (id-ID)</option>
<option value="it">Italian (it)</option>
<option value="it-IT">Italian (it-IT)</option>
<option value="lt">Lithuanian (lt)</option>
<option value="lt-LT">Lithuanian (lt-LT)</option>
<option value="ms-MY">Malay (ms-MY)</option>
<option value="nb-NO">Norwegian, Bokmal (Norway) (nb-NO)</option>
<option value="pl">Polish (pl)</option>
<option value="pl-PL">Polish (Poland) (pl-PL)</option>
<option value="pt">Portuguese (Brazil) (pt)</option>
<option value="pt-BR">Portuguese (Brazil) (pt-BR)</option>
<option value="pt-PT">Portuguese (Portugal) (pt-PT)</option>
<option value="ru">Russian (ru)</option>
<option value="ru-RU">Russian (Russia) (ru-RU)</option>
<option value="sk">Slovak (sk)</option>
<option value="sk-SK">Slovak (Slovakia) (sk-SK)</option>
<option value="sl">Slovenian (sl)</option>
<option value="sl-SI">Slovenian (sl-SI)</option>
<option value="es">Spanish (es)</option>
<option value="es-ES">Spanish (Spain) (es-ES)</option>
<option value="es-MX">Spanish (Mexico) (es-MX)</option>
<option value="sv">Swedish (sv)</option>
<option value="sv-SE">Swedish (sv-SE)</option>
<option value="th">Thai (th)</option>
<option value="th-TH">Thai - Thailand (th-TH)</option>
<option value="tr">Turkish (tr)</option>
<option value="tr-TR">Turkish (tr-TR)</option>
</select>
</td>
</tr>
<tr>
<td>Traffic flow thickness:</td>
<td>
<form oninput="ft.value=flowThickness.value">
<input type="range" id="flowThickness" value="5" min="1" max="20" step="1" onchange="trafficFlowThicknessUpdated(this)" />
<output name="ft" for="flowThickness">5</output>
</form>
</td>
</tr>
</table>
<br /><br />
Options not demonstrated:
<ul>
<li>authOptions</li>
<li>timeStamp</li>
<li>view</li>
</ul>
</div>
<fieldset style="width:calc(100% - 30px);min-width:290px;margin-top:10px;">
<legend>
<h1 style="font-size:16px">Azure Maps Leaflet options</h1>
</legend>
This sample shows how the different options of Azure Maps tile layer can be used in the Leaflet JS map control.
This samples uses the open source <a href="https://github.com/Azure-Samples/azure-maps-leaflet" target="_blank">Azure Maps Leaflet plugin</a>.
</fieldset>
</body>
</html>