1

I wonder why the new style is not applied to the features of the vector. The code below works fine but the style is not applied.

var layerWFS = new ol.layer.Vector({
  source: new ol.source.Vector({
    loader: function(extent) {
      $.ajax('http://demo.opengeo.org/geoserver/wfs', {
        type: 'GET',
        data: {
          service: 'WFS',
          version: '1.1.0',
          request: 'GetFeature',
          typename: 'placenames_medium',
          srsname: 'EPSG:3857',
          bbox: extent.join(',') + ',EPSG:3857'
        }
      }).done(function(response) {
        layerWFS
        .getSource()
        .addFeatures(new ol.format.WFS()
          .readFeatures(response));
      });
    },
    strategy: ol.loadingstrategy.bbox,
    projection: 'EPSG:3857',
    style: new ol.style.Style({
         image: new ol.style.Circle({
           radius: 3,
           fill: new ol.style.Fill({
              color: 'orange'}), 
           stroke: new ol.style.Stroke({
             color: 'black'})
        })
      })
    })
});

var map = new ol.Map({
  target: 'map',
  controls: [],
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    }),
    layerWFS
  ],
  view: new ol.View({
    center: [-8908887.277395891, 5381918.072437216],
    zoom: 14
  })
});

Where is the problem?

I followed this example to apply the style: http://mappinggis.com/2016/06/anadir-wfs-en-openlayers-simbologia/

Codepen: http://codepen.io/ricopo/pen/GjRgam

3

style should be defined on the layer not the source

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.