所以我正在使用谷歌地图 api。我必须在对象内插入值 lat 和 lon,但我不能执行以下操作:
$.get(url).done(buscaGPS(data, i));
function buscaGPS(data, i) {
}
代码
objecto = [{
"address_1": "Avenida da Republica, 15A",
"city": "Lisbon",
"country": "pt",
"id": 1534282,
"name": "Pastelaria Versailles"
}, {
"address_1": "Avenida da Republica, 15A",
"city": "Lisbon",
"country": "pt",
"id": 1534282,
"name": "Pastelaria Versailles"
}];
for (var i = 0; i < objecto.length; i++) {
var url = "http://maps.googleapis.com/maps/api/geocode/json?address=" + objecto[i].address_1 + "+" + objecto[i].city + "+" + objecto[i].country + "&sensor=false";
$.get(url).done(buscaGPS);
};
function buscaGPS(data) {
objecto[i].lat = data.results[0].geometry.location.lat;
objecto[i].lon = data.results[0].geometry.location.lng;
}