-
Notifications
You must be signed in to change notification settings - Fork 471
Expand file tree
/
Copy pathOGC map layer options.html
More file actions
353 lines (310 loc) · 15.8 KB
/
OGC map layer options.html
File metadata and controls
353 lines (310 loc) · 15.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>OGC map layer 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 the OGC map layer affect rendering." />
<meta name="keywords" content="Microsoft maps, map, gis, API, SDK, tiles, layer" />
<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 src="/lib/clipboard/dist/clipboard.min.js"></script>
<script>
var map, tileLayer, defaultOptions, removeDefaults;
function getMap() {
//Initialize a map instance.
map = new atlas.Map('myMap', {
center: [-100, 31.5],
zoom: 5,
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 style control and add it to the map.
map.controls.add(new atlas.control.StyleControl({
style: 'dark',
mapStyles: 'all'
}), {
position: 'top-right'
});
//Create an instance of the OGC map layer and add it to the map. In this case below the transit data (roads).
layer = new atlas.layer.OgcMapLayer();
map.layers.add(layer, 'transit');
defaultOptions = layer.getOptions();
//Update the tile layer with the options in the input fields.
updateLayer();
});
new ClipboardJS('.copyBtn');
}
function updateLayer(updateSource) {
var options = getLayerOptions();
//Update the options on the layer.
layer.setOptions(options);
document.getElementById('CodeOutput').value = JSON.stringify(options, null, '\t').replace(/\"([^(\")"]+)\":/g, "$1:");
}
function getLayerOptions() {
removeDefaults = document.getElementById('RemoveDefaults').checked;
return {
url: document.getElementById('url').value,
bringIntoView: getPropertyValue('bringIntoView', document.getElementById('bringIntoView').checked),
debug: getPropertyValue('debug', document.getElementById('debug').checked),
contrast: getPropertyValue('contrast', parseFloat(document.getElementById('Contrast').value)),
fadeDuration: getPropertyValue('fadeDuration', parseFloat(document.getElementById('FadeDuration').value)),
hueRotation: getPropertyValue('hueRotation', parseFloat(document.getElementById('HueRotation').value)),
maxBrightness: getPropertyValue('maxBrightness', parseFloat(document.getElementById('MaxBrightness').value)),
minBrightness: getPropertyValue('minBrightness', parseFloat(document.getElementById('MinBrightness').value)),
opacity: getPropertyValue('opacity', parseFloat(document.getElementById('Opacity').value)),
saturation: getPropertyValue('saturation', parseFloat(document.getElementById('Saturation').value)),
minZoom: getPropertyValue('minZoom', parseFloat(document.getElementById('MinZoom').value)),
maxZoom: getPropertyValue('maxZoom', parseFloat(document.getElementById('MaxZoom').value)),
visible: getPropertyValue('visible', document.getElementById('Visible').checked)
};
return Object.assign(layerOptions, sourceOptions);
}
function getPropertyValue(propertyName, value) {
if (removeDefaults && defaultOptions[propertyName] === value) {
return undefined;
}
return value;
}
function getSelectValue(id) {
var elm = document.getElementById(id);
return elm.options[elm.selectedIndex].value;
}
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;
}
#CodeOutput {
width: 290px;
height: 350px;
overflow-y: auto;
}
.copyBtn {
float: right;
}
table td:nth-of-type(1) {
width: 120px;
}
table td:nth-of-type(2) {
width: 200px;
}
.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;
}
</style>
</head>
<body onload="getMap()">
<fieldset class="sidePanel">
<legend>OGC map layer options</legend>
This sample shows how the different options of the OGC map layer affect rendering.
<br /><br />
<div class="tab">
<button class="tablinks active" onclick="openTab(this, 'StyleOptions')">Base Options</button>
<button class="tablinks" onclick="openTab(this, 'MediaOptions')">Media Options</button>
<button class="tablinks" onclick="openTab(this, 'LayerOptions')">Layer options</button>
<button class="tablinks" onclick="openTab(this, 'Code')">Code</button>
</div>
<div id="StyleOptions" class="tabcontent" style="display:block;">
<table>
<tr title="An integer specifying the minimum zoom level to render the layer at.">
<td>Min Zoom:</td>
<td>
<form oninput="minz.value=MinZoom.value">
<input type="range" id="MinZoom" value="0" min="0" max="24" step="1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="minz" for="MinZoom">0</output>
</form>
</td>
</tr>
<tr title="An integer specifying the maximum zoom level to render the layer at.">
<td>Max Zoom:</td>
<td>
<form oninput="maxz.value=MaxZoom.value">
<input type="range" id="MaxZoom" value="24" min="0" max="24" step="1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="maxz" for="MaxZoom">24</output>
</form>
</td>
</tr>
<tr title="Specifies if the layer is visible or not.">
<td>Visible:</td>
<td><input id="Visible" type="checkbox" onclick="updateLayer()" checked="checked" /></td>
</tr>
</table>
<p>
In addition to the options in this tool, the OGC map layer also has options for;
<ul>
<li>activeLayers - Specifies the sublayers in the service to render.</li>
<li>dimensions - Custom dimensions to add to tile requests.</li>
<li>proxyService - URL to a CORs enabled proxy service.</li>
<li>service - Specify if service is WMS or WMTS. Auto detected by default.</li>
<li>styles - The styles of the active layers.</li>
<li>version - The service version to use in requests. Auto detected by default.</li>
</ul>
</p>
</div>
<div id="MediaOptions" class="tabcontent">
<table>
<tr title="The duration in milliseconds of a fade transition when a new tile is added. ">
<td>Fade Duration</td>
<td>
<form oninput="fadeDuration.value=FadeDuration.value">
<input type="range" id="FadeDuration" value="300" min="0" max="1000" step="100" oninput="updateLayer()" onchange="updateLayer()" />
<output name="fadeDuration" for="FadeDuration">300</output>
</form>
</td>
</tr>
<tr title="A number between 0 and 1 that indicates the opacity at which the overlay will be drawn.">
<td>Opacity</td>
<td>
<form oninput="opacity.value=Opacity.value">
<input type="range" id="Opacity" value="1" min="0" max="1" step="0.1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="opacity" for="Opacity">1</output>
</form>
</td>
</tr>
<tr title="A number between -1 and 1 that increases or decreases the contrast of the overlay.">
<td>Contrast</td>
<td>
<form oninput="contrast.value=Contrast.value">
<input type="range" id="Contrast" value="0" min="-1" max="1" step="0.1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="contrast" for="Contrast">0</output>
</form>
</td>
</tr>
<tr title="Rotates hues around the color wheel. A number in degrees.">
<td>Hue Rotation</td>
<td>
<form oninput="hueRotation.value=HueRotation.value">
<input type="range" id="HueRotation" value="0" min="0" max="360" step="1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="hueRotation" for="HueRotation">0</output>
</form>
</td>
</tr>
<tr title="A number between 0 and 1 that increases or decreases the maximum brightness of the overlay.">
<td>Max Brightness</td>
<td>
<form oninput="maxBrightness.value=MaxBrightness.value">
<input type="range" id="MaxBrightness" value="1" min="0" max="1" step="0.1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="maxBrightness" for="MaxBrightness">1</output>
</form>
</td>
</tr>
<tr title="A number between 0 and 1 that increases or decreases the minimum brightness of the overlay.">
<td>Min Brightness</td>
<td>
<form oninput="minBrightness.value=MinBrightness.value">
<input type="range" id="MinBrightness" value="0" min="0" max="1" step="0.1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="minBrightness" for="MinBrightness">0</output>
</form>
</td>
</tr>
<tr title="A number between -1 and 1 that increases or decreases the saturation of the overlay.">
<td>Saturation</td>
<td>
<form oninput="saturation.value=Saturation.value">
<input type="range" id="Saturation" value="0" min="-1" max="1" step="0.1" oninput="updateLayer()" onchange="updateLayer()" />
<output name="saturation" for="Saturation">0</output>
</form>
</td>
</tr>
</table>
</div>
<div id="LayerOptions" class="tabcontent">
<table>
<tr title="The URL that points to the service.">
<td>Url:</td>
<td>
<input type="text" id="url" value="https://tpwd.texas.gov/arcgis/rest/services/Vegetation_Mapping/Texas_Ecological_Mapping_Systems_Data/mapserver/WMTS/1.0.0/WMTSCapabilities.xml" />
</td>
</tr>
<tr title="Indicates if the map should set the map view to the bounding box of the layer. Not persistent.">
<td>Bring into view:</td>
<td><input id="bringIntoView" type="checkbox"/></td>
</tr>
<tr title="Indicates if errors related to accessing the service should be logged to the console.">
<td>Debug:</td>
<td><input id="debug" type="checkbox" /></td>
</tr>
<tr>
<td></td>
<td><input type="button" value="Update layer options" onclick="updateLayer();" /></td>
</tr>
</table>
</div>
<div id="Code" class="tabcontent">
<textarea id="CodeOutput"></textarea><br /><br />
<input id="RemoveDefaults" type="checkbox" onclick="updateLayer()" checked="checked" /> Remove defaults
<button class="copyBtn" data-clipboard-target="#CodeOutput">Copy to clipboard</button>
</div>
</fieldset>
<div id="myMap"></div>
</body>
</html>