Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Last active March 15, 2025 15:06
Show Gist options
  • Save thinkphp/1e45cd73e8f7dbeb62aa0793a86c61a1 to your computer and use it in GitHub Desktop.
Save thinkphp/1e45cd73e8f7dbeb62aa0793a86c61a1 to your computer and use it in GitHub Desktop.
view-on-map
let buttons = document.querySelectorAll('.view-map');
for (let i = 0; i < buttons.length; i++) {
buttons[i].addEventListener('click', function() {
const card = this.closest('.place-card');
const lat = card.dataset.lat;
const lng = card.dataset.lng;
const name = card.dataset.name;
if (lat && lng) {
showMap(lat, lng, name);
} else {
alert('Map coordinates not available for this location');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment