Search code examples
jqueryruby-on-railsgoogle-mapsruby-on-rails-3.1gmaps4rails

gmaps4rails zoom in on marker on user link click


I have several markers on one map, I also have several links and I want the user to be able to click the link and the map zooms in on the corresponding marker. I want to do this with a jQuery function. I browsed through the source code for gmaps4rails and found references to center_longitude and center_latitude. However using them as Gmaps.map.map.centerLongitude(12) or Gmaps.map.map.center_longitude(12) doesn't work.

What would the correct function be for dynamically changing where and how much it zooms?


Solution

  • You're looking for panTo defined here.

    Usage:

    Gmaps.map.map.panTo(new google.maps.LatLng(lat, lng));
    

    Btw, Gmaps.map.map.center_*is dedicated to map initialization.