diff --git a/amadeus_demo/amadeus_demo/settings.py b/amadeus_demo/amadeus_demo/settings.py index 41164c8..9860628 100644 --- a/amadeus_demo/amadeus_demo/settings.py +++ b/amadeus_demo/amadeus_demo/settings.py @@ -32,7 +32,7 @@ SECRET_KEY = ')-oaaz2gxfl6h7g$y6j5bw0519(a8^ue_^m=t5vnj)lbnp=cg&' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = os.environ.get('DEBUG_VALUE', True) +DEBUG = False HOST_URL = os.environ.get('HOST_URL', 'localhost') ALLOWED_HOSTS = ['localhost', '0.0.0.0', '127.0.0.1', HOST_URL] diff --git a/amadeus_demo/map/activity.py b/amadeus_demo/map/activity.py index 715ee9f..31b883a 100644 --- a/amadeus_demo/map/activity.py +++ b/amadeus_demo/map/activity.py @@ -11,8 +11,6 @@ def construct_activity(self): activity_returned['link'] = self.activity['bookingLink'] activity_returned['lat'] = self.activity['geoCode']['latitude'] activity_returned['lng'] = self.activity['geoCode']['longitude'] - activity_returned['price'] = self.activity['price']['amount'] - activity_returned['currency'] = self.activity['price']['currencyCode'] except (TypeError, AttributeError, KeyError): pass return activity_returned diff --git a/amadeus_demo/map/safety.py b/amadeus_demo/map/safety.py index 4904413..f96c272 100644 --- a/amadeus_demo/map/safety.py +++ b/amadeus_demo/map/safety.py @@ -3,11 +3,6 @@ def __init__(self, safety): self.safety = safety def construct_safety_scores(self): - overall = 1 - overall_icon = 1 - lgbtq = 1 - theft = 1 - medical = 1 try: overall = self.safety[0]['safetyScores']['overall'] overall_icon = self.classify_overall_safety_score(overall) diff --git a/amadeus_demo/map/templates/map/map.html b/amadeus_demo/map/templates/map/map.html index f6f82cc..8b9aa61 100644 --- a/amadeus_demo/map/templates/map/map.html +++ b/amadeus_demo/map/templates/map/map.html @@ -51,14 +51,18 @@

Find the perfect hotel for your journey!

// Add a 'tap' event listener to the marker group group.addEventListener('tap', function(evt) { + + var clickedCoord = map.screenToGeo(evt.currentPointer.viewportX, evt.currentPointer.viewportY); + var clickedCoordLat = clickedCoord.lat; + var clickedCoordLng = clickedCoord.lng // Use jQuery to make an AJAX request to a server-side Django view $(document).ready(function() { $.ajax({ method: 'POST', url: "{% url 'search_safety'%}", data: { - 'hotel_lat': hotel_lat, - 'hotel_lng': hotel_lng + 'hotel_lat': clickedCoordLat.toString(), + 'hotel_lng': clickedCoordLng.toString() }, success: function(data) { // Parse the JSON data returned from the server @@ -78,8 +82,8 @@

Find the perfect hotel for your journey!

}); }); // Add POI and activity markers - addPOIMarker(map, hotel_lat, hotel_lng); - addActivityMarker(map, hotel_lat, hotel_lng); + addPOIMarker(map, clickedCoordLat, clickedCoordLng); + addActivityMarker(map, clickedCoordLat, clickedCoordLng); }, false); // Parse the JSON data containing information about hotels @@ -104,14 +108,14 @@

Find the perfect hotel for your journey!

} } - function addPOIMarker(map) { + function addPOIMarker(map, clickedCoordLat, clickedCoordLng) { $(document).ready(function() { $.ajax({ method: 'POST', url: "{% url 'search_pois'%}", data: { - 'lat': hotel_lat, - 'lng': hotel_lng + 'lat': clickedCoordLat.toString(), + 'lng': clickedCoordLng.toString() }, success: function(data) { var pois = JSON.parse(data); @@ -122,7 +126,7 @@

Find the perfect hotel for your journey!

poi_lat = pois[i]['lat']; poi_lng = pois[i]['lng']; poi_category = pois[i]['category']; - if (poi_category == 'NIGHTLIFE') { + if (poi_category == 'NIGHTLIFE') { var customIcon = new H.map.Icon("{% static 'icons/nightlife.svg' %}", { size: { w: 32, @@ -183,14 +187,14 @@

Find the perfect hotel for your journey!

}); } - function addActivityMarker(map) { + function addActivityMarker(map, clickedCoordLat, clickedCoordLng) { $(document).ready(function() { $.ajax({ method: 'POST', url: "{% url 'search_activity'%}", data: { - 'lat': hotel_lat, - 'lng': hotel_lng + 'lat': clickedCoordLat.toString(), + 'lng': clickedCoordLng.toString() }, success: function(data) { var activities = JSON.parse(data); @@ -246,8 +250,8 @@

Find the perfect hotel for your journey!

var map = new H.Map(document.getElementById('map'), defaultLayers.vector.normal.map, { center: { - lat: 37.773972, - lng: -122.431297 + lat: 41.397158, + lng: 2.160873 }, zoom: 13, pixelRatio: window.devicePixelRatio || 1 diff --git a/amadeus_demo/map/views.py b/amadeus_demo/map/views.py index bf02e9d..a836336 100644 --- a/amadeus_demo/map/views.py +++ b/amadeus_demo/map/views.py @@ -12,9 +12,8 @@ amadeus = Client() - def hotels_map(request): - hotels = search_hotels('SFO') + hotels = search_hotels('BCN') HERE_API_KEY = os.environ.get('HERE_API_KEY') return render(request, 'map/map.html', {'hotels': json.dumps(hotels), 'here_api_key': HERE_API_KEY @@ -24,7 +23,7 @@ def hotels_map(request): def search_hotels(city_code): hotels = amadeus.reference_data.locations.hotels.by_city.get(cityCode=city_code) hotel_offers = [] - for hotel in hotels.data: + for hotel in hotels.data[:15]: list_offer = HotelList(hotel).construct_hotel_list() hotel_offers.append(list_offer) return hotel_offers