Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple map support #20

Open
cfarnleitner opened this issue Nov 16, 2018 · 4 comments
Open

multiple map support #20

cfarnleitner opened this issue Nov 16, 2018 · 4 comments

Comments

@cfarnleitner
Copy link

cfarnleitner commented Nov 16, 2018

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).

@klaftertief
Copy link
Contributor

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.

@amadvance
Copy link

Hi @cfarnleitner

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

Thanks!

@laufhannes
Copy link

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()
	// ...
})

@amadvance
Copy link

Thanks @laufhannes !

Now it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants