Google GClientGeocoder geocoder function - how to pass extra parm(s)?
I am using Google GClientGeocoder geocoder function. Method getLocations seems to be a a Google asynchronous callback function.
I would like to update the record identified with "id" with points found in GLatLng, However I can't figure out how 开发者_如何学Pythonto add id as a parameter to my getGeoCode function.
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)
}
I think, it's quite 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)
}
精彩评论