diff --git a/apis/interactive_maps.py b/apis/interactive_maps.py index b4684cc..3fd51ce 100644 --- a/apis/interactive_maps.py +++ b/apis/interactive_maps.py @@ -5,26 +5,48 @@ 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): + def travel_history_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') + icon=folium.Icon(color="red") ).add_to(local_m) - local_m.save(f'static/swissmap_customer={customer_id}.html') - return(f'static/swissmap_customer={customer_id}.html') + local_m.save(f'static/travelhistorymap_customer{customer_id}.html') + return(f'static/travelhistorymap_customer{customer_id}.html') -# Working example -""" + # own_location and destination are tuples in form (coordinates, place) + def destination_map(self, customer_id, own_location, destination): + local_m = self.m + folium.Marker( + location=destination[1], # coordinates for the marker + popup=destination[0], # pop-up label for the marker + icon=folium.Icon(color="green") + ).add_to(local_m) + folium.Marker( + location=destination[1], # coordinates for the marker + popup=destination[0], # pop-up label for the marker + icon=folium.Icon(color="red") + ).add_to(local_m) + local_m.save(f'static/destinationmap_customer={customer_id}_destination{destination[0]}.html') + return(f'static/destinationmap_customer={customer_id}_destination{destination[0]}.html') + + + +# Working examples for travel history map and destination map + # Hard coded location list location_list = [('Center of Switzerland' , [46.8132, 8.2242]), ('Zermatt', [46.11654, 7.445683])] customer_id = 235 -cmap = SwissMap() -cmap.customer_map(customer_id, location_list) -""" +# Travel history +thmap = SwissMap() +thmap.travel_history_map(customer_id, location_list) + +# Destination +dmap = SwissMap() +dmap.destination_map(customer_id, location_list[0], location_list[1]) diff --git a/static/destinationmap_customer=235_destinationZermatt.html b/static/destinationmap_customer=235_destinationZermatt.html new file mode 100644 index 0000000..78e33d8 --- /dev/null +++ b/static/destinationmap_customer=235_destinationZermatt.html @@ -0,0 +1,113 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/static/swissmap_customer=235.html b/static/swissmap_customer=235.html index 4f47aa0..aad1b57 100644 --- a/static/swissmap_customer=235.html +++ b/static/swissmap_customer=235.html @@ -23,7 +23,7 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file