Reputation: 6108
I´m trying to display a Google Maps with gmaps4rails following the instructions from https://github.com/apneadiving/Google-Maps-for-Rails but I´m not able to display the map.
I have the gem gmaps4rails (1.5.6) installed with bundle.
I can see the javascripts included in my view source code:
However, please have a look at the paths of these scripts. It tries to get the javascripts from /javascript path (where there is nothing), instead of /assets (as I have seen in other examples). I think this is the root cause of the problem, however I don´t know how to solve it (I´m almost newbie with rails).
When the server tries to render the view, got this error:
<script src="//maps.google.com/maps/api/js?v=3.8&sensor=false&client=&key=&libraries=geometry&language=&hl=&region="></script>
<script src="//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js"></script>
<script src="/javascripts/gmaps4rails/gmaps4rails.base.js"></script>
<script src="/javascripts/gmaps4rails/gmaps4rails.googlemaps.js"></script>
<script type="text/javascript">
Gmaps.map = new Gmaps4RailsGoogle();
Gmaps.load_map = function() {
Gmaps.map.map_options.auto_adjust = true;
Gmaps.map.initialize();
Gmaps.map.markers = [{"lat":"45","lng":"36"},{"lat":"41.45","lng":"-120"}];
Gmaps.map.markers_conf.do_clustering = true;
Gmaps.map.create_markers();
Gmaps.map.adjustMapToBounds();
Gmaps.map.callback();
};
Gmaps.oldOnload = window.onload;
window.onload = function() { Gmaps.triggerOldOnload(); Gmaps.loadMaps(); };
</script>
Started GET "/javascripts/gmaps4rails/gmaps4rails.base.js" for 127.0.0.1 at 2013-09-18 13:01:35 +0200
ActionController::RoutingError (No route matches [GET] "/javascripts/gmaps4rails/gmaps4rails.base.js"):
Upvotes: 1
Views: 655
Reputation: 6108
I finally solved it. I skipped the second step in github instructions. I thought rails generate gmaps4rails:install was same as bundle install. Now, I have found out this is the way it install the css and javascript resources in your app.
After that I managed to show the map. Although I have some other problems, but I will open a new topic.
Upvotes: 2