Search code examples
ruby-on-railsruby-on-rails-4gmaps4rails

How to show own image as marker on google map ? gmaps4rails 2


gmaps4rails 2 + rails 4

def CommonUtils.get_gmap_hash(object)
     Gmaps4rails.build_markers(object) do |user, marker|
         marker.lat user.latitude
         marker.lng user.longitude
         marker.infowindow user.location
         binding.pry
         marker.picture({
            :picture => "/img/blank.png",
            :width   => 32,
            :height  => 32
            })
         marker.json({:title => user.title})
      end
  end

here marker.picture method is not hitting itself don't know why ? Any help ?

and default marker is coming i want different marker(blank.png).

blank.png is in assets/images/img/blank.png


Solution

  • According to the source, do:

     Gmaps4rails.build_markers(object) do |user, marker|
         marker.lat user.latitude
         marker.lng user.longitude
         marker.infowindow user.location
         marker.picture({
            :url     => "/img/blank.png",
            :width   => 32,
            :height  => 32
            })
         marker.json({:title => user.title})
      end