0
코드가 제대로 작동하지만이 함수를 호출 할 때마다 모바일 장치에서이 질문의 제목과 동일한 이름의 오류가 계속 발생합니다.정의되지 않은 'geometry'속성을 읽을 수 없습니다.
_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);
});
}
}
});
}
위도와 경도가 일부 로깅으로 정의 되었기 때문에 나는 왜 여전히 오류가 발생하는지 이해하지 못합니다. 미리 감사드립니다.
도움 주셔서 감사합니다. 내 백엔드의 주소 중 하나에 오타가 있었는데, 이는 googlemaps API가 존재하지 않는 주소를 검색하게 만들었습니다. 그것은 비록 내가 어떻게 다른 좌표의 정확한 금액을 받고 있었는지 재밌 네요 ... 만약 내가 충분한 평판을 가지고 당신에게 최대 표를 줄 것입니다. –
기꺼이 도와 드리겠습니다! –