Skip to content

Navigation Menu

Sign up
apneadiving edited this page Sep 30, 2011 · 16 revisions

Since 1.2.0, you can pass your maps params almost entirely from controller.

That's really useful when it comes to use partials as infowindows and I extended this to the other features.

Previously, you could just add extra content to the json created: @json = User.all.to_gmaps4rails do |user, marker| ""id": #{user.id}" end

Now, do:

@json = User.all.to_gmaps4rails do |user, marker|
 marker.json "\"id\": #{user.id}"
end

Here is an example which speaks for itself:

@json = User.all.to_gmaps4rails do |user, marker|
 marker.infowindow render_to_string(:partial => "/users/my_template", :locals => { :object => user}).gsub(/\n/, '').gsub(/"/, '\"')
 marker.picture({
 :picture => "http://www.blankdots.com/img/github-32x32.png",
 :width => "32",
 :height => "32"
 })
 marker.title "i'm the title"
 marker.sidebar "i'm the sidebar"
 marker.json "\"id\": #{user.id}"
end

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /