1

I am trying to get a point layer from GeoServer to load in my web app as a WFS. I can get a sample set of polygon data to load, but my points will not. Here is the code I am using for this:

var geojsonFormat = new ol.format.GeoJSON();

var vectorSource = new ol.source.Vector({
  loader: function(extent, resolution, projection) {
    var url = 'http://........?service=WFS&' +
        'version=1.1.0&request=GetFeature&typename=Store:layer&' +
        'outputFormat=text/javascript&format_options=callback:loadFeatures' +
        '&srsname=EPSG:3857&bbox=' + extent.join(',') + ',EPSG:3857';
    $.ajax({url: url, dataType: 'jsonp', jsonp: true});
  },
  strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
    maxZoom: 19
  }))
});
window.loadFeatures = function(response) {
  vectorSource.addFeatures(geojsonFormat.readFeatures(response));
};

var centerlocations = new ol.layer.Vector({
  source: vectorSource,
  style: new ol.style.Style({
    stroke: new ol.style.Stroke({
      color: 'rgba(0, 0, 255, 1.0)',
      width: 5
   })
  })
});

Is there something different that needs to be done for loading point data?

  • are there any points in response? if yes then check what readFeatures expects, else see Geoserver log file to see what went wrong – Ian Turton Sep 13 '15 at 2:11
  • Thanks for the response. Yes, the points are coming up in response and everything seems to fit what readFeatures is expecting – alex89 Sep 13 '15 at 16:23
1

The style you have defined is not applied on points. For point you need to set an imageStyle like this:

new ol.style.Style({
  image: new ol.style.Circle({
    stroke: new ol.style.Stroke({
      color: 'rgba(0, 0, 255, 1.0)',
      width: 5
     }),
    radius: 5
  })
});

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.