0

Controller.rb

Rails 4.0 + gmaps4rails 2.0.3 + ruby​​ 2.0.0
Googleマップのマーカー画像を変更したい。「画像」=>「http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000」を与えている場合、誰かがどうすればよいか考えていれば何も来ませんか? 共有してください
ありがとう

Gmaps4rails.build_markers(object) do |user, marker|
   marker.lat user.latitude
   marker.lng user.longitude
   marker.infowindow user.location
   marker.picture({
   "picture" => 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000',
   "width" =>  '16',        
   "height" => '16'
   })
   marker.json({:title => user.title})
end

私はこれも試していますが、別のマーカーがどこに間違っているのかわかりませんか?

def CommonUtils.get_gmap_city_marker(object)
     Gmaps4rails.build_markers(object) do |user, marker|
         marker.lat user.latitude
         marker.lng user.longitude
         marker.infowindow user.location
         marker.picture({
            :picture => "http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000", # up to you to pass the proper parameters in the url, I guess with a method from device
            :width   => 32,
            :height  => 32
            })
          marker.json({:title => user.title})
      end
  end
4

1 に答える 1

0

Wikiによると、使用する必要があります

def gmaps4rails_marker_picture
      {
       "picture" => "/images/#{name}.png",
       "width" => 20,
       "height" => 20,
       "marker_anchor" => [ 5, 10],
       "shadow_picture" => "/images/morgan.png" ,
       "shadow_width" => "110",
       "shadow_height" => "110",
       "shadow_anchor" => [5, 10],
      }
end

各マーカーのカスタマイズセクションで説明します。したがって、javascript を app/assets/javascripts/ に配置し、マーカーを app/assets/images/ フォルダーに配置してみてください。

于 2013-11-26T11:32:34.107 に答える