Вопрос

When creating a google static map I want to use rails assets path rather than directly stating production server path. Doesn't work when I do it like below. How can I do that? I'm actually using gmaps4rails but read that it doesn't support creating static maps.

user_icon = "http://0.0.0.0:3000/assets/number_1.png"

URI.encode("http://maps.google.com/maps/api/staticmap?center=#{customer}&zoom=9&size=#{width}x#{height}&scale=2&sensor=false&markers=color:0xEE82EE|#{customer}&markers=icon:#{user_icon}|#{provider1}&markers=color:0x00BFFF|#{provider2}&markers=color:0x00BFFF|#{provider3}")
Это было полезно?

Решение

I discovered that I has to URL encode the link to icon. So this sorted it out

user_icon = URI.encode(facebook_profile_picture(user_id))
provider1_icon =URI.encode("http://graph.facebook.com/100006411879480/picture?type=square")

....

 return URI.encode("http://maps.google.com/maps/api/staticmap?center=#{customer}&zoom=9&size=#{width}x#{height}&scale=2&sensor=false&markers=color:0xEE82EE|#{customer}&markers=icon:#{user_icon}|#{provider0}&markers=color:0x00BFFF|#{provider1}&markers=icon:#{provider1_icon}|#{provider2}")
      end 
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top