Come non detto: avevo fatto un piccolo errore. Posto la soluzione alla richiesta fatta sopra:
Provatela con Chrome 5, Safari, Opera 10.5 e ditemi se funziona bene. Qualcuno sa come faccio a farla funzionare con Explorer?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento senza titolo</title>
<script type="text/javascript" src="mootools-core-1.3.1-full-compat-yc.js"></script>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var geocoder;
window.addEvent("domready", function()
{
geocoder = new google.maps.Geocoder();
});//chiude AddEvent
function codeLatLng(position) {
//var input = document.getElementById("latlng").value;
//var latlngStr = input.split(",",2);
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(
function (position) {
GeocodeReverse(position);
},
// next function is the error callback
function (error)
{
switch(error.code)
{
case error.TIMEOUT:
alert ('Timeout');
break;
case error.POSITION_UNAVAILABLE:
alert ('Position unavailable');
break;
case error.PERMISSION_DENIED:
alert ('Permission denied');
break;
case error.UNKNOWN_ERROR:
alert ('Unknown error');
break;
}
}
);//chiude geolocation.getCurrentPosition
}//chiude if navigator.geolocation
}
function GeocodeReverse(position)
{
var lat = position.coords.latitude//parseFloat(position.coords.latitude);
var lng = position.coords.longitude//parseFloat(position.coords.longitude);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
alert(results[1].formatted_address);
} else {
alert("No results found");
}
} else {
alert("Geocoder failed due to: " + status);
}
});
}
</script>
</head>
<body>
<div>
<input type="button" value="Reverse Geocode" onclick="codeLatLng()">
</div>
</body>
</html>

Rispondi quotando