我在Google地图上设置了一个标记图标图片,当我传入url时,它可以完美地工作,但是当我设置链接到本地​​资产的image_tag时,它会找到资产,但不会在地图上显示。这是我的代码:

@home.marker(view_context.image_path("i-home.png", size: '80x80', class: 'text-size'))

助手给我以下路径

"/assets/i-home-afcc4167c5d6c4a0bffbe87848bb9694437b7f506c3fb5465fe597642d6a41f2.png"

我也想知道为什么没有以前使用过的'view_context'不能正常工作。

我什至还尝试添加css属性:

.text-size {
  width: 80px !important;
  height: 80px !important;
}


这是可以使用url的代码:

@home.marker("http://res.cloudinary.com/dndagbvyi/image/upload/c_scale,w_80/v1490692341/dog-shadow-02_m1vpet.png")


和“标记”方法:

    def marker(image)
      Gmaps4rails.build_markers(self) do |address, marker|
      marker.lat address.latitude
      marker.lng address.longitude
      marker.infowindow address.name
      marker.picture({
                  anchor: [40, 58],
                  url: image,
                  width: 500,
                  height: 500,
                 })
     end
   end

最佳答案

尝试对image_path方法使用单个参数。

@home.marker(view_context.image_path("i-home.png"))

10-07 19:34
查看更多