× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Using google map with Rails

Chih-Wei Chang
Nov 19, 2014
<p><span style="font-size:16px">When trying to use the Google Map API with Rails, here is a handy gem:</span></p><p><span style="font-size:16px">https://github.com/apneadiving/Google-Maps-for-Rails</span></p><p><span style="font-size:16px">However, when you use it, remember to add things like this:</span></p><pre><code class="language-html">&lt;script type="text/javascript"&gt; function initialize() { var latlng = new google.maps.LatLng(-34.397, 150.644); var myOptions = { zoom: 8, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } google.maps.event.addDomListener(window, "load", initialize); &lt;/script&gt;</code></pre><p><span style="font-size:16px">in case you get any error like: "Uncaught TypeError: Cannot read property 'offsetWidth' of null"</span></p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus