problema di passaggio parametri

serino

Nuovo Utente
3 Ott 2013
2
0
0
Salve,

ho il seguente codice che mi permette di fare la conversione ; da indirizzi a coordinate.
Gli indirizzi sono scritti nella variabile:
HTML:
var addresses=["Roma", "Napoli", "Salerno", " Napoli via toledo"];

HTML:
 <script type="text/javascript">
    //<![CDATA[
    

    // delay between geocode requests - at the time of writing, 100 miliseconds seems to work well
    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 = '&nbsp;&nbsp;&lt;marker address="' + search + '" lat="' +lat+ '" lng="' +lng+ '"&gt;<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 = '&nbsp;&nbsp;&lt;marker address="' + search + '" error="' +reason+ '"&gt;<br>';
                document.getElementById("message").innerHTML += xml;
              }   
            }
            next();
          }
        );
      }



      // ======= An array of locations that we want to Geocode ========
     
 

var addresses=["Roma", "Napoli", "Salerno", " Napoli via toledo"];

	

      // ======= 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 += "&lt;/markers&gt;";
        }
      }

      // ======= 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/

    //]]>

Ora vorrei tramite questa funzione prendermi i luoghi da un database e metterli in questa variabile :

HTML:
var addresses=["Roma", "Napoli", "Salerno", " Napoli via toledo"];

Ecco il codice per far prendere da databese i luoghi:
HTML:
   // Read the data from example.xml
      downloadUrl("database.php", function(doc) {
        var xmlDoc = xmlParse(doc);
        var markers = xmlDoc.documentElement.getElementsByTagName("marker");
        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");
		  var text = markers[i].getAttribute("text");
		  //document.write(markers.length);
          // create the marker
		 // var j=["name:"+"'"+name+"'"+","+"luogo:"+"'"+luogo+"'"+","+"indirizzo:"+"'"+indirizzo+"'"+"," + "lat:"+lat+ ","+"lng:"+lng+"," +"data:" +"'"+data+"'"+","+"context:"+"'"+context+"'"];
         //var ja=[name+","+luogo+","+indirizzo+","+lat+","+lng+","+data+context];
		 //document.write(ja);
		 var addresess = [];
		var j={};
		//j.name = name;
		j.luogo=luogo;
		j.indirizzo=indirizzo;
	
		addresess.push(j);
       
		 

        }


      });

Ma non mi funziona... Cosa sbaglio?
 
Discussioni simili
Autore Titolo Forum Risposte Data
S problema passaggio di parametri tra due pagine php PHP 7
LaKanka Problema passaggio parametri PHP 2
G problema passaggio parametri form-php PHP 1
N Problema passaggio variabili tra pagine PHP 4
andreas88 Problema installazione passaggio 2 Magento Magento 0
A Problema nel passaggio di una animazione da flash a animate Flash 9
ESABOT Problema passaggio dati tra activity tramite intent Sviluppo app per Android 1
A Problema con getCurrentPosition e passaggio variabili da javascript a PHP Javascript 3
G [PHP] Problema nel passaggio del valore mese PHP 8
R Problema passaggio variabili POST PHP 0
T Problema con il passaggio dati metodo "POST" PHP 1
F Problema con passaggio variabile da form PHP 3
B Problema su passaggio dati da form Classic ASP 1
M [RISOLTO]Problema controllo e passaggio di valori da una pagina all''altra PHP 4
P Problema passaggio di valori da una pagina php ad un'altra PHP 2
V problema passaggio di dati Javascript 0
V problema riguardante l'apertura di pagine e passaggio dati nei div Javascript 0
P problema passaggio valore javascript a select su pagine php Javascript 0
J problema passaggio di variabili Classic ASP 0
D Problema Passaggio variabili Classic ASP 2
cosov Problema con passaggio dati tra pagine asp Classic ASP 5
S Flash & PHP - Problema passaggio variabili! Flash 1
M Problema passaggio variabili in asp Classic ASP 2
I Sto progettando nuovi siti utilizzando bootstrap e devo dire funziona bene, l'unico problema e la maschera -moz- HTML e CSS 0
K Problema form update PHP 2
O problema con dvr dahua xvr5116 IP Cam e Videosorveglianza 0
S Problema nel ciclare un json Javascript 0
G Problema con Xampp Web Server 1
andrea barletta Problema con miniature comandi Photoshop 0
I problema con alice Posta Elettronica 0
K Problema Inner join PHP 1
F firefox problema http Linux e Software 0
N Problema con position absolute e overflow HTML e CSS 4
E Problema jquery Success jQuery 2
L Problema con inner join PHP 11
K [php] Problema con inner join PHP 4
E problema selezione sfumata Photoshop 2
K [PHP] Problema con variabili concatenate. PHP 1
A Problema filtro fluidifica Photoshop Photoshop 1
H Problema Bordi Scontorno Photoshop 1
O problema con query PHP 4
R Problema installazione Realtek WiFi USB rtl8821 Reti LAN e Wireless 1
I problema con 2 account Posta Elettronica 1
L problema collegamento file css con html HTML e CSS 1
Y Problema percorso file in rete PHP 1
N Problema SEO "L'URL non si trova su Google" SEO e Posizionamento 4
E Problema accesso a file con app sviluppata con MIT APP INVENTOR 2 Sviluppo app per Android 0
P Problema acquisizione clienti Webdesign e Grafica 1
F NetBeans problema creazione progetto Java Windows e Software 0
M Problema con Try Catch PHP 0

Discussioni simili