I have an openlayers map in my project and I wanted to add WMS tiles to it. This is my code :
const map = new ol.Map({
layers: [
new ol.layer.Tile({
name: 'wmstiles',
source: new ol.source.TileWMS({
url: 'https://ssl-geowms.lillemetropole.fr/dynmapr/dynmapr.php',
serverType: 'geoserver',
version:"1.1.1",
params: {
LAYERS: 'PLU%2Fplu',
VERSION: '1.1.1',
TRANSPARENT: false,
HEIGHT: 256,
WIDTH: 256
},
pixelRatio: 1,
projection: 'EPSG:2154'
}),
visible: false
})
],
view: new ol.View({
center: ol.proj.fromLonLat([3.1666, 50.6167]),
zoom: 13,
maxZoom: 20,
})
});
As you can see, I'm trying to project the coordinates into EPSG:2154
(France) in order to send them to the WMS server. But my map is blank because openlayers did not generate a call with the good projection.
Instead of something like this (generated from another website that is not using openlayers) : https://ssl-geowms.lillemetropole.fr/dynmapr/dynmapr.php?in=PLU/plu&service=WMS&request=GetMap&version=1.1.1&layers=PLU%2Fplu&styles=&format=image%2Fjpeg&transparent=false&height=256&width=256&srs=EPSG%3A2154&bbox=704615.2885901299,7064111.541254971,705393.894388002,7064886.656737898
As you can see, it dit not reproject into EPSG:2154
but in EPSG:3857
. There are also other problems like the height and width but this is another story. If I copy/paste the bounding box from the working link to the first one, it works.