I am attempting to Geocode a physical address using the Google Maps API in a Meteor template.
This is the function I am using to run the geocoder:
codeAddress = function(address, callback) {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
callback(results[0].geometry.location);
} else {
callback(0);
}
});
}
Using a static address for testing purposes, this is the function I am using to call codeAddress():
codeAddress("3100 East Fletcher Avenue, Tampa, FL, United States", function(result) {
console.log(result);
});
Here is the Problem
The console output returns nothing for the Lat and Long:
But the response from the Google Maps API does, in fact, contain the needed information:
I know that the API is asynchronous but I don't know enough about Meteor to figure out how to retrieve the data after it has been returned by the API.