7

When adding a polygon to a Leaflet map, the border is quite wide (dark blue in image below). For maps of a wide area, this often obscures finer details of the map underneath.

Is it possible to reduce the width of the border, while retaining the other default styling of the polygon?

Currently I am creating the polygon from GeoJSON using

var boundary = { "type": "Feature", "geometry": {"type":"Polygon","coordinates":[....]}};
var poly = L.geoJson(boundary);
map.addLayer(poly);

Map of Hoxton, London

I am using Leaflet 0.7.3 (latest stable release). I'd be interested in solutions that change the style across all instances of leaflet maps, as well as ways to change it for a specific map.

Peter
  • 1,674
  • 4
  • 27
  • 44

1 Answers1

19

Please read the Leaflet documentation, which specifies a weight option for paths, which you can specify as an option to L.geoJson.

var poly = L.geoJson(boundary, { weight: 1 });
tmcw
  • 11,536
  • 3
  • 36
  • 45
  • Thanks - this looks perfect. Could you modify your answer to include the code snippet in the answer - hyperlinks are prone to change or break over time. – Peter Aug 03 '15 at 14:27
  • @tmcw, do you know about how to specify no outline on polygons? – daniella Dec 12 '17 at 23:09
  • It's the first option in the linked documentation: `stroke: false` – tmcw Dec 12 '17 at 23:59