I had an OpenLayers 4.6.5 application, which showed a map, and on top of that had the option to turn on and off some overlays.
The overlays are of the type TileWMS, and seemed to work perfectly.
At first i got called OpenLayers remotely like this:
<script src="https://openlayers.org/en/v4.6.5/build/ol.js" type="text/javascript"></script>
But i need to store do it locally instead, and at the same time upgrade to 5.3.0. So i downloaded the v5.3.0-dist.zip, added the files and replaces the above with:
<script src="./lib/ol/ol.js"></script>
Everything seems to work as before, except for the TileWMS, which simply isn't showing.
As far as i can tell there is nothing, in the upgrade notes, indicating that something should have changed.
I have tried excluding unnecessary parts of my JavaScript, so let me know if i left out too much:
var token = "123456thisisnotmytoken";
var myProjection = new ol.proj.Projection({
code: projCode,
units: "m",
extent: [120000, 5661139.2, 1378291.2, 6500000]
});
var projection = GetProjection(myProjection);
var projectionExtent = projection.getExtent();
const map = new Map({
target: "map",
layers: [
new Group({
"title": "Base maps",
layers: [
new ol.layer.Tile({...
}),
new ol.layer.Tile({...
})
]
}),
new Group({
"title": "Overlays",
layers: [
new ol.layer.Tile({
title: "Matrikel",
type: "overlay",
visible: true,
opacity: 1.0,
zIndex: 1000,
source: new ol.source.TileWMS({
url: "https://services.kortforsyningen.dk/mat?token=" + token,
params: {
"LAYERS": "MatrikelSkel,Centroide",
"VERSION": "1.1.1",
"TRANSPARENT": "true",
"FORMAT": "image/png",
"STYLES": ""
},
})
}),
new ol.layer.Tile({
title: "Hillshade",
type: "overlay",
visible: false,
opacity: 1.0,
zIndex: 900,
source: new ol.source.TileWMS({
url: "https://services.kortforsyningen.dk/dhm?token=" + token,
params: {
"LAYERS": "dhm_terraen_skyggekort_transparent_overdrevet",
"VERSION": "1.1.1",
"TRANSPARENT": "true",
"FORMAT": "image/png",
"STYLES": ""
},
})
})
]
}),
],
view: view
});
map.addControl(new ol.control.LayerSwitcher());
I get that the second TileWMS is hidden as default, but i have tried turning it on and off in the LayerSwitcher, which worked before the upgrade.
Any suggestions pn how i fix this?