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)