Wednesday, 2 May 2018

OpenLayers 3 - display layer WFS in EPSG:4326


I have to display a layer from a WFS service (http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Bacini_idrografici.map) using OpenLayers 3.x API (..there's a reason). The WFS service is exposed in EPSG:4326.



In similar cases I have always used the following code successfully:


var sourceWFS = new ol.source.Vector({
loader: function (extent) {
$.ajax('http://wms.pcn.minambiente.it/ogc?map=/ms_ogc/wfs/Bacini_idrografici.map', {
type: 'GET',
data: {
service: 'WFS',
version: '1.1.0',
request: 'GetFeature',
typename: 'ID.ACQUEFISICHE.BACINIIDROGRAFICI.PRINCIPALI',

srsname: 'EPSG:4326',
bbox: extent.join(',') + ',EPSG:4326'
}
}).done(loadFeatures)
.fail(function () {
alert("error loading vector layer");
});
},
strategy: ol.loadingstrategy.bbox,
});


function loadFeatures(response) {
var formatWFS = new ol.format.WFS();
sourceWFS.addFeatures(formatWFS.readFeatures(response));
}

var vectorLayerWFS = new ol.layer.Vector({
source: sourceWFS,
});


But now, this layer WFS isn't displayed on the map and I do not understand why?


What's wrong?




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...