Функция геокодера Google GClientGeocoder - как передать дополнительные параметры? - PullRequest
0 голосов
/ 17 марта 2010

Я использую функцию геокодера Google GClientGeocoder. Метод getLocations представляется функцией асинхронного обратного вызова Google.

Я бы хотел обновить запись, обозначенную "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)  



    }

1 Ответ

0 голосов
/ 30 сентября 2010

Я думаю, это довольно просто:

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)  

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...