I have the following code to draw circles at different locations, using Folium:
import folium
data = [
{"lat": 37.7749, "lon": -122.4194, "value": 10, "name": "Location A"},
{"lat": 34.0522, "lon": -118.2437, "value": 20, "name": "Location B"},
{"lat": 40.7128, "lon": -74.0060, "value": 15, "name": "Location C"},
{"lat": 41.8781, "lon": -87.6298, "value": 5, "name": "Location D"}
]
# Initialize the map centered at an average location
m = folium.Map(location=[39.8283, -98.5795], zoom_start=4)
# Add circles to the map with custom attribute for value
for item in data:
circle = folium.Circle(
location=[item["lat"], item["lon"]],
radius=100000, # Radius in meters
color='blue',
fill=True,
fill_color='blue',
fill_opacity=0.6,
popup=f"{item['name']}: {item['value']}",
data_value=item["value"]
)
circle.add_to(m)
m.save('map.html')
I’d like to do some kind of filter by input value, meaning that, for example, entering in a text box number 20 would make markers with lower value than 20 to be hidden. I’ve seen in Folium things like TreeLayerControl
, which is very similar to my goal, but I can’t group my markers, since I expect to plot many circles and it would be useless from a UX point of view