How do pass color parameter to google maps api using google-maps-for-rails? I would like to set color of each marker inside controller based on a value, so some would be red, some yellow and some green. I believe it is the icon property, in Symbol, looking at:
https://developers.google.com/maps/documentation/javascript/reference#MarkerOptions
Also, I would like to have a number from 1-99 inside the marker, is it possible? So far I have this.
@json = Device.all.to_gmaps4rails do |device, marker|
end
I have been struggling with this for days, any help would be appreciated.
You should simply leverage the google's chart api.
Example, the following is a marker with:
FF0000
000000
http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000
So you should customize your needs:
@json = Device.all.to_gmaps4rails do |device, marker|
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
})
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With