Is there a better way to retrieve the latitude and longitude from an address?
Currently, I am using the Google Maps API by passing the address like this:
getLocationJson(term: string) {
var term = "Mechelsesteenweg+64";
return this._http.get('https://maps.googleapis.com/maps/api/geocode/json?address=Someroad+64&key=AIzkeystuffjXDm6eU5mPP9Nczg')
.subscribe((json: any) => {
var obj = JSON.parse(json);
var jsonParsed = obj["results"];
});
}
However, I have a feeling that this might not be the most efficient method. Can I utilize geocoder instead? For example:
getGeoLocation(address: string) {
let geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latlng = google.maps.location.LatLng();
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
Any advice would be greatly appreciated. (It's similar to this question but with a different angle)