问题
I have the following code to display a geojson file on a Folium map in python.
import folium
import json
with open("roadway.geojson") as f:
data = json.load(f)
m = folium.Map(location=[39.945559, -86.503854], zoom_start=10)
folium.GeoJson(
data= data,
name="Network",
show=False,
style_function=lambda x: {"weight":2, 'color':'black','fillColor': 'lightblue',},
highlight_function=lambda x: {'weight':3, 'color':'black'},
smooth_factor=2.0,
tooltip=folium.features.GeoJsonTooltip(
fields=['DLY_TOT_VO'],
aliases=['Daily Volume:'],
labels=True,
sticky=True,
toLocaleString=True
)
).add_to(m)
m
What I get from this is a map with the geojson overlay that has lines displayed in black and then if I hover over each line, I can see the value read from DLY_TOT_VO
in the geojson file as shown below
I am including this map in my application using PyQt5. What I'd like to do is to actually be able to click on a line and save the value of DLY_TOT_VO
for that line in a variable. I will then do some further calculations with that value.
Is there a way I can do that? Maybe a click event listener or something like that? Also, roadway.geojson can be downloaded from here
来源:https://stackoverflow.com/questions/64576899/click-on-a-geojson-layer-feature-shown-on-python-folium-map