diff --git a/apis/interactive_maps.py b/apis/interactive_maps.py index 972e8d2..b4684cc 100644 --- a/apis/interactive_maps.py +++ b/apis/interactive_maps.py @@ -1,26 +1,30 @@ import folium -from folium import plugins -import json - -#OpenStreetMap -m = folium.Map(location=[46.8132, 8.2242], tiles='CartoDB', zoom_start=7.6, min_zoom = 6, max_zoom = 12) +class SwissMap: + def __init__(self) -> None: + self.m = folium.Map(location=[46.8132, 8.2242], tiles='OpenStreetMap', zoom_start=7.6, min_zoom = 6, max_zoom = 12) + + + # Returns travel map of customer as html string + def customer_map(self, customer_id, location_list): + local_m = self.m + for place, coordinates in location_list: + folium.Marker( + location=coordinates, # coordinates for the marker + popup=place, # pop-up label for the marker + icon=folium.Icon(color="red")#, icon_color = 'red', icon="fa-map-marker-alt", prefix='fa') + ).add_to(local_m) + local_m.save(f'static/swissmap_customer={customer_id}.html') + return(f'static/swissmap_customer={customer_id}.html') + + +# Working example +""" # Hard coded location list location_list = [('Center of Switzerland' , [46.8132, 8.2242]), ('Zermatt', [46.11654, 7.445683])] +customer_id = 235 -for place, coordinates in location_list: - folium.Marker( - location=coordinates, # coordinates for the marker - popup=place, # pop-up label for the marker - icon=folium.Icon(color="red")#, icon_color = 'red', icon="fa-map-marker-alt", prefix='fa') - ).add_to(m) - - -m.save('foliummap.html') - -html_string = m.get_root().render() -print(html_string) -print('finish') - -return html_string \ No newline at end of file +cmap = SwissMap() +cmap.customer_map(customer_id, location_list) +""" diff --git a/apis/sbb.py b/apis/sbb.py index bb060f0..78db63b 100644 --- a/apis/sbb.py +++ b/apis/sbb.py @@ -36,7 +36,7 @@ header_dict = {'api_key' : '814d86a3ffc49c350bb7dcc48cac69b3'} response = requests.get('https://journey-maps.api.sbb.ch:443', headers=header_dict) print(response.text) -""" + """ diff --git a/static/swissmap_customer=235.html b/static/swissmap_customer=235.html new file mode 100644 index 0000000..4f47aa0 --- /dev/null +++ b/static/swissmap_customer=235.html @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + \ No newline at end of file