Hey,
I am using the HTML5 Geolocation API to find the longitude and the latitude from the users of my site. This works, but now I would like te show on the screen "You cuurently are in ...". So I need to convert these coordinates I get from the Geolocation API to a place name.
I tried a bit with Google Maps API, but I Didn't get it working.
Does anyone knows how to do this.
This is my code so far
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=true&amp;key=ABQIAAAA55ubMQxcIybj35yHYV_iGRTrPfqOlZVmBxwB40M45alaTGbn0hTaoOvTqt2CB0iR6c1SkxYmRqRvHA" type="text/javascript"></script>
<script type="text/javascript">
// When loaded go to:
initiate_geolocation();
function initiate_geolocation() {
navigator.geolocation.getCurrentPosition(handle_geolocation_query,handle_errors);
}
function handle_errors(error)
{
switch(error.code)
{
case error.PERMISSION_DENIED: document.getElementById("geo").innerHTML = "User did not share geolocation data";
break;
case error.POSITION_UNAVAILABLE: document.getElementById("geo").innerHTML = "Could not detect current position";
break;
case error.TIMEOUT: document.getElementById("geo").innerHTML = "retrieving geolocation position timed out";
break;
default: document.getElementById("geo").innerHTML = "unknown geolocation error";
break;
}
}
function handle_geolocation_query(position){
document.getElementById("geo").innerHTML = "Your coordinates are " + position.coords.latitude + ", " + position.coords.longitude;
var geoCoder = new GClientGeocoder();
geoCoder.getLocations(new GLatLng(position.coords.latitude, position.coords.longituder, true), getPositionName());
}
function getPositionName(response)
{
//
// Here I don't know what to do
//
}
</script>
Thanks,
Vincent