Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gmaps4rails not showing map

Following the YouTube video on getting to run Gmaps4rails, I cannot get it to show a map. (Rails 3.1.3, gmaps4rails 1.3.2)

The page includes the correct javascript assets in the head ...

<script src="/assets/gmaps4rails/gmaps4rails.base.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps4rails/gmaps4rails.bing.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps4rails/gmaps4rails.googlemaps.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps4rails/gmaps4rails.mapquest.js?body=1" type="text/javascript"></script>
<script src="/assets/gmaps4rails/gmaps4rails.openlayers.js?body=1" type="text/javascript"></script>

... the correct placeholder for the map is included ...

<div class="map_container"> 
  <div id="map" class="gmaps4rails_map"></div>
</div>

and the scripts are generated at the end of my body:

<script type="text/javascript" src="//maps.google.com/maps/api/js?v=3.5&sensor=false&amp;libraries=geometry"></script>
<script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox_packed.js"></script>
<script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.5/src/markerclusterer_packed.js"></script>
<script type="text/javascript" src="//google-maps-utility-library-v3.googlecode.com/svn/trunk/richmarker/src/richmarker-compiled.js"></script>  

<script type="text/javascript" charset="utf-8">

Gmaps.map = new Gmaps4RailsGoogle();
Gmaps.load_map = function() {
Gmaps.map.map_options.auto_adjust = true;
Gmaps.map.initialize();
Gmaps.map.markers = [{"lng": "4.481594", "lat": "51.194179"}];
Gmaps.map.markers_conf.do_clustering = true;
Gmaps.map.create_markers();
Gmaps.map.adjustMapToBounds();
Gmaps.map.callback();
};    
window.onload = function() { Gmaps.loadMaps(); };

</script>

All parts seem to be in place, but it's not doing anything. I'm not sure how to debug this. Did I miss something critical?

like image 552
Anthony Liekens Avatar asked Dec 22 '25 01:12

Anthony Liekens


1 Answers

The stylesheets for gmaps4rails were not included in my page, since I had overwritten the default application.css by my own styling. As a result, the maps did not show up.

Making sure that gmaps4rails.css was required solved the problem.

<%= stylesheet_link_tag "gmaps4rails" %>
like image 163
Anthony Liekens Avatar answered Dec 23 '25 22:12

Anthony Liekens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!