Goal: Change website background to the nearest big city from the user's location. For example if the user is in New York City it should be the empire state building. If the user is in Paris it should be the eiffel tower.
So far I've been able to get the user's Latitude and Longitude using Geolocation.getCurrentPosition():
var options = {
enableHighAccuracy: true,
timeout: 5000,
maximumAge: 0
};
function success(pos) {
var crd = pos.coords;
console.log('Your current position is:');
console.log('Latitude : ' + crd.latitude);
console.log('Longitude: ' + crd.longitude);
console.log('More or less ' + crd.accuracy + ' meters.');
};
function error(err) {
console.warn('ERROR(' + err.code + '): ' + err.message);
};
navigator.geolocation.getCurrentPosition(success, error, options);
So let's say I'm at these coords (40.748163, -73.985946) which is right outside the Empire state building.
How would I set my code up to realize I'm in New York and set the background accordingly?
Thanks for any help!