Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reducing border width of Leaflet polygon

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.

like image 291
Peter Avatar asked Aug 03 '15 10:08

Peter


1 Answers

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 });
like image 198
tmcw Avatar answered Sep 28 '22 13:09

tmcw