I'm wondering how to display a Layer in OpenLayers 3 which I host in Geoserver. I imported the Layer from a PostGIS-DB and it is possible to display it using the geoserver preview option. The Layer uses EPSG:3857.
<html lang="en">
<head>
<link rel="stylesheet" href="http://openlayers.org/en/v3.1.1/css/ol.css" type="text/css">
<style>
.map {
height: 900px;
width: 900px;
}
</style>
<script src="http://openlayers.org/en/v3.1.1/build/ol.js" type="text/javascript"></script>
<title>test</title>
</head>
<body>
<div id="map" class="map"></div>
<script>
var layers = [
new ol.layer.Tile ({
extent: [3359890.5, 5761308, 3395047, 5773695.5],
source: new ol.source.TileWMS(/** @type {olx.source.TileWMSOptions} */
({
url: 'http://192.168.1.14:8082/geoserver/wms',
params: {
'LAYERS': 'jueterbog:fl_spa',
'TILED': true,
},
title: 'SPA'
})
)
}),
new ol.layer.Tile ({
source: new ol.source.OSM()
})
];
var map = new ol.Map ({
layers: layers,
target: 'map',
view: new ol.View ({
center: [1450000,6809000],
zoom: 12
})
});
</script>
</body>
</html>
The Layer should be displayed in this area: 52.025151, 13.069072