Line width in meters

141 views
Skip to first unread message

gogli...@gmail.com

unread,
Sep 30, 2013, 6:23:38 AM9/30/13
to leafl...@googlegroups.com
Good afternoon. 
How to create a line, the width of which is not specified in pixels, and in meters (that is, when you change the scale and changed the apparent thickness of the line)?

Dypsok

unread,
Nov 4, 2016, 4:18:15 AM11/4/16
to Leaflet, gogli...@gmail.com

Hi, 
  have you find any solution to this problem ?
  I have the exact same problem : too many lines are drawn on the map (heavy city bus transport network) and they are all overlapping .
  So I was thinking that the best solution would have been some sort of polylines cluster, that dynamically change the with of lines on hight zoom...
   
  Any help is welcome.

Thanks.

Malcolm Meyer

unread,
Nov 7, 2016, 8:27:26 AM11/7/16
to Leaflet, gogli...@gmail.com
well not sure about width in meters, but there is a plugin for overlapping lines - for the bus network example - that will draw offset lines, similar to what you would see in a print transit map. Dont recall the name of the plugin but search for it it exists.

k_man_au

unread,
Nov 7, 2016, 9:16:27 PM11/7/16
to Leaflet, gogli...@gmail.com
If I was going to do it I'd work out how many pixels per meter at a specified zoom and then use that figure to alter the symbol on a zoom change event? Probably a non-linear relationship you could discover a formula for... if you do let us know :)

dyp...@gmail.com

unread,
Nov 8, 2016, 2:12:33 PM11/8/16
to leafl...@googlegroups.com, gogli...@gmail.com
Hi K_man_au,
  based on Malcom input, yes I have found that plugin : http://bbecquet.github.io/Leaflet.PolylineOffset/examples/example_bus.html
I have to test yet hoaw it would perform with large set of lines and if it handle correctly line intersection, but the demo looks quite good to me!

Thank you all, if someone have another alternative option to study let me know too :-)




--

---
You received this message because you are subscribed to a topic in the Google Groups "Leaflet" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/leaflet-js/Du0rWyIx-No/unsubscribe.
To unsubscribe from this group and all its topics, send an email to leaflet-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

k_man_au

unread,
Nov 13, 2016, 5:06:21 PM11/13/16
to Leaflet, gogli...@gmail.com
I don't think that plugin answers your original question... it provides an offset in pixels, not the opportunity to specify width in meters

However, thanks Malcom for suggesting that plugin as I didn't know about it, but have a use for that very function.

To unsubscribe from this group and all its topics, send an email to leaflet-js+...@googlegroups.com.

Max Abou-Hagar

unread,
Dec 7, 2016, 12:32:10 PM12/7/16
to Leaflet, gogli...@gmail.com
Just because im randomly here and answered something similiar:
you will need an event listener on the map:
map.on('zoomend', function() { /* ... */  })

Inside it, you will need to adjust the width of you polyline (or path object in general), so

polyline.setStyle({weight: your_weight })

Now, the real problem comes with the meters. Im not sure how to solve this automatically, but the easierst way would be to simple have an array in the form of (zoomlevel -> line width), because zoom levels are integers. So you would only have to set this array up once (and just test what line width looks good) and use this array inside the zoomend handler so dynamically change the line width.

There might be a way for converting meter -> line width, but that might be pretty complicated i think (because of custom projections and stuff), while this is basically a "test once all relevant zoom levels and you are set" solution. Changing the linewidth in the dev console of your browser is easy, so this should be a pretty fast solution for your use case (i know it doesnt exactly solve the asked question, but maybe your problem)

Max
Reply all
Reply to author
Forward
0 new messages