i want a simple website to show a WMS and want to use Openlayers. I started with Quick Start from Openlayers newest version, but got errors. So i took an old workspace (openlayers version 2) and edited this:
<!DOCTYPE html>
<html>
<head>
<title>OpenLayers Demo</title>
<link rel="stylesheet" href="https://openlayers.org/en/v4.3.1/css/ol.css" type="text/css">
<style type="text/css">
html, body, #basicMap {
width: 600px;
height: 600px;
margin: 10;
}
</style>
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>
</head>
<body onload="init();">
<div id="basicMap"></div>
<script>
function init() {}
map = new OpenLayers.Map("basicMap");
map.addLayer(new OpenLayers.Layer.OSM());
var mv = new OpenLayers.Layer.WMS(
"WMS MV",
"https://www.geodaten-mv.de/dienste/alkis_wms?",
{
layers: 'adv_alkis_flurstuecke',
version:"1.1.1",
format:"image/png"
},
{isBaseLayer: false}
);
map.addLayers([mv]);
map.setCenter(new OpenLayers.LonLat(11.5043,53.594) // Center of the map
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
new OpenLayers.Projection("EPSG:3857") // to Spherical Mercator Projection
),
16 // Zoom level
);
map.addControl( new OpenLayers.Control.LayerSwitcher() );
var ctrl_1 = new OpenLayers.Control.MousePosition({displayProjection: 'EPSG:4326'});
map.addControl( ctrl_1 );
</script>
</body>
</html>
So i got an little div with a map, but without the WMS.
I tested the WMS on this [enter link description here][1]
THE URL for WMS: https://www.geodaten-mv.de/dienste/alkis_wms?request=GetCapabilities&SERVICE=WMS&version=1.3.0
What am I doing wrong? I don't have to use Version 2 from OpenLayers! I need a simple local website to Show WMS as layer. Maybe there is a problem with projection...
[1]: http://gis.ibbeck.de/ginfo/apps/OLExamples/OL212/wms_example/add_WMSlayer.asp