I am trying to connect a WMS layer from GeoServer with OpenLayers 3 like below, however, my JavaScript file does not show my WMS layer.
My Chrome says it failed to load response data (WMS). My source is redirected to below URL. This URL works on my server, but not through the JavaScript source.
Can someone please help?
It seems like the problem is caused from security settings in GeoServer and I tried to create roles to getread()
as well. (http://docs.geoserver.org/stable/en/user/security/service.html)
var layers = [
new ol.layer.Tile({
extent: [-13884991, 2870341, -7455066, 6338219],
source: new ol.source.TileWMS({
url: "http://localhost:8080/geoserver/Mars/wms",
params: {'layers': 'Mars:Mercury_basemap', 'tiled': true, 'format': 'application/openlayers', 'srs': 'EPSG:4326', 'transparent': true},
serverType: 'geoserver'
}))
})
];
var map = new ol.Map({
layers: layers,
target: 'map',
view: new ol.View({
center: [-10997148, 4569099],
zoom: 4
})
});
srs=EPSG%3A4326&
as it's the wrong parameter to request your coordinate reference system for a WMS 1.3.0 GetMap request. You also have the correct parameter though asCRS=EPSG%3A3857&