I am trying to integrate a WMS overlay onto my default OpenLayers map. Using just the ol.source.OSM({})
layer the map renders fine, but when I add the WMS layer to the layers: []
array it just gives me a blank map. I am using the following code but it isn't working, what do I need to change?
<!doctype html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/css/ol.css" type="text/css">
<style>
.map {
height: 100%;
width: 100%;
}
</style>
<script src="https://cdn.rawgit.com/openlayers/openlayers.github.io/master/en/v5.3.0/build/ol.js"></script>
<title>OpenLayers example</title>
</head>
<body>
<h2>WMS Map</h2>
<div id="map" class="map"></div>
<script type="text/javascript">
var map = new ol.Map({
target: 'map',
layers: [
new ol.layer.Tile(
{
source: new ol.source.OSM({})
}),
new ol.layer.ImageWMS(
{
source: new ol.source.ImageWMS(
{
url: 'http://www.igeo.pt/WMS/Geologia/CGP1M'
})
})
],
view: new ol.View(
{
center: ol.proj.fromLonLat([37.41, 8.82]),
zoom: 4
})
});
</script>
</body>
</html>