问题
I have a ruby on rails application in which in 80% of the pages I am using google maps. So in many of my seperate JS files (in assets/javascripts) I have included many variables from google like
google.maps.DirectionsStatus
new google.maps.LatLng(a,b)
new google.maps.Marker
google.maps.event.addListener
And I have included the below script in my application.html.erb in head section
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=<%= ENV["GOOGLE_MAP"]%>&sensor=false&libraries=places">
</script>
In production in pages in which I am not using google maps an error is displayed on console
TypeError: a is null
...(null,_.ia)},p$=function(a,b){this.j=a;this.ma=a.value;this.Vd(this.ma);this.V=b...
This stops other javascript functions in the pages with no google maps from running.Everything in the localhost works fine btw its only in production (Aws-ec2 server with ubuntu. Server nginx and app server puma) that it is not working. Have I gone wrong with google maps integration? Is there a workaround for this problem?
Note: I am not using turbolinks for the application.
Update: Upon further testing only document.ready functions are not working on such pages. Other js functions on such pages are working fine in production.