1
votes

Anyone wise to whether it is possible to use the google places autocomplete api from a client side app.

I tried to access it with a jsonp request to the following url..

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=#{input}&types(regions)&language=en_en&key=MY_API_KEY&callback=JSONP_CALLBACK"

And I get this response

"error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 94.33.38.138, with referer: http://localhost:3000/"

What I'm finding out is that the autocomplete api requires a server key, and can only be accessed from the backend. Is that correct? Or is there another way to access it from a browser?

I need to combine the results from the places autocomplete with another autocomplete list on the same input field so the google places autocomplete widget is not an option.

1

1 Answers

2
votes

You may request the predictions via the autocomplete-service of the places-library of the javascript-API( https://developers.google.com/maps/documentation/javascript/places-autocomplete#place_autocomplete_service )...no key is required and it may be requested from client-side