0

At present when a new marker is added to the map, it will automatically zoom into that new location.

How can I configure gmaps4rails to respond to a button that will automatically zoom out to view all the markers on the map? as below:

enter image description here

The configuration I have for rendering is:

  allLocations = root.table.rows(".selected").data()
  $('#multi_markers').map ->
    handler = Gmaps.build("Google")
    handler.buildMap
      internal:
        id: "multi_markers"
    , ->
      for aLocation in allLocations
        markers = handler.addMarkers([
          {
            lat: aLocation[9]
            lng: aLocation[10]
          }
        ])
      handler.bounds.extendWith markers
      handler.fitMapToBounds()
      return

Note this is pertaining to gmaps4rails not simply gmaps

Sauron
  • 6,399
  • 14
  • 71
  • 136

1 Answers1

0

after handler.buildMap you can tell set a default zoom like this:

handler.buildMap({ provider: { zoom: 15, center: new google.maps.LatLng(40.7127, -74.00030), mapTypeId: google.maps.MapTypeId.ROADMAP}, internal: {id: 'map'}}

Here assign the latitude: 40.7127 longitude: -74.00030 and zoom: 15. The rest is type of map and can be left out

elcapitan
  • 145
  • 1
  • 2
  • 13