fschwartzer commited on
Commit
be17c91
1 Parent(s): 384183a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -86,7 +86,22 @@ with st.sidebar:
86
  radius_visible = False # Hide radius slider for random coordinates
87
 
88
  # Slider for setting the zoom level
89
- zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  # Conditionally render the radius slider
92
  if radius_visible:
 
86
  radius_visible = False # Hide radius slider for random coordinates
87
 
88
  # Slider for setting the zoom level
89
+ if selected_coords == 'Custom':
90
+ zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level)
91
+ else:
92
+ # Find the maximum distance between coordinates for the entire dataset
93
+ max_distance_all = 0
94
+ for index, row in data.iterrows():
95
+ distance_all = calculate_distance(row['latitude'], row['longitude'], data['latitude'].mean(), data['longitude'].mean())
96
+ if distance_all > max_distance_all:
97
+ max_distance_all = distance_all
98
+
99
+ # Calculate a zoom level based on the maximum distance of the entire dataset
100
+ zoom_level_all = round(15 - np.log10(max_distance_all))
101
+
102
+ # Slider for setting the zoom level based on the entire dataset
103
+ zoom_level = st.slider('Nível de zoom', min_value=1, max_value=15, value=zoom_level_all)
104
+
105
 
106
  # Conditionally render the radius slider
107
  if radius_visible: