0
财产“几何”我的代码工作像它应该,但我不断收到错误这个问题的标题我的移动设备上的同名每当这个函数被调用。无法读取的不确定
_matchAddresses(id) {
fetch('https://myapp.com/rest/jobs/address/' + id)
.then((response) => response.json())
.then((responseJson) => {
var addresses = [];
console.log('addresses: ' + responseJson);
for (var i=0; i<responseJson.length; i++) {
addresses.push(responseJson[i]);
for (var j=0; j<addresses.length; j++) {
fetch('https://maps.googleapis.com/maps/api/geocode/json?address='+ addresses[j].split(" ") + '&key=googleapikey')
.then((response) => response.json())
.then((responseJson) => {
let lat = responseJson.results["0"].geometry.location.lat; //error here
let lng = responseJson.results["0"].geometry.location.lng; //error here
console.log("coordinates: " + lat + " " + lng); //returns coordinates every time
if (this._latMatch(userLat, lat) && this._lngMatch(userLng, lng)) {
this._myFunction();
console.log("fire");
}
})
.catch((error) => {
console.error(error);
});
}
}
});
}
我知道,纬度和经度已与一些日志定义的,所以我dont't明白为什么我仍然会得到错误。先谢谢你。
谢谢您的帮助。事实证明,我的后端的一个地址有它一个错字,这是导致Google地图API搜索一个不存在的地址。很有趣的是我是如何得到不同坐标的正确数量虽然...如果我有足够的声誉我会给你一个了投票。 –
很高兴能帮到你! –