From f8aedc5899c9ab47fd66334573291eacb2daed6b Mon Sep 17 00:00:00 2001 From: MarekWo Date: Tue, 30 Dec 2025 12:43:50 +0100 Subject: [PATCH] feat(contacts): Add Map button to open GPS location in Google Maps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Map button between Copy Key and Delete buttons on existing contacts cards. Button appears only when contact has GPS coordinates (adv_lat/adv_lon != 0). Opens contact location in Google Maps in new tab. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- app/static/js/contacts.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/static/js/contacts.js b/app/static/js/contacts.js index e2b1933..c4aa776 100644 --- a/app/static/js/contacts.js +++ b/app/static/js/contacts.js @@ -974,13 +974,23 @@ function createExistingContactCard(contact, index) { copyBtn.innerHTML = ' Copy Key'; copyBtn.onclick = () => copyContactKey(contact.public_key_prefix, copyBtn); + actionsDiv.appendChild(copyBtn); + + // Map button (only if GPS coordinates available) + if (contact.adv_lat && contact.adv_lon && (contact.adv_lat !== 0 || contact.adv_lon !== 0)) { + const mapBtn = document.createElement('button'); + mapBtn.className = 'btn btn-sm btn-outline-primary'; + mapBtn.innerHTML = ' Map'; + mapBtn.onclick = () => openGoogleMaps(contact.adv_lat, contact.adv_lon); + actionsDiv.appendChild(mapBtn); + } + // Delete button const deleteBtn = document.createElement('button'); deleteBtn.className = 'btn btn-sm btn-outline-danger'; deleteBtn.innerHTML = ' Delete'; deleteBtn.onclick = () => showDeleteModal(contact); - actionsDiv.appendChild(copyBtn); actionsDiv.appendChild(deleteBtn); // Assemble card @@ -1014,6 +1024,14 @@ function copyContactKey(publicKeyPrefix, buttonEl) { }); } +function openGoogleMaps(lat, lon) { + // Create Google Maps URL with coordinates + const mapsUrl = `https://www.google.com/maps?q=${lat},${lon}`; + + // Open in new tab + window.open(mapsUrl, '_blank'); +} + function showDeleteModal(contact) { contactToDelete = contact;