1 | goog.require('ol.Map');
|
2 | goog.require('ol.View');
|
3 | goog.require('ol.format.WMTSCapabilities');
|
4 | goog.require('ol.has');
|
5 | goog.require('ol.layer.Tile');
|
6 | goog.require('ol.source.WMTS');
|
7 |
|
8 |
|
9 | var capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml';
|
10 |
|
11 |
|
12 |
|
13 |
|
14 | var hiDPI = ol.has.DEVICE_PIXEL_RATIO > 1;
|
15 | var layer = hiDPI ? 'bmaphidpi' : 'geolandbasemap';
|
16 | var tilePixelRatio = hiDPI ? 2 : 1;
|
17 |
|
18 | var map = new ol.Map({
|
19 | target: 'map',
|
20 | view: new ol.View({
|
21 | center: [1823849, 6143760],
|
22 | zoom: 11
|
23 | })
|
24 | });
|
25 |
|
26 | fetch(capabilitiesUrl).then(function(response) {
|
27 | return response.text();
|
28 | }).then(function(text) {
|
29 | var result = new ol.format.WMTSCapabilities().read(text);
|
30 | var options = ol.source.WMTS.optionsFromCapabilities(result, {
|
31 | layer: layer,
|
32 | matrixSet: 'google3857',
|
33 | style: 'normal'
|
34 | });
|
35 | options.tilePixelRatio = tilePixelRatio;
|
36 | map.addLayer(new ol.layer.Tile({
|
37 | source: new ol.source.WMTS( (options))
|
38 | }));
|
39 | });
|