ruby on rails - Loading Google map blank with console errors -
hi trying google map show on page in ruby on rails app i'm getting following errors. i'm struggling understand how whole process works. think has script tag can't figure out.
gmaps.js file in javascript folder:
/* options google maps */ map = new google.maps.map(document.getelementbyid('map-canvas'), { center: {lat: -34.397, lng: 150.644}, zoom: 8 }); html.erb:
<%# google map %> <div> <div id="map-canvas" style="width:400px; height:300px;"> </div> </div> script in application html:
<%-# google map script tag-%> <script async defer src="https://maps.googleapis.com/maps/api/js?key=your_key&callback=initmap"> </script> console errors:
uncaught referenceerror: google not defined uncaught invalidvalueerror: initmap not function
uncaught referenceerror: google not defined referring line:
map = new google.maps.map(document.getelementbyid('map-canvas') this error means ruby doesn't know google because have not defined it.
uncaught invalidvalueerror: initmap not function referring line:
src="https://maps.googleapis.com/maps/api/js?key=aizasyd6juojpsnbqs3jvscyzixu6on1nqpis6i&callback=initmap"> so callback being called application hasn't defined initmap function is.
are using gem this? if one?
Comments
Post a Comment