简体   繁体   中英

“Google is not defined” error on ruby on rails

I have a html and js file (maps_scripts.js) in which I have defined all the google maps function related to the mentioned html page. These two are working really fine.

I've been assigned to include these files to jruby on rails project developed by someone else.

So far these are the steps I took.

  1. copied maps_scripts.js file to \\app\\assets\\javascripts
  2. copied related marker images to \\app\\assets\\images
  3. added

     <%= javascript_include_tag 'https://maps.googleapis.com/maps/api/js?key=my_key&libraries=places' %> " 

    to my html.erb page

  4. include

     <%= javascript_include_tag 'map_scripts.js', 'data-turbolinks-track' => true %> 

    to my html.erb page

Question

I'm getting

 Uncaught ReferenceError: google is not defined at map_scripts.self-09044ded37604e5a1f367207911e2c79370a307b67a4be3178923d19f555011c.js:4

Note : I have several

   google.maps.* 

calls in the maps_scripts.js file. For an instance

  1. google.maps.MarkerImage
  2. google.maps.Size
  3. google.maps.Map etc.

Either you are missing a script or order of the scripts in map_scripts.js is wrong. try changing the order.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM