Just Fore Fun Golf
Acquiring GPS...
function updateDistances(userLocation) {
targets.forEach(t => {
const targetPos = L.latLng(t.lat, t.lon);
const distYards = (userLocation.distanceTo(targetPos) * 1.09361).toFixed(0);
// Add Flag Marker
L.marker(targetPos, {
icon: L.icon({ iconUrl: t.icon, iconSize: [26, 26], iconAnchor: [13, 13] })
}).addTo(map).bindPopup(`${t.name}
${distYards} yards`);
// Add Yardage Label
L.marker(targetPos, {
icon: L.divIcon({
className: 'dummy',
html: `${distYards}
`,
iconAnchor: [15, -10]
})
}).addTo(map);
});
}
map.on('locationerror', function() { alert("Please enable Location Services to see yardages."); });
// 5. Initial Load
findMe();
// 6. UI Handlers
document.getElementById('refreshButton').onclick = () => window.location.reload();
// Show popup once per day
const today = new Date().toDateString();
if (localStorage.getItem('golf_popup') !== today) {
document.getElementById('popupContainer').style.display = 'block';
}
document.getElementById('closePopup').onclick = () => {
document.getElementById('popupContainer').style.display = 'none';
localStorage.setItem('golf_popup', today);
};