python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.94k stars 2.23k forks source link

Smooth markers refresh for navigation support #1890

Open Alessandro-Minerba opened 9 months ago

Alessandro-Minerba commented 9 months ago

Hi, I'm quite new to the folium library and I'm implementing a map on a PyQt6 application for real time navigation support. First of all great job, it looks really good for a fresh new developer. Regarding my issue, I made some researches and I understood there's no way to have a smooth way to update markers position without reloading the entire map, which creates a bad looking flashing during the route. There's any chance in the future to have this feature available in the library? Thank you in advance.

hansthen commented 7 months ago

You could have a look at the Realtime plugin. This plugin allows you to update the map without reloading it. For this to work however, you need to also develop an HTTP server (or something similar, like Flask, Django or FastAPI) that will calculate the current map state and return it as JSON.

from flask import Flask

app = Flask(__name__)

@app.route("/navigate")
def navigate():
    return calculate_state()

# and from some other part of your code in another thread
app.run(host='0.0.0.0', port=5000, debug=True)