Search code examples
ruby-on-railsgoogle-mapsgmaps4rails

gmaps4rails v2 - map type


How do you set the map type to HYBRID or SATELLITE ? I thought it would be some option to pass to the provider hash, but if it's the case I can't find the proper one.

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

Thanks


Solution

  • Pass whatever map options you need from google as an object on the provider key.

    Its documented with the source here.

    In your case:

    var mapOptions = { mapTypeId: google.maps.MapTypeId.HYBRID };
    handler.buildMap({ provider: mapOptions, internal: {id: 'map'}}, function(){
      ...