0

控制器.rb

Rails 4.0 + gmaps4rails 2.0.3 + ruby​​ 2.0.0
我想更改谷歌地图上的标记图像。如果我给“图片”=>' 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

根据维基你必须使用

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 回答