Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Javascript API gives INVALID_REQUEST

I am using Google Maps JavaScript API from ionic 2 framework. This code

new google.maps.places.AutocompleteService().getPlacePredictions(
    { input: query, types: ['cities'] }, 
    function (predictions, status) {}
);

gives INVALID_REQUEST as a status and empty predictions. In browser console I could see this URL query:

https://maps.googleapis.com/maps/api/place/js/AutocompletionService.GetPredictionsJson?1skha&4sen-US&9scities&15e3&key=my_api_key_is_here&callback=YYYY&token=XXXX

for query=kha.

Official documentation does not helps a lot (because there is no even error status returned).

like image 902
heroin Avatar asked Dec 31 '25 10:12

heroin


1 Answers

After looking more closely in docs, I've found that I used incorrect type. It should be '(cities)' instead of 'cities'.

like image 107
heroin Avatar answered Jan 06 '26 05:01

heroin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!