3

Gmaps4rails is not define in rails 4.0.0 Google Maps for Rails i am following this tutorial "http://rubydoc.info/gems/gmaps4rails/2.0.4/frames"

1) Gemfile

gem 'gmaps4rails'

2) HTML on view page   
<div style='width: 800px;'>
  <div id="map" style='width: 800px; height: 400px;'></div>
</div>

3) on view page    
<script src="//maps.google.com/maps/api/js?v=3.13&amp;sensor=false&amp;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>
You'll require underscore.js too, see here: underscorejs.org/

3) Javascript source code

If you have the asset pipeline, add this:

//= require underscore
//= require gmaps/google
If you don't have asset pipeline, you'll need to import the js OR coffee files:

rails g gmaps4rails:copy_js

rails g gmaps4rails:copy_coffee
4) Javascript code:

Create your map:

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();
});

But when i am checking at firebug its showing "Gmaps is not defined" Ruby 2.0.0 rails 4.0.0 gmaps4rails 2.0.3

Any suggestion please reply.....

4

1 に答える 1