Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

geocomplete_rails and Uncaught ReferenceError: google is not defined

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?

like image 766
Marcin Doliwa Avatar asked Dec 07 '25 22:12

Marcin Doliwa


1 Answers

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&amp;libraries=places"></script>

before line:

<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

Hope that helps!

like image 169
Paweł Dawczak Avatar answered Dec 09 '25 14:12

Paweł Dawczak



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!