Skip to content
Benjamin Roth edited this page Oct 22, 2013 · 1 revision

The gem comes with a hash builder:

    @hash = Gmaps4rails.build_markers(@users) do |user, marker|
      marker.lat user.latitude
      marker.lng user.longitude
      marker.json({:id => user.id })
      marker.picture({
       "url" => "/logo.png",
       "width" =>  32,
       "height" => 32})
      marker.infowindow render_to_string(:partial => "/users/my_template", :locals => { :object => user})
    end

    # @hash is a Hash, convert it to json using @hash.to_json or any other method

Depending on your setup, use your own json builders, just stick to the expected keys.