Skip to content

Commit

Permalink
explain code
Browse files Browse the repository at this point in the history
  • Loading branch information
minjikarin committed May 2, 2023
1 parent d1c5454 commit 01f1d0c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions amadeus_demo/map/templates/map/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ <h2>Find the perfect hotel for your journey!</h2>
}

function addInfoBubble(map) {
// Create a new marker group
var group = new H.map.Group();
// Add the marker group to the map
map.addObject(group);

// Add a 'tap' event listener to the marker group
group.addEventListener('tap', function(evt) {
// Use jQuery to make an AJAX request to a server-side Django view
$(document).ready(function() {
$.ajax({
method: 'POST',
Expand All @@ -56,24 +61,32 @@ <h2>Find the perfect hotel for your journey!</h2>
'hotel_lng': hotel_lng
},
success: function(data) {
// Parse the JSON data returned from the server
var safety = JSON.parse(data);
// Get the hotel name from the marker object's data property
var hotel_name = evt.target.getData();
// Create a new info bubble at the marker's location, with the hotel name and safety score as content
var bubble = new H.ui.InfoBubble(evt.target.getGeometry(), {
content: hotel_name + '<div>' + safety + '</div>'
});
// Add the info bubble to the map's user interface
ui.addBubble(bubble);
},
error: function(data) {
console.log("Safe Place API - Error");
}
});
});
// Add POI and activity markers
addPOIMarker(map, hotel_lat, hotel_lng);
addActivityMarker(map, hotel_lat, hotel_lng);
}, false);

// Parse the JSON data containing information about hotels
var hotels = JSON.parse("{{ hotels|escapejs }}");
var i;
for (i = 0; i < hotels.length; i++) {
// Create marker objects for each hotel and add them to the marker group
try {
hotel_name = hotels[i]['name'];
hotel_lat = hotels[i]['latitude'];
Expand Down

0 comments on commit 01f1d0c

Please sign in to comment.