Update location service using Google Maps API

This commit is contained in:
Nguyen Ngo
2025-08-25 11:30:39 -04:00
parent 7ce5bea59e
commit ba59368949
4 changed files with 499 additions and 67 deletions
+9 -4
View File
@@ -570,12 +570,17 @@ function handleLocationError(error) {
}
function reverseGeocode(lat, lng) {
console.log(`🌍 Starting reverse geocoding for: ${lat}, ${lng}`);
console.log(`🌍 Reverse geocoding for: ${lat}, ${lng}`);
// Using Nominatim (OpenStreetMap) reverse geocoding service
const url = `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=json&addressdetails=1&zoom=18`;
// The server will use Google Maps API first, then fall back to OpenStreetMap
// This provides better accuracy and address formatting
const url = '/api/reverse-geocode'; // You may want to create this endpoint
// For now, using direct OpenStreetMap as fallback
// In production, this should go through your server API
const osmUrl = `https://nominatim.openstreetmap.org/reverse?lat=${lat}&lon=${lng}&format=json&addressdetails=1&zoom=18`;
fetch(url, {
fetch(osmUrl, {
method: "GET",
headers: {
"User-Agent": "QR-Attendance-System/1.0",