2010-03-17 6 views
0

J'utilise la fonction de géocodage de Google GClientGeocoder. La méthode getLocations semble être une fonction de rappel asynchrone de Google.Fonction de géocodeur Google GClientGeocoder - comment transmettre des paramètres supplémentaires?

Je voudrais mettre à jour l'enregistrement identifié par "id" avec des points trouvés dans GLatLng, Cependant je ne peux pas comprendre comment ajouter l'id en tant que paramètre à ma fonction getGeoCode.

function fnGetEncoding(address,id) 
    { 
    // Create new geocoding object 
    geocoder = new GClientGeocoder(); 

    // Retrieve location information, pass it to getGeoCode() 
    geocoder.getLocations(address, getGeoCode); 
    } 

    function getGeoCode(response) 
    { 
    // Retrieve the object 
    place = response.Placemark[0]; 

    // Retrieve the latitude and longitude 
    point = new GLatLng(place.Point.coordinates[1], 
     place.Point.coordinates[0]); 

    $('#id_listing').append(response.name + point + '<br>');  

    // I would like to update the record identified with "id" with points found GLatLng 

    // fnWriteGeocodesToFile(response.name, id , point) 



    } 
+0

Peut-être que vous devriez accepter vos questions avant de demander auparavant nouveau? – antyrat

Répondre

0

je pense, il est assez simple:

function fnGetEncoding(address,id) 
{ 
    // Create new geocoding object 
    geocoder = new GClientGeocoder(); 

    // Retrieve location information, pass it to getGeoCode() 

    geocoder.getLocations(address, 
    **function(response,id){** 
    getGeoCode(response,id); 
    **}** 
} 

function getGeoCode(response,id) 
{ 
    // Retrieve the object 
    place = response.Placemark[0]; 

    // Retrieve the latitude and longitude 
    point = new GLatLng(place.Point.coordinates[1], 
    place.Point.coordinates[0]); 

    $('#id_listing').append(response.name + point + '<br>');  

    // I would like to update the record identified with "id" with points found GLatLng 

    // fnWriteGeocodesToFile(response.name, id , point) 

} 
Questions connexes