Created
March 15, 2025 12:37
-
-
Save thinkphp/a7dde48723b47f649da058a7211b7c87 to your computer and use it in GitHub Desktop.
display_places
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (let i = 0; i < places.length; ++i) { | |
const place = places[i]; | |
const address = place.location?.formatted_address || place.location?.address || 'Address not available'; | |
const categories = place.categories?.map(cat => cat.name).join(', ') || 'Category not available'; | |
const lat = place.geocodes?.main?.latitude; | |
const lng = place.geocodes?.main?.longitude; | |
output += ` | |
<div class="place-card" data-lat="${lat}" data-lng="${lng}" data-name="${place.name}"> | |
<div class="place-image"> | |
${place.categories && place.categories[0]?.icon ? | |
`<img src="${place.categories[0].icon.prefix}88${place.categories[0].icon.suffix}" alt="${categories}">` : | |
'No Image Available' | |
} | |
</div> | |
<div class="place-details"> | |
<div class="place-name">${place.name}</div> | |
<div class="place-category">${categories}</div> | |
<div class="place-address">${address}</div> | |
<div class="place-buttons"> | |
<button class="view-map">View on Map</button> | |
</div> | |
</div> | |
</div> | |
`; | |
} | |
resultsContainer.innerHTML = output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment