OpenLayers 3 Stroke style

FatAl picture FatAl · Apr 30, 2015 · Viewed 7.6k times · Source

I want to modify style of the method select . I'm able to change the style of this method but i'm not able to duplicate the white border of blue stroke.

Someone is able to style vector with a stroke and put a border to the stroke?

See this example, for understand what i'm talking about: http://openlayers.org/en/v3.4.0/examples/select-features.html

Answer

tsauerwein picture tsauerwein · Apr 30, 2015

The trick is that you have two styles. With the first style you are drawing a white line, with the second style a thinner blue line on top:

var width = 3;
var styles = [
  new ol.style.Style({
    stroke: new ol.style.Stroke({
      color: 'white',
      width: width + 2
    })
  }),
  new ol.style.Style({
    stroke: new ol.style.Stroke({
      color: 'blue',
      width: width
    })
  })
];