Skip to content

Commit

Permalink
Adding battery percentage to drone name and display the image tooltip…
Browse files Browse the repository at this point in the history
… when hovering over either div.
  • Loading branch information
teiszler committed Oct 23, 2024
1 parent b236fc4 commit 34ccb30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cnc/streamlit/overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ def draw_map():
if time.time() - last_update < st.session_state.inactivity_time * 60: # minutes -> seconds
coords = []
i = 0
drone_name = k.split(".")[-1]
for index, row in df.iterrows():
if i % 10 == 0:
coords.append([row["latitude"], row["longitude"]])
if i == 0:
text = folium.DivIcon(
icon_size="null", #set the size to null so that it expands to the length of the string inside in the div
icon_anchor=(-20, 30),
html=f'<div style="color:white;font-size: 12pt;font-weight: bold;background-color:{COLORS[marker_color]};">{k.split(".")[-1]}</div>',
html=f'<div style="color:white;font-size: 12pt;font-weight: bold;background-color:{COLORS[marker_color]};">{drone_name}&nbsp;({int(row["battery"])}%)</div>',

)
plane = folium.Icon(
Expand All @@ -137,15 +138,14 @@ def draw_map():
prefix="glyphicon",
angle=int(row["bearing"]),
)
html = f'<img src="http://{st.secrets.webserver}/raw/{k.split(".")[-1]}/latest.jpg" height="250px" width="250px"/>'
html = f'<img src="http://{st.secrets.webserver}/raw/{drone_name}/latest.jpg" height="250px" width="250px"/>'

fg.add_child(
folium.Marker(
location=[
row["latitude"],
row["longitude"],
],
# tooltip=k.split(".")[-1],
tooltip=html,
icon=plane,
)
Expand All @@ -157,6 +157,7 @@ def draw_map():
row["latitude"],
row["longitude"],
],
tooltip=html,
icon=text,
)
)
Expand Down

0 comments on commit 34ccb30

Please sign in to comment.