I'm trying to use geocomplete_rails gem: https://github.com/guyisra/geocomplete_rails
My application.js file looks like this:
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require moment
//= require bootstrap-datetimepicker
//= require geocomplete
//= require_tree .
$(function() {
$('#event_raw_location').geocomplete();
});
When I open form page with #event_raw_location element, I get Uncaught ReferenceError: google is not defined error and autocomplete does not work. Any idea why?
From the documentation in here it looks like you should add one more JavaScript.
Try adding following line in your app/views/layouts/application.html.erb:
<script src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
before line:
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With