我想一个WMS覆盖集成到我的默认的OpenLayers地图。 仅使用ol.source.OSM({})
层中的地图呈现很好,但是当我添加WMS层到layers: []
数组它只是给我一个空白地图。 我使用下面的代码,但它不工作,我需要什么改变?
<!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>