Saturday 19 October 2019

javascript - How can I use WFS from Geoserver with OpenLayers 3?


I have tried with different setups and formats, but no success.


With firebug, I can see that the json data is loaded, but nothing shows up on the map.


Have anyone experience with geoserver and wfs in openlayers 3?


var layer_ojd_vector = new ol.layer.Vector({
source: new ol.source.Vector({
parser: new ol.parser.GeoJSON(),
url: http://SERVER:8080/geoserver/NS/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=NS:LAYER&maxFeatures=50&outputFormat=json

}),
style: new ol.style.Style({rules: [
new ol.style.Rule({
filter: 'geometryType("point")',
symbolizers: [
new ol.style.Shape({
fillColor: '#013',
size: 40
})
]

})
]})
});

Answer



I've seen this answered quite a bit on here.


You must run the HTML file from a webserver and access by:


SERVER:8080/geoserver/index.html


or however yours is setup.


You can't simply double click the HTML file and view the WFS layer.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...