Displaying geojson data sent by flask server in folium map

Ted James
2 min readApr 22, 2024

I am currently working on a teaching tool for aviation and I need to display realtime data in a 1s interval in a GUI on a map. I decided to use PySide6 and folium for this. The realtime data is simple position data consisting of latitude and longitude. To my understanding it is not possible to insert changing values from the simulation right into the folium Realtime function, but to fetch it from an endpoint. The exampledata provided in the documentation works and displays data as expected in the map from this source: https://raw.githubusercontent.com/python-visualization/folium-example-data/main/subway_stations.geojson I set up a flask_server to send randomized data as a proof of concept, but the data doesn’t show in the map. Down below the function, which contains the Realtime access

def plot_flight_path(self):
# Create a Folium map centered at the start of the path
self.m = folium.Map(location=[self.start[0], self.start[1]], zoom_start=5)
# Add the satellite imagery layer from Google Maps API
folium.TileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', attr='Google Satellite',
name='Google Satellite', overlay=True).add_to(self.m)

# Plot the path as a Polyline on the map
folium.PolyLine(locations=self.route, color='blue', weight=5).add_to(self.m)
rt = folium.plugins.Realtime(
"http://127.0.0.1:5000/random_position.geojson",
get_feature_id=JsCode("(f) => { return f.properties.objectid; }"),
interval=10000,
)
#rt =

--

--

Ted James

The world is my office, and every destination is my inspiration