Heya :) This group is used primarily for announcements now; for questions like this I recommend Stack Overflow instead. There's a maps-api-v3 and places-api tag which will bring this to the attention of the best people.
In the meantime, try using getPlacePredictions rather than getQueryPredictions. This appears to apply the restriction correctly. Cheers, James On Sat, Aug 8, 2015 at 8:36 AM, gotofritz <fritzthe...@gmail.com> wrote: > Hi. A simple AutocompleteService request. > > Loading this API: > https://maps.googleapis.com/maps/api/js?v=3.21&libraries=places&callback= > onAPILoaded > > And running this script (sorry, tried to do a JSBin > http://jsbin.com/sujatuzaro/edit?html,js,output but it won't load the > API) > > function runQuery(country) { > var request = { > input: 'london', > componentRestrictions: {country: country}, > }; > > var callback = function(predictions, status) { > if (status != google.maps.places.PlacesServiceStatus.OK) { > alert(status); > return; > } > var resultsString = predictions.reduce(function (prev, current) { > return prev + "\n" + current.description; > }, "RESULTS FOR " + country + "\n--------------\n"); > console.log(resultsString); > }; > > var service = new window.google.maps.places.AutocompleteService(); > service.getQueryPredictions(request, callback); > } > > function onAPILoaded() { > runQuery('uk'); > runQuery('ca'); > } > > I get the following output: > > RESULTS FOR uk > -------------- > > London, United Kingdom > London, ON, Canada > London Borough of Hillingdon, United Kingdom > London Eye, London, United Kingdom > London Bridge, London, United Kingdom > > RESULTS FOR ca > -------------- > > London, United Kingdom > London, ON, Canada > London Borough of Hillingdon, United Kingdom > London Eye, London, United Kingdom > London Bridge, London, United Kingdom > > > RESULTS FOR uk > -------------- > > London, United Kingdom > London, ON, Canada > London Borough of Hillingdon, United Kingdom > London Eye, London, United Kingdom > London Bridge, London, United Kingdom > > .... > > The problem is not that they are repeated a few times (although that is > odd) but the fact the componentRestrictions doesn't seem to have any effect. > Any idea? Thanks in advance. > > -- > You received this message because you are subscribed to the Google Groups > "Google Maps JavaScript API v3" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to google-maps-js-api-v3+unsubscr...@googlegroups.com. > To post to this group, send email to > google-maps-js-api-v3@googlegroups.com. > Visit this group at http://groups.google.com/group/google-maps-js-api-v3. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-maps-js-api-v3+unsubscr...@googlegroups.com. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. Visit this group at http://groups.google.com/group/google-maps-js-api-v3. For more options, visit https://groups.google.com/d/optout.