I am trying to figure out why when I have a map displaying a controller's json string for map locations, when I click the infobox and go to a specific id page, I cannot zoom to the specific id location, and KEEP the rest of the locations on map. For instance:
The map displaying all of the points from the places_controller:
def index
@json = Places.all.to_gmaps4rails
end
The individual id page displaying itself:
def show
@json = Places.find(params[:id]).to_gmaps4rails
end
I want the .find(params[:id]).to_gmaps4rails to include .all of the places, but center on the :id location.
ps- the index map is geoLocated and centers on user, whereas the show location centers on just the 1 marker entry.
Thanks!
I'd do something like:
def show
@json = Places.all.to_gmaps4rails
@center = Places.find(params[:id])
end
And in view:
<%= gmaps( :map_options => { :center_latitude => @center.latitude, :center_longitude => @center.longitude, :zoom => 6 },
:markers => { :data => @json }
) %>