1
1
import folium
2
2
import streamlit as st
3
- from osmnx import distance , geocoder , graph_from_bbox , routing
3
+ from osmnx import distance , geocoder , graph_from_bbox , routing , features_from_bbox
4
4
from streamlit_folium import st_folium
5
5
6
6
bounding_box = {'min_lat' : 49.174522 , 'max_lat' : 50.526524 , 'min_lon' : 19.076385 , 'max_lon' : 21.432953 }
@@ -31,27 +31,24 @@ def plot_route(map_, route_pts):
31
31
def run_server ():
32
32
st .title ('Rowerem przez Małopolskę' )
33
33
34
+ localities = tuple (features_from_bbox (
35
+ bbox = (bounding_box ['max_lat' ], bounding_box ['min_lat' ], bounding_box ['min_lon' ], bounding_box ['max_lon' ]),
36
+ tags = {"place" : ["town" , "vilage" ]})['name' ].values
37
+ )
38
+
34
39
cont1 = st .container ()
35
40
36
41
with cont1 :
37
42
col1 , col2 = st .columns (2 )
38
43
39
44
with col1 :
40
- st .text_input ( ' Skąd' )
45
+ origin = st .selectbox ( " Skąd" , localities )
41
46
42
47
with col2 :
43
- st .text_input ( ' Dokąd' )
48
+ destination = st .selectbox ( " Dokąd" , localities )
44
49
45
50
cont2 = st .container ()
46
51
47
- map_bound_coordinates = [
48
- (50.526524 , 19.076385 ),
49
- (50.526524 , 21.432953 ),
50
- (49.174522 , 21.432953 ),
51
- (49.174522 , 19.076385 ),
52
- (50.526524 , 19.076385 ),
53
- ]
54
-
55
52
# center on Liberty Bell, add marker
56
53
map_ = folium .Map (
57
54
max_bounds = True ,
@@ -66,9 +63,9 @@ def run_server():
66
63
marker = folium .Marker ([50.049683 , 19.944544 ], popup = 'Kraków' , tooltip = 'Kraków' )
67
64
map_ .add_child (marker )
68
65
69
- map_bounds = folium . PolyLine ( locations = map_bound_coordinates , weight = 5 )
66
+ route_pts = get_route_points ( origin , destination )
70
67
71
- map_ . add_child ( map_bounds )
68
+ plot_route ( map_ , route_pts )
72
69
73
70
with cont2 :
74
71
# call to render Folium map in Streamlit
0 commit comments