I installed gmaps4rails for my Rails app, ran the generator, and required the two files like this in my application.js file, along with underscore.js
//= require underscore
//= require gmaps4rails/gmaps4rails.base
//= require gmaps4rails/gmaps4rails.googlemaps
adding, as instructed on github https://github.com/apneadiving/Google-Maps-for-Rails, these dependencies in layout.html.erb
<script src="//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry" type="text/javascript"></script>
<script src='//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js' type='text/javascript'></script>
When I tried to create the demo map from the github page with this code, I got an error that the object doesn't have a build
method.
Uncaught TypeError: Object # has no method 'build'
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers([
{
"lat": 0,
"lng": 0,
"picture": {
"url": "https://addons.cdn.mozilla.net/img/uploads/addon_icons/13/13028-64.png",
"width": 36,
"height": 36
},
"infowindow": "hello!"
}
]);
handler.bounds.extendWith(markers);
handler.fitMapToBounds();
});
Indeed, when I look inside the base
file that I require in the manifest file there is no build
method for that object.
How does one create a map in the new version for gmaps4rails?
Update the github account for gmaps says to require gmaps this way, but when I do it says'couldn't find file 'gmaps/google'
//= require underscore
//= require gmaps/google
You should use these requires in the assets pipeline
//= require underscore
//= require gmaps/google
Remember that you will need to add underscore.js manually or using a gem in order to use it.