0

When I load my WFS into OpenLayers 4 it does not use the custom style which I've specified in ArcGIS Server. The points appear in the default OL style (white transparent fill with a blue outline).

I remember that when I used GeoServer the styles specified in the server would automatically appear in OL. So I expected it to be the same way with ArcGIS Server, but I guess that is not the case. I've added styles=default& in the WFS URL but with no success.

The JS I'm using to load the WFS:

SamF2016source = new ol.source.Vector({
format: new ol.format.WFS(),
loader: function (extent, resolution, projection) {
    var url = 'https://atlas.brabant.nl/arcgis/services/fauna/MapServer/WFSServer?request=GetFeature&typeName=SamF2016&version=1.1.0&styles=default&SRSname=EPSG:3857&outputFormat=gml3';
    // Use fetch, more simple & modern instead of XMLHttpRequest
    fetch(url).then(function (response) {
        return response.text();
    }).then(function (text) {
        var features = SamF2016source.getFormat().readFeatures(text);
        // Add parsed features to vectorSource
        SamF2016source.addFeatures(features);
    }).catch(function (error) {
        console.log(error.message);
    })
}
});

SamF2016 = new ol.layer.Vector({
    source: SamF2016source,
    setZIndex: 1005,
    title: 'SamF2016',
    visible: false,
});

In the GetCapabilities of the server the style is specified as so (bottom part of the GML):

Layer queryable="1">
<Name>1</Name>
<Title>
<![CDATA[ SamF2013 ]]>
</Title>
<Abstract>
<![CDATA[ ]]>
</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:28992</CRS>
<EX_GeographicBoundingBox>
<westBoundLongitude>4.211658</westBoundLongitude>
<eastBoundLongitude>6.025627</eastBoundLongitude>
<southBoundLatitude>51.244639</southBoundLatitude>
<northBoundLatitude>51.815840</northBoundLatitude>
</EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="4.211658" miny="51.244639" maxx="6.025627" maxy="51.815840"/>
<BoundingBox CRS="EPSG:4326" minx="51.244639" miny="4.211658" maxx="51.815840" maxy="6.025627"/>
<BoundingBox CRS="EPSG:28992" minx="73913.494800" miny="362246.413600" maxx="198987.600000" maxy="425141.200000"/>
<Style>
<Name>default</Name>
<Title>1</Title>
<LegendURL width="130" height="928">
<Format>image/png</Format>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://atlas.brabant.nl/arcgis/services/fauna/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=1" xlink:type="simple"/>
</LegendURL>
</Style>
</Layer>

When GetLegendGraphic is called the right symbology returns: http://atlas.brabant.nl/arcgis/services/fauna/MapServer/WmsServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=1

With a GetMap request the right symbology also returns (BBOX is a bit off but you get the idea): https://atlas.brabant.nl/arcgis/services/fauna/MapServer/WMSServer?request=GetMap&service=WMS&version=1.1.0&layers=1&styles=default&srs=EPSG:28992&bbox=-73913.494800,362246.413600,198987.600000,425141.200000&&width=780&height=330&format=image%2Fpng

What code do I need to add/adjust so that the points in my OL map appear like the symbology in the GetLegendGraphic and GetMap requests?

3

WFS don't give any rendered style, it's for you to apply. This is what any WFS does ~ gives you vector data.

WMS give an image where you give a style (using SLD) or you accept the default style.

The GetCapabilities you give is showing you the capabilities of the WMS, the WFS has a different GetCapabilities response, and different capabilities.

For the FeatureType that you are requesting has the following capabilities, there are no styles here:

<FeatureType>
    <Name>fauna:SamF2016</Name>
    <Title>SamF2016</Title>
    <DefaultCRS>urn:ogc:def:crs:EPSG:6.9:28992</DefaultCRS>
    <OtherSRS>urn:ogc:def:crs:EPSG:6.9:4326</OtherSRS>
    <OutputFormats>
        <Format>application/gml+xml; version=3.2</Format>
    </OutputFormats>
    <ows:WGS84BoundingBox>
        <ows:LowerCorner>4.2697569340901396 51.221271739696967</ows:LowerCorner>
        <ows:UpperCorner>6.029130352568183 51.822105829878616</ows:UpperCorner>
    </ows:WGS84BoundingBox>
</FeatureType>

Note the responses of the GetCapabilities requests is not GML its text/xml

  • That makes sense, thanks. So if I understand correctly it is not that easy to create a custom style like mine for a WFS? Having various amounts of fieldnames en colors. – Lout May 23 '18 at 9:42
  • You can't (AFAIK ~ would depend on the output formats supplied) create a style for a WFS, (you can't have the server apply a style that you request with the data), you can only style the data you receive from a WFS, that is apply the style in your client whether it be OpenLayers or ArcGIS or QGIS. Certainly with this service which only gives GML, you can't add a style. In the future with the support of vector tiles it might be a possibility. – nmtoken May 23 '18 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.