Add WTMS VAO Ausland.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Mon, 11 Jan 2021 21:10:37 +0000 (22:10 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Mon, 11 Jan 2021 21:10:37 +0000 (22:10 +0100)
wrmap.js

index 51723339fdac2167b449b5d78cbf93bee4868f16..d7d051a8909fb624b7ed45868f981caeab8c4c52 100644 (file)
--- a/wrmap.js
+++ b/wrmap.js
@@ -284,29 +284,23 @@ function init_wrmap(i, jq_map) {
        function is_in_austria(feature) {
                return austria_feature.getGeometry().intersectsCoordinate(feature.getGeometry().getFirstCoordinate());
        }
-       if (features_all.every(is_in_austria)) {
-               let capabilitiesUrl = 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml';
-               fetch(capabilitiesUrl).then(function(response) {
-                       return response.text();
-               }).then(function(text) {
-                       let result = new ol.format.WMTSCapabilities().read(text);
-                       let options = ol.source.WMTS.optionsFromCapabilities(result, {
-                               layer: 'bmapgrau', // geolandbasemap
-                               matrixSet: 'google3857',
-                               style: 'normal',
-                       });
-                       options['attributions'] = 'Grundkarte: <a href="https://www.basemap.at/">basemap.at</a>';
-                       let layer_map = new ol.layer.Tile({
-                               source: new ol.source.WMTS(options),
-                       });
-                       map.getLayers().insertAt(0, layer_map);
+       let austria_only = features_all.every(is_in_austria);
+       let capabilitiesUrl = austria_only ? 'https://www.basemap.at/wmts/1.0.0/WMTSCapabilities.xml' : 'https://maps.wien.gv.at/vao/1.0.0/WMTSCapabilities.xml';
+       fetch(capabilitiesUrl).then(function(response) {
+               return response.text();
+       }).then(function(text) {
+               let result = new ol.format.WMTSCapabilities().read(text);
+               let options = ol.source.WMTS.optionsFromCapabilities(result, {
+                       layer: austria_only ? 'bmapgrau' : 'vaoausland',
+                       matrixSet: 'google3857',
+                       style: 'normal',
                });
-       } else {
+               options['attributions'] = austria_only ? 'Grundkarte: <a href="https://www.basemap.at/">basemap.at</a>' : 'Grundkarte: <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>';
                let layer_map = new ol.layer.Tile({
-                       source: new ol.source.OSM()
+                       source: new ol.source.WMTS(options),
                });
                map.getLayers().insertAt(0, layer_map);
-       }
+       });
 
        // // Alternatives:
        // // * OpenTopoMap (see https://opentopomap.org/about)