bootleaf icon indicating copy to clipboard operation
bootleaf copied to clipboard

Recreation of the layers without page refresh

Open JimBratsos opened this issue 3 years ago • 2 comments

Good afternoon,

I have stumbled across an issue during the development of mine. I am calling a GeoJSON layer using the URL from my server, and I would like that it gets dynamically re-created every few seconds on the map. This layer represents a route, kind of like a GPS. Is there a function already implemented that allows me to do that, or I will need to make some additions to the app.js?

Thank you in advance

JimBratsos avatar Apr 13 '21 18:04 JimBratsos

Hi Jim,

I don't think I've ever tried this, but a search for "leaflet auto refresh" brings up this post, which has some suggestions:

https://stackoverflow.com/questions/18515230/javascript-map-in-leaflet-how-to-refresh

I also found https://github.com/calvinmetcalf/leaflet-ajax which may be a good starting point?

Let me know if any of them work - and feel free to submit a Pull Request if you manage to get it working in Bootleaf!

Cheers, Steve

slead avatar Apr 16 '21 07:04 slead

Hey,

I figured out that the issue that I had was due to the usage of leaflet's ToC. Using your ajax call I can recreate the layer, but I have no clue as to how to update it and have leaflet's ToC to choose the layer of display at the same time. Do you have any ideas?

Thanks for your answer!

JimBratsos avatar Apr 19 '21 18:04 JimBratsos