Pregunta

 @hash = Gmaps4rails.build_markers(@additional_infos) do |additional_info, marker|
         marker.lat additional_info.latitude
         marker.lng additional_info.longitude
         marker.picture({
             "picture" => view_context.image_path('/qr-code-icon.png'),
             "width" => 32,
             "height" => 37
         })
       end

This is in my index action of controller. The map shows fine with regular markers but I cant seem to get the custom markers to show. I've tried numerous types of different URLs and ways to link to the icons but no luck.

I've tried "url" = > #{root_url} , http localhost etc.. Pulling my hair out

¿Fue útil?

Solución

You must use "url" hash key instead of "picture"

@hash = Gmaps4rails.build_markers(@additional_infos) do |additional_info, marker| 
  marker.lat additional_info.latitude 
  marker.lng additional_info.longitude 
  marker.picture({
    "url" => view_context.image_path('/qr-code-icon.png'), 
    "width" => 32, 
    "height" => 37 
  })
end

Otros consejos

try this, that work for me.

@hash = Gmaps4rails.build_markers(@members) do |member, marker|
  marker.lat member.latitude
  marker.lng member.longitude
  marker.infowindow member.name
  marker.picture({
:url => view_context.image_path('marker.png'),
:width => 32,
:height => 37

})

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top