I have been trying for years to figure out how to use google maps in my Rails app. I am currently trying with Rails 5.
I have also been trying to figure out how to get my javascript to work in a production environment.
My most recent attempts at these challenges are outlined in this production issue post and this google maps post.
After a long codementor session, the production environment javascript problem seemed to have been solved by moving:
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
from out of the head tag to the end of the body tag.
However, in doing this, the google maps javascript now doesnt work. It gives an error that says:
initMap is not a function
I have seen many others raise this problem, including here.
I have tried the solution outlined in this post, which is to replace this script:
<script src="https://maps.googleapis.com/maps/api/js?key=<%= ENV["GOOGLE_MAPS_API_KEY"] %>&callback=initMap"
async defer></script> -->
with this script in my address view file:
<script type="text/javascript" src="http://maps.google.com/maps/api/js?key=<%= ENV['GOOGLE_MAPS_API_KEY'] %>" async defer></script>
The key difference is the removal of "&callback=initMap". This gives no errors in the console inspector. However, it doesn't display a map either.
I have created a new problem by fixing the production issues.
Can anyone see what I need to do in order to get the google maps rendering (without breaking the production environment js)?