-
Notifications
You must be signed in to change notification settings - Fork 445
/
Mini overview map options.html
261 lines (237 loc) · 12.1 KB
/
Mini overview map 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Mini overview map 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 to create a simple custom control that centers and zooms the map to fit any data that is loaded on the map." />
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, " />
<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 overview map control module. -->
<script src="/lib/azure-maps/azure-maps-overview-map.min.js"></script>
<script>
var map, overviewMap;
function getMap() {
//Initialize a map instance.
map = new atlas.Map('myMap', {
center: [-122.33, 47.6],
zoom: 12,
view: 'Auto',
//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]'
}
});
//Wait until the map resources are ready.
map.events.add('ready', function () {
//Add the bring data into view control to the map.
overviewMap = new atlas.control.OverviewMap();
map.controls.add(overviewMap, {
position: 'top-left'
});
//Add a style control to the map.
map.controls.add(new atlas.control.StyleControl({
mapStyles: 'all'
}), {
position: 'top-left'
});
});
}
function selectUpdated(elm, property) {
var o = {};
o[property] = elm.options[elm.selectedIndex].value;
overviewMap.setOptions(o);
}
function checkboxUpdated(elm, property) {
var o = {};
o[property] = elm.checked;
overviewMap.setOptions(o);
}
function sliderUpdated(elm, property) {
var o = {};
o[property] = parseInt(elm.value);
overviewMap.setOptions(o);
}
function setSyncZoom(elm) {
overviewMap.setOptions({
syncZoom: elm.checked
});
document.getElementById('zoomOption').style.display = (elm.checked) ? 'none' : '';
}
function setOverlay(elm) {
var overlay = elm.options[elm.selectedIndex].value;
overviewMap.setOptions({
overlay: overlay
});
document.getElementById('markerOption').style.display = (overlay === 'marker') ? '' : 'none';
}
function setMarkerDraggable(elm) {
overviewMap.setOptions({
markerOptions: {
draggable: elm.checked
}
});
}
</script>
<style>
.sidePanel {
width: 350px;
height: 580px;
float: left;
margin-right: 10px;
}
#myMap {
position: relative;
width: calc(100% - 360px);
min-width: 290px;
height: 600px;
float: left;
}
</style>
</head>
<body onload="getMap()">
<div class="sidePanel">
<fieldset style="width:320px;margin-bottom:10px;">
<legend>
<h1 style="font-size:16px">Mini overview map options</h1>
</legend>
This sample shows how to the mini overview map reacts to different options.
This samples uses the open source <a href="https://github.com/Azure-Samples/azure-maps-overview-map" target="_blank">Azure Maps Overview Map Control module</a>.
<br /><br />
<table>
<tr title="Specifies the type of information to overlay on top of the map.">
<td>Overlay:</td>
<td>
<select onchange="setOverlay(this)">
<option selected="selected">area</option>
<option>marker</option>
<option>none</option>
</select>
</td>
</tr>
<tr id="markerOption" style="display:none;" title="Specifies if marker is draggable.">
<td>Marker options<br />(draggable):</td>
<td><input type="checkbox" onclick="setMarkerDraggable(this)" /></td>
</tr>
<tr title="The height of the overview map in pixels.">
<td>Height</td>
<td>
<form oninput="h.value=height.value">
<input type="range" id="height" value="150" min="32" max="300" step="1" onchange="sliderUpdated(this, 'height')" />
<output name="h" for="height">150</output>
</form>
</td>
</tr>
<tr title="The width of the overview map in pixels.">
<td>Width</td>
<td>
<form oninput="w.value=width.value">
<input type="range" id="width" value="150" min="32" max="300" step="1" onchange="sliderUpdated(this, 'width')" />
<output name="w" for="width">150</output>
</form>
</td>
</tr>
<tr title="The name of the style to use when rendering the map. ">
<td>Map style:</td>
<td>
<select onchange="selectUpdated(this, 'mapStyle')">
<option>grayscale_dark</option>
<option>grayscale_light</option>
<option>high_contrast_dark</option>
<option>night</option>
<option selected="selected">road</option>
<option>road_shaded_relief</option>
<option>satellite</option>
<option>satellite_road_labels</option>
</select>
</td>
</tr>
<tr title="The style of the control.">
<td>Style:</td>
<td>
<select onchange="selectUpdated(this, 'style')">
<option>auto</option>
<option>auto-reverse</option>
<option>dark</option>
<option selected="selected">light</option>
</select>
</td>
</tr>
<tr title="Specifies the shape of the overview map.">
<td>Shape:</td>
<td>
<select onchange="selectUpdated(this, 'shape')">
<option selected="selected">square</option>
<option>round</option>
</select>
</td>
</tr>
<tr title="Specifies if zoom level changes should be synchronized.">
<td>Sync zoom:</td>
<td><input type="checkbox" onclick="setSyncZoom(this)" checked="checked" /></td>
</tr>
<tr id="zoomOption" style="display:none" title="Zoom level to set on overview map when not synchronizing zoom level changes.">
<td>Zoom</td>
<td>
<form oninput="z.value=zoom.value">
<input type="range" id="zoom" value="1" min="0" max="24" step="1" onchange="sliderUpdated(this, 'zoom')" />
<output name="z" for="zoom">1</output>
</form>
</td>
</tr>
<tr title="The number of zoom levels to offset from the parent map zoom level when synchronizing zoom level changes.">
<td>Zoom offset</td>
<td>
<form oninput="zo.value=zoomOffset.value">
<input type="range" id="zoomOffset" value="-5" min="-8" max="3" step="1" onchange="sliderUpdated(this, 'zoomOffset')" />
<output name="zo" for="zoomOffset">-5</output>
</form>
</td>
</tr>
<tr title="Specifies if bearing and pitch changes should be synchronized.">
<td>Sync bearing pitch:</td>
<td><input type="checkbox" onclick="checkboxUpdated(this, 'syncBearingPitch')" checked="checked" /></td>
</tr>
<tr title="Specifies if the overview map is interactive.">
<td>Interactive:</td>
<td><input type="checkbox" onclick="checkboxUpdated(this, 'interactive')" checked="checked" /></td>
</tr>
<tr title="Specifies if the overview map is minimized or not.">
<td>Minimized:</td>
<td><input type="checkbox" onclick="checkboxUpdated(this, 'minimized')" /></td>
</tr>
<tr title="Specifies if a toggle button for mininizing the overview map should be displayed or not.">
<td>Show toggle:</td>
<td><input type="checkbox" onclick="checkboxUpdated(this, 'showToggle')" checked="checked" /></td>
</tr>
<tr title="Specifies if the overview map control is visible or not.">
<td>Visible:</td>
<td><input type="checkbox" onclick="checkboxUpdated(this, 'visible')" checked="checked" /></td>
</tr>
</table>
<p>
Additional ways to customize the overview map.<br /><br />
- 'getLayers()' for area overlay.<br />
- 'markerOptions' for marker overlay.<br />
- 'getOverviewMap()' for more map settings.
</p>
</fieldset>
</div>
<div id="myMap"></div>
</body>
</html>