Reputation: 1105
Does anyone known any working method to draw polylines on Leaflet with constant width in meters?
I can't find any working solutions for this. Documentation about Leaflet Path have only stroke with weight in pixels.
Upvotes: 3
Views: 2406
Reputation: 35134
I've just published leaflet-corridor
plugin which does exactly what you asked for: draws a polyline with width fixed in meters.
Usage:
var corridor = L.corridor([/*Array of L.latlng*/], widthInMeters);
map.addLayer(corridor);
Upvotes: 3
Reputation: 228
Your map tile provider probably provides the meters/pixel data for all the zoom levels. OpenStreetMaps example: http://wiki.openstreetmap.org/wiki/Zoom_levels
Then add an event to zoomend that scales the strokewidth of your polyline(s) based on the current zoom level.
Upvotes: 0
Reputation: 1398
There isn't any method like that, but knowing the density of pixels on the screen, you can get the number of pixels you need for 1 meter.
Upvotes: 1