Anthony Liekens
Anthony Liekens

Reputation: 1081

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?

Upvotes: 3

Views: 3487

Answers (2)

Anthony Liekens
Anthony Liekens

Reputation: 1081

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" %>

Upvotes: 4

Sami
Sami

Reputation: 75

Your content looks pretty similar to what I have; unfortunately I cannot see anything amiss right away.

To answer the last part of your question: have you used the debug console of your browser to see if there are any JS errors thrown during rendering?

Upvotes: 0

Related Questions