Leaflet.hotline icon indicating copy to clipboard operation
Leaflet.hotline copied to clipboard

multiple map support

Open cfarnleitner opened this issue 6 years ago • 4 comments

When dealing with multiple maps, the hotline canvas will be added to the very last map only. I've put a simple demo of that in a fiddle: https://jsfiddle.net/chris_farnleitner/t45jh23a/7/ (when using the zoom controls you can see that both hotlines are actually drawn on the same map).

The very same concept does work when using polyline instead of hotline - any ideas how to overcome this issue?

In general I'm wondering, how a canvas is added to a map - i.e. there is a var canvas = document.createElement("canvas") [...] and this._canvas = canvas = typeof canvas === "string" ? document.getElementById(canvas) : canvas;, but this somehow does not add up to me (especially, because 'canvas' is always an object (without an particular id) and so 'typeof canvas === "string"' does also never becomes true).

cfarnleitner avatar Nov 16 '18 12:11 cfarnleitner

Sorry, I'm no longer actively maintaining the plugin. Maybe it's fixed in one of the forks or you could ask for help in the general Leaflet community.

klaftertief avatar Nov 16 '18 22:11 klaftertief

Hi @cfarnleitner

Did you found any solution ? I have the same problem.

Thanks!

amadvance avatar Dec 17 '18 22:12 amadvance

As far as I get it: There's a (somehow fixed) renderer defined in the default options that will always use the same canvas (as renderer()) is only called once). But you can define your own renderer in the options provided to your L.hotline(latLngs, options) call. There we simply call the renderer() method each time we want to add a hotline to a (new) map:

L.hotline(latLngs, {
	renderer: L.Hotline.renderer()
	// ...
})

laufhannes avatar Sep 17 '20 11:09 laufhannes

Thanks @laufhannes !

Now it works!

amadvance avatar Oct 03 '20 15:10 amadvance