1

Wondering if it's possible to add multiple strokes to a polygon or line feature (the same thing could apply to multiple fills for polygons too).

The leaflet documentation on the L.Path style options doest seem to suggest there is a way. For example, styling the stroke once is straightforward:

var geoJsonFeature = L.geoJson(data, {
  style: {
    color: '#ff9700',
    weight: 4
  }
}).addTo(map);

... but it doesn't appear to allow adding a second, thin stroke on top (e.g. with a thinner weight, so the two are strokes are layered one on top of the other), w/o, I guess, loading the geojson twice.

Is it possible to hack this somehow? Or might it be possible with another library like d3.js?

  • 2
    Import the same feature twice, with different names. Then style as needed. – Fjellrev May 2 '17 at 10:13
1

I don't think that is currently possible in leaflet. I'm not sure about d3 either because I've never used it. If it was my project I would create two functions: one that creates the base layer styling and one that adds the secondary layer on top.

  • 2
    This would probably be better as a comment? – John Powell Mar 11 '15 at 16:44

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.