I need to extract longitude and latitude coordinates from google.maps.GeocodeResults in order to store them in an external Array<any>
.
Currently, I am able to display results[0]
, but encounter an OVER_QUERY_LIMIT
error when attempting to add it to the array. This is confusing because I already have the desired value.
public geocoderResults!: Array<any>;
public addCodedAddress(address: string): void {
let geocoder = new google.maps.Geocoder();
geocoder.geocode({ address: address }, (results, status) => {
if (status == google.maps.GeocoderStatus.OK && results[0]) {
console.log('this does have something in it', results[0]);
this.geocoderResults.push(results[0]);
console.log(
'this should have something in it, but doesnt ',
this.geocoderResults,
);
} else {
console.warn(
'Geocode was not successful for the following reason: ' +
status,
);
}
});
}
How can I retrieve the GeocodeResults long / lat information?
Thank you!