salve ragazzi ho il seguente codice:
codice:
<html>
<head>
<script type="text/javascript" src="http://www.google.com/jsapi?key=INSERIRE_QUI_LA_API_KEY"></script>
<script>
google.load("maps", "2");
function initialize() {
//Valori de default
var zoom = 3;
var latlng = new google.maps.LatLng(37.4419, -100.1419);
var location = "Sto visualizzando la posizione di default";
//Se ClientLocation è valorizzato allora prendo i valori della posizione attuale
if (google.loader.ClientLocation) {
zoom = 13;
latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
location = "Visualizzo la posizione trovata in base all'IP: " + getFormattedLocation() + ". Lat: "+google.loader.ClientLocation.latitude+", Long: "+google.loader.ClientLocation.longitude;
}
document.getElementById("location").innerHTML = location;
var map = new google.maps.Map2(document.getElementById('map'));
map.setCenter(latlng, zoom);
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
//Aggiungo segnaposto
map.addOverlay(new GMarker(latlng));
}
//Posizione trovata scritta con città e stato
function getFormattedLocation() {
if (google.loader.ClientLocation.address.country_code == "US" &&
google.loader.ClientLocation.address.region) {
return google.loader.ClientLocation.address.city + ", "
+ google.loader.ClientLocation.address.region.toUpperCase();
} else {
return google.loader.ClientLocation.address.city + ", "
+ google.loader.ClientLocation.address.country_code;
}
}
google.setOnLoadCallback(initialize);
</script>
</head>
<body>
<div style="width:500;height:300" id="map"></div>
<div id="location"></div>
</body>
</html>
come faccio a passare a una variabile ip il seguente valore?
location = "Visualizzo la posizione trovata in base all'IP: " + getFormattedLocation() + ". Lat: "+google.loader.ClientLocation.latitude+", Long: "+google.loader.ClientLocation.longitude;
graZIE