Google maps 离子2中的地理代码API出错

Google maps 离子2中的地理代码API出错,google-maps,typescript,ionic2,geocode,Google Maps,Typescript,Ionic2,Geocode,我正在使用谷歌地图地理编码API读取地址并在地图上放置标记。我就是这样使用它的: for(let marker of markers){ this.geocoder = new google.maps.Geocoder(); this.geocoder.geocode({ 'address': marker["address"] }, (results,status) => { var position = new google.maps.LatLng(resul

我正在使用谷歌地图地理编码API读取地址并在地图上放置标记。我就是这样使用它的:

for(let marker of markers){
this.geocoder = new google.maps.Geocoder();
this.geocoder.geocode({
 'address': marker["address"]
}, (results,status) => {  
          var position = new google.maps.LatLng(results[0].geometry.location.lat(),results[0].geometry.location.lng()); // error pointing to this line
          this.personMarker = new google.maps.Marker({position: position, title: marker.name, markerInfo: marker, map : this.map , icon : marker.imageurl});
          google.maps.event.addListener(this.personMarker, 'click',  () => {
          this.showCard = true;
          this.org = marker.organization;
          this.gig = marker.gig;
          this.location = marker["address"];
          this.image = marker.imageurl;
          this.ngoData = marker;
          this.ownerusername = marker.ownerusername;
            });
     });
 }
我收到以下
错误:“无法读取null属性“0”
指向我在代码段中显示的带有注释的行。只是不知道是什么导致了该错误,因为我仅在
回调中访问“results”参数
console.log(results)
有时会在循环的第一次迭代中返回“null”,然后返回剩余迭代的正确结果,或者返回所有迭代的正确结果。我不理解这种不一致的行为,但我知道,当我再次单击和加载地图之间的间隔很短时,通常会出现这种错误


我知道所有的地址都是有效的,因为有时我所有的标记都出现在地图上,错误没有出现

请再试一次,看看检查
状态
是否会得到一个错误代码,如
超过查询限制
,然后将其张贴在这里。通常,GeocodeAPI和其他API每秒都有一个配额。这或许可以解释这种间歇性行为。我还建议在继续使用
results
之前,始终添加一个简单的检查器,如
if(status==“OK”&&results)
。再试一次,看看检查
status
是否会得到一个错误代码,如
超过查询限制
,然后将其发布到此处。通常,GeocodeAPI和其他API每秒都有一个配额。这或许可以解释这种间歇性行为。我还建议在继续使用
results
之前,始终添加一个简单的检查器,如
if(status==“OK”&&results)