Hai bisogno di fare reverse geocoding per ottenere quelle informazioni. E.g. guarda sotto.
In questo esempio sto usando la API di google maps con jQuery per ottenere il JSON necessario. Nell'esempio estrae l'indirizzo completo ma ovviamente puoi estrarre solo quello che ti server tipo la citta' - il formato dati e' questo: http://maps.googleapis.com/maps/api/...2&sensor=false
codice:
function showPosition(p)
{
var latitude = parseFloat( p.coords.latitude );
var longitude = parseFloat( p.coords.longitude );
document.getElementById('current').innerHTML="latitude=" + latitude + " longitude=" + longitude;
$.getJSON("http://maps.googleapis.com/maps/api/geocode/json?latlng=" + latitude +"," + longitude + "&sensor=false", function(data) {
var pos=new google.maps.LatLng( latitude , longitude);
map.setCenter(pos);
map.setZoom(14);
var infowindow = new google.maps.InfoWindow({
content: "<strong>" + data.results[0].formatted_address + "</strong>"
});
var marker = new google.maps.Marker({
position: pos,
map: map,
title:"Tu sei qui"
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker);
});
});
}