// Fetch data from Google Sheets
fetch('/?show_driver_map') // Calls the PHP function
.then(response => response.json())
.then(data => {
data.table.rows.forEach(row => {
let address = row.c[4].v; // Column E: Full Address
geocoder.geocode({ 'address': address }, function(results, status) {
if (status === 'OK') {
new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: address
});
} else {
console.error("Geocoding failed: " + status);
}
});
});
})
.catch(error => console.error("Error fetching data:", error));
}
Skip to content