我在我的谷歌地图上设置了一个标记图标图片,当我传入一个 url 时它工作得很好,但是当我设置一个链接到本地 Assets 的 image_tag 时,它找到了 Assets 但没有在 map 。这是我的代码:
@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"))
关于css - 无法使用 rails helpers image_tag 或 image_path 在 Google map 上显示本地镜像图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43064937/