Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

How to configure others attributes on gmaps4rails?


I'm using gmaps4rails and really enjoying it, but, I missed setting some properties, such as:

  • scrollwheel
  • zoomControl
  • zoomControlOptions

How could these be used?


Solution

  • There is a dedicated callback in the gem to trigger custom settings.

    You could do this:

    <%# your call to gmaps4rails here %>
    
    //important: this must be AFTER the call to gmaps4rails so that the Gmaps4Rails class is known.
    <% content_for :scripts do %>
    <script type="text/javascript" charset="utf-8">
      Gmaps4Rails.callback = function() {
        Gmaps4Rails.map.setOptions({
          scrollwheel: false,
          zoomControl: true,
          zoomControlOptions: whatever_you_need
        }):
      };
    </script>
    <% end %>