leaflet-corridor icon indicating copy to clipboard operation
leaflet-corridor copied to clipboard

How to handle changing the corridor dynamically?

Open mickeyjohn opened this issue 7 years ago • 5 comments

Hi, It is a good idea to make polyline rendered weight in meters. Can anyone give a pointer on how to handle the case of corridor value change dynamically? I am new to leaflet.

Thanks alot, John

mickeyjohn avatar Feb 01 '18 21:02 mickeyjohn

What's the exact scenario?

mikhailshilkov avatar Feb 01 '18 22:02 mikhailshilkov

I am using it with leaflet Draw to draw polylines with (corridor/weight) in meters. After a change in corridor, I update its options.corridor = then call layer.updateCallback(); but it does not work until any zoomming.

mickeyjohn avatar Feb 01 '18 22:02 mickeyjohn

I think you need to pass map as this to updateCallback:

line.corridor += 1000;
line.updateCallback.call(map);

seems to work.

mikhailshilkov avatar Feb 01 '18 22:02 mikhailshilkov

Hi mikhailshilkov,

Wow, It works. Great thanks. I think It would look cleaner if it requires only one method call like layer.refresh();.

Have a great weekend. John.

mickeyjohn avatar Feb 02 '18 13:02 mickeyjohn

Sure, I haven't considered that scenario in the initial implementation. Feel free to send a PR.

mikhailshilkov avatar Feb 02 '18 13:02 mikhailshilkov