trim hash part from custom imagery source URLs

before trying to detect the imagery source's type, fixes #8822
This commit is contained in:
Martin Raifer
2022-02-16 21:57:03 +01:00
parent 04a07092d2
commit 352f244d68

View File

@@ -112,19 +112,19 @@ export function rendererBackgroundSource(data) {
source.url = function(coord) {
var result = _template;
var result = _template.replace(/#.*/su, ''); // strip hash part of URL
if (result === '') return result; // source 'none'
// Guess a type based on the tokens present in the template
// (This is for 'custom' source, where we don't know)
if (!source.type || source.id === 'custom') {
if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(_template)) {
if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) {
source.type = 'wms';
source.projection = 'EPSG:3857'; // guess
} else if (/\{(x|y)\}/.test(_template)) {
} else if (/\{(x|y)\}/.test(result)) {
source.type = 'tms';
} else if (/\{u\}/.test(_template)) {
} else if (/\{u\}/.test(result)) {
source.type = 'bing';
}
}