i am using the Google-Maps-for-Rails gem and I am now trying to display circles.
My Model “Place” consists of:
- longitude
- latitude
- radius
- etc
I have no problem to display markers:
# Controller: @markers = Place.all.to_gmaps4rails
gmaps("markers" => {"data" => @markers})
Unfortunately it doens’t include :radius => ..
I also know that circles can be displayed like:
gmaps(
"circles" => { "data" => '[
{"longitude": -122.214897, "latitude": 37.772323, "radius":1000000}
]',
})
Is there any way to include the radius attribute in the markers hash ? Like:
gmaps("circles" => { "data" => @markers })
Probably something like:
Place.all.each |place| place.merge!(:radius => 1000) ...
would do, but I think there may be a nicer solution
The logic behind markers and circles is really different.
In your controller
In your view:
Or if you don’t need
infowindowor other features, you could simply do:In your controller
In your view: