2010-03-17 43 views
0

我正在使用Google GClientGeocoder地理編碼器功能。 getLocations方法似乎是一個Google異步回調函數。Google GClientGeocoder地理編碼器功能 - 如何傳遞額外的parm(s)?

我想用id找到的記錄更新爲GLatLng, 但是我無法弄清楚如何將id作爲參數添加到我的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

也許你應該問之前新接受你以前的問題? – antyrat 2010-03-17 12:13:25

回答

0

我認爲,這是相當簡單:

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) 

}