3

I'm working with AIMS(Autodesk Infrasture Map Studio) and openlayers 3, I have a WFS layers in AIMS Server that i want to display using OL3. it doesn't show any errors, the map appears but the layers does not show. it works with wms ol3, but not wfs. I'm using latest version of openlayers 3.10.1 and examples of wfs layers http://openlayers.org/en/v3.10.1/examples/vector-wfs.html

Please can anyone help me to fix that? This is my code :

 var vectorSource = new ol.source.Vector({
   format: new ol.format.WFS({
     featureNS: "http://fdo.osgeo.org/schemas/feature/ns224280581",
     featureType: "BRGYBOUNDARY"
   }),
   url: function(extent,resolution, projection) {
   return 'http://192.168.7.7/mapserver2014/mapagent/mapagent.fcgi?service=WFS&version=1.1.0&request=GetFeature&typename=ns224280581:BRGYBOUNDARY&maxFeatures=1000&outputFormat=GML3&srsname=EPSG:4326&bbox=' + extent.join(',') + ',EPSG:3857';
 },
  strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
  maxZoom: 19
  }))
 });
var vector = new ol.layer.Vector({
 source: vectorSource,
  style: new ol.style.Style({
   stroke: new ol.style.Stroke({
   color: 'rgba(0, 0, 255, 1.0)',
   width: 2
  })
    })
 });

  var raster = new ol.layer.Tile({
  source: new ol.source.OSM
 });

  var map = new ol.Map({
   layers: [raster, vector],
   target: document.getElementById('map'),
    view: new ol.View({
     center: ol.proj.transform([120.604169, 15.480071], 'EPSG:4326','EPSG:3857'),         
maxZoom: 19,
zoom: 12
  })
});

AIMS WFS Layers http://192.168.7.7/mapserver2014/mapagent/mapagent.fcgi?service=WFS&version=1.1.0&request=GetFeature&typename=ns224280581:BRGYBOUNDARY&maxFeatures=1000&outputFormat=GML3&srsname=EPSG:4326

1

The url you provide doesnt work. Try to use the following code for your vector layer. It will show if the url fails to load.

var vectorSource = new ol.source.Vector({
loader: function (extent) {
    //place here any actions on start loading layer
    document.getElementById('laodingcont').innerHTML = "<font color='orange'>start loading.....</font>";
    $.ajax('http://192.168.7.7/mapserver2014/mapagent/mapagent.fcgi', {
        type: 'GET',
        data: {
            service: 'WFS',
            version: '1.1.0',
            request: 'GetFeature',
            typename: 'ns224280581:BRGYBOUNDARY',
            srsname: 'EPSG:4326',
            bbox: extent.join(',') + ',EPSG:3857'
        }
    }).done(loadFeatures) //success function here (loadFeatures)
        .fail(function () {
        //place here any actions on fail loading layer
        document.getElementById('laodingcont').innerHTML = "<font color='red'>error loading vector layer.</font>";
    });
},
strategy: ol.loadingstrategy.bbox
});
//get back the success responce and manipulate
function loadFeatures(response) {
    formatWFS = new ol.format.WFS(),
    vectorSource.addFeatures(formatWFS.readFeatures(response));
    document.getElementById('laodingcont').innerHTML = "<font color='green'>finish loading vector layer.</font>";
}

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.