This should actually be very easy, but I've been stuck here for two days and still can't find a reason why OpenLayers doesn't do what I am expected from the API.
There is a WFS Layer I want to load and show in my map. The Capabilities can be seen here: http://www.pegelonline.wsv.de/webservices/gis/aktuell/wfs?service=WFS&request=GetCapabilities
After going through the Capabilities, I started to build my VectorLayer. I have read from the Openlayers API that there are two ways to load the features: one is with format and url, another is with loader.
Since the format + url way seems very simple, I decided to use this. I created the URL based on what I got from the Capabilities:http://www.pegelonline.wsv.de/webservices/gis/aktuell/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=gk:waterlevels&outputFormat=GML3
As you can see, all 530 features in GML3 format can be loaded through this URL, so up until this stage there is no problem.
I started to write OpenLayers 5 code:
createVectorLayer () {
const vectorLayer = new VectorLayer({
name:"waterlevels",
source: new VectorSource({
format: new GML3(),
url: "http://www.pegelonline.wsv.de/webservices/gis/aktuell/wfs?service=WFS&version=1.1.0&request=GetFeature&typeName=gk:waterlevels&outputFormat=GML3"
}),
style: new OlStyle({
image: new Icon({
src: 'static/Icons/waterlevels.png'
})
})
})
}
I have done all the imports, but just not shown them here to save space.
The first thought was actually that the style seems not very good. But after I check the layers with layer.getSource().getFeatures()
I find out there there are 0 features in the Vectorlayer.
But in the net analyse, I could see the GML file with 530 features successfully loaded. So I am a little bit confused right now.
I would appreciate if someone can point out which step I may be doing wrong here. I have already checked multiple times for imports, WFS Capabilities, and changed Styles also multiple times. I even tried with loader, But nothing works so far.