kristianmandrup / gmaps-autocomplete-rails

Google Maps v3 search with jQuery UI Autocomplete, ready for use with Rails asset pipeline
MIT License
73 stars 35 forks source link

How to use Google Places API Key? #17

Closed stefanocdn closed 8 years ago

stefanocdn commented 8 years ago

Hi, I read the documentation but cannot find a way to use a Google API Key (to increase the number of requests), is there a way to do it?

I know I could add key param inside the URL

<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=XXXX&amp;sensor=false"></script>

But is that safe to embed an API Key on the client side?

kristianmandrup commented 8 years ago

Read the Google API docs ;)

https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key

<script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
  type="text/javascript"></script>

You now have to use HTTPS, to ensure it is safe and the key (and your location?) is not intercepted.