I followed the following tutorial:
And, the resulting code I wrote has the following instantiation for the google places autoplete (I'm using Node.js with browserify so it looks a little different):
enableAutoCompleteForElement: function(aDomElement) {
var self = this;
// The geocode type restricts the search to geographical location types.
GoogleMapsLoader.KEY = ArbitratorConfig.google_api_key;
GoogleMapsLoader.LIBRARIES = ['places'];
GoogleMapsLoader.SENSOR = false;
console.log("Google client id: " + ArbitratorConfig.google_client_id);
GoogleMapsLoader.load(function(google) {
self.autoplete = new google.maps.places.Autoplete(aDomElement,
{ types: ['geocode'] });
google.maps.event.addListener(self.autoplete, 'place_changed', function() {
// When the user selects an address from the dropdown, this will fire.
var place = self.autoplete.getPlace();
});
});
}
This works quite well, for most applications. However, I've noticed that it's not quite as accurate as the places autoplete bundled with Google Calendar. For example, if I create an event in Google Calendar and do a search in the location input for 'Bloomington Ice Garden', it will (probably depending on your location to start with) return a result of 'Bloomington Ice Garden, West 98th Street, Minneapolis, MN, United States'. However, if I perform the same search with my client, it doesn't bring up this result. The closest I can get is 'Bloomington, MN, United States'.
I feel like I'm missing part of the library, or I'm incorrectly telling it to do something that it shouldn't be doing. I'd like to be able to retrieve any type of place that's registered with Google Places - not just cities, states, or countries (which appears to be what it's autopleting currently).
I followed the following tutorial:
https://developers.google./maps/documentation/javascript/examples/places-autoplete-addressform
And, the resulting code I wrote has the following instantiation for the google places autoplete (I'm using Node.js with browserify so it looks a little different):
enableAutoCompleteForElement: function(aDomElement) {
var self = this;
// The geocode type restricts the search to geographical location types.
GoogleMapsLoader.KEY = ArbitratorConfig.google_api_key;
GoogleMapsLoader.LIBRARIES = ['places'];
GoogleMapsLoader.SENSOR = false;
console.log("Google client id: " + ArbitratorConfig.google_client_id);
GoogleMapsLoader.load(function(google) {
self.autoplete = new google.maps.places.Autoplete(aDomElement,
{ types: ['geocode'] });
google.maps.event.addListener(self.autoplete, 'place_changed', function() {
// When the user selects an address from the dropdown, this will fire.
var place = self.autoplete.getPlace();
});
});
}
This works quite well, for most applications. However, I've noticed that it's not quite as accurate as the places autoplete bundled with Google Calendar. For example, if I create an event in Google Calendar and do a search in the location input for 'Bloomington Ice Garden', it will (probably depending on your location to start with) return a result of 'Bloomington Ice Garden, West 98th Street, Minneapolis, MN, United States'. However, if I perform the same search with my client, it doesn't bring up this result. The closest I can get is 'Bloomington, MN, United States'.
I feel like I'm missing part of the library, or I'm incorrectly telling it to do something that it shouldn't be doing. I'd like to be able to retrieve any type of place that's registered with Google Places - not just cities, states, or countries (which appears to be what it's autopleting currently).
Share Improve this question asked Jan 14, 2016 at 4:45 jwir3jwir3 6,2195 gold badges51 silver badges98 bronze badges1 Answer
Reset to default 8Remove the types: ['geocode']
option from your Autoplete
. That's what's causing Google Places Autoplete to exclude places like 'Bloomington Ice Garden', which is an establishment and not a geocode.