salve ho il seguente problema......
var delay = 100;
if (GBrowserIsCompatible()) {
// ====== Create a Client Geocoder ======
var geo = new GClientGeocoder();
// ====== Array for decoding the failure codes ======
var reasons=[];
reasons[G_GEO_SUCCESS] = "Success";
reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value.";
reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address.";
reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons.";
reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed.";
reasons[403] = "Error 403: Probably an incorrect error caused by a bug in the handling of invalid JSON.";
// ====== Geocoding ======
function getAddress(search, next) {
geo.getLocations(search, function (result)
{
// If that was successful
if (result.Status.code == G_GEO_SUCCESS) {
// Lets assume that the first marker is the one we want
var p = result.Placemark[0].Point.coordinates;
var lat=p[1];
var lng=p[0];
// Display the results in XML format
var xml = ' <marker address="' + search + '" lat="' +lat+ '" lng="' +lng+ '"><br>';
document.getElementById("message").innerHTML += xml;
}
// ====== Decode the error status ======
else {
// === if we were sending the requests to fast, try this one again and increase the delay
if (result.Status.code == G_GEO_TOO_MANY_QUERIES) {
nextAddress--;
delay++;
} else {
var reason="Code "+result.Status.code;
if (reasons[result.Status.code]) {
reason = reasons[result.Status.code]
}
var xml = ' <marker address="' + search + '" error="' +reason+ '"><br>';
document.getElementById("message").innerHTML += xml;
}
}
next();
}
);
}
var addresses = [
"1060 West Addison Street, Chicago, IL",
"99, rue de Rivoli, Paris 75001",
"Oder, DE",
"Piazza della Scala, Milano 20121",
"London, UK",
"1600 Pennsylvania Avenue, Washington, DC",
"A totally bogus address"
];
// ======= Global variable to remind us what to do next
var nextAddress = 0;
// ======= Function to call the next Geocode operation when the reply comes back
function theNext() {
if (nextAddress < addresses.length) {
setTimeout('getAddress("'+addresses[nextAddress]+'",theNext)', delay);
nextAddress++;
} else {
document.getElementById("message").innerHTML += "</markers>";
}
}
// ======= Call that function for the first time =======
theNext();
}
// display a warning if the browser was not compatible
else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
// This Javascript is based on code provided by the
// Community Church Javascript Team
// http://www.bisphamchurch.org.uk/
// http://econym.org.uk/gmap/
//]]>
</script>
ho il problema di passaggio di valori nella variabile addresses in cui vorrei passare i luoghi che mi prendo da un database nel seguente modo:
// Read the data from example.xml
downloadUrl("database.php", function(doc) {
var xmlDoc = xmlParse(doc);
var markers = xmlDoc.documentElement.getElementsByTagName("marke r");
for (var i = 0; i < markers.length; i++) {
// obtain the attribues of each marker
var lat = parseFloat(markers[i].getAttribute("lat"));
var lng = parseFloat(markers[i].getAttribute("lng"));
var point = new google.maps.LatLng(lat,lng);
var name = markers[i].getAttribute("name");
var luogo = markers[i].getAttribute("luogo");
var indirizzo = markers[i].getAttribute("indirizzo");
var context = markers[i].getAttribute("context");
var data = markers[i].getAttribute("data");
//document.write(markers.length);
// create the marker
addresses = [luogo];
}
//document.getElementById("slide_bar").innerHTML = side_bar_html;
});
passando i valori con """"addresses = [luogo];""""" non mi funziona... come mai