This is the WFS service I'm using:
I add it to my OpenLayers map as a Vector layer as following:
proj4.defs("EPSG:25830","+proj=utm +zone=30 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");
register(proj4);
const proyeccion = getProjection('EPSG:25830');
var vectorSource = new VectorSource({
format: new GeoJSON(),
url: function(extent) {
return 'https://idena.navarra.es/ogc/wfs?service=WFS&version=1.1.0&request=GetFeature&typename=IDENA:DOTACI_Sym_AlojTur&outputFormat=application/json&srs=EPSG:25830';
},
strategy: bboxStrategy
});
var vector = new VectorLayer({
source: vectorSource,
projection: 'EPSG:25830',
style: new Style({
stroke: new Stroke({
color: 'rgba(215, 29, 29, 1.0)',
width: 4
})
})
});
var map = new Map({
target: 'map',
layers: [vector,layer], //layer is an WMS layer
view: new View({
projection: proyeccion,
center: fromLonLat([-1.629950,42.63],proyeccion),
zoom: 9
})
});
When loading the map, the WFS request is done and the response contains the feature collection in GeoJSON format and with the correct EPSG:
Although everything seems to work fine, the map does not show the wfs layer
What is the problem here?
EPSG:3857
orEPSG:4326
from your wfs server or you make ol3 aware about theEPSG:25830
projection. In my opinion 2nd option is the proper way to do it.const proyeccion = getProjection('EPSG:25830');
. Isn't that enough?