I would need to set up in our application a radius circle into Google Maps, something like
(pink radius circle).
In the best way I would need to specify how big in miles the radius will be. As our application is written in Ruby On Rails, I am thinking whether will be better to use just Javascript or a gem.
Thank you very much!
EDIT: Attempts:
var map;
var miles = 3;
function initialize() {
var mapOptions = new google.maps.Circle({
center: new google.maps.LatLng(51.476706,0),
radius: miles * 1609.344,
fillColor: "#ff69b4",
fillOpacity: 0.5,
strokeOpacity: 0.0,
strokeWeight: 0,
map: map
});
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
But the map is not inicialized.
Best Answer
Well it's very easy to add a circle to a map with the Maps API, see https://developers.google.com/maps/documentation/javascript/reference?csw=1#Circle
And then you just need some JS to convert miles to metres. Multiply by 1609.344 in fact should do it. So something like this perhaps:
(updated my answer for a fully working solution)