'How to create slider for Folium Circle Map
I have a dataframe called df as below. It contains time series of the number of car passed (n) from Monday to Wednesday for two different locations, distinguished by the coordinate.
| day | lat | lng | 3pm | 6pm | 9pm | |
|---|---|---|---|---|---|---|
| 0 | Monday | 3.1857 | 101.3153 | 24 | 50 | 35 |
| 1 | Tuesday | 3.1857 | 101.3153 | 13 | 36 | 49 |
| 2 | Wednesday | 3.1857 | 101.3153 | 29 | 63 | 58 |
| 3 | Monday | 3.1867 | 101.3145 | 7 | 15 | 32 |
| 4 | Tuesday | 3.1867 | 101.3145 | 5 | 21 | 18 |
| 5 | Wednesday | 3.1867 | 101.3145 | 19 | 24 | 42 |
And using folium.Circle() I managed to visualize how many car passed on 3pm on Monday:
df_day = df.loc[df['name'] == 'Monday'].reset_index(drop=True)
m = folium.Map(location=[3.185725088374699, 101.31522342062456], tiles="OpenStreetMap", zoom_start=15)
for j in range(0,len(df)):
n = df_day['3pm'].iloc[j]
folium.Circle(
location = [df['lat'][j], df['lng'][j]],
tooltip = txt,
popup = df['Addr1'][j],
radius = float(n),
color = 'black',
fill = True,
fill_color = blue
).add_to(m)
m
So what I am trying to achieve is visualizing the map using sliders so I can choose to display the number of car at specific time(3pm/6pm/9pm) and day(Monday/Tuesday/Wednesday).
The slider looks something like this: https://media.geeksforgeeks.org/wp-content/uploads/20220216223051/ezgifcomgifmaker.gif
But instead of date, I want to put the slider to choose from Monday and Wednesday, and another slider to choose time from 3pm to 9pm.
I am not really sure how to do that so any help is greatly appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
