Rails n00b here. I'm attempting to add circles to my maps and stuck on adding this functionality. My current view:
<script type="text/javascript">
circle = [{'lng' => <%= @listing.longitude %>, 'lat' => <%= @listing.latitude %>, 'radius' => 25000, 'strokeColor' => '#FF0000'}]
handler = Gmaps.build('Google');
handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
markers = handler.addMarkers(<%=raw @hash.to_json %>);
handler.bounds.extendWith(markers);
handler.addCircle(circle);
handler.fitMapToBounds()
handler.getMap().setZoom(12);
}); </script>
The map is working correctly when I remove the "circle= ..." code as well as handler.addCircle(circle) code.
Where am I going wrong?
The circle =
should probably be in JS hash syntax like:
circle = [{lng: <%= @listing.longitude %>, lat: <%= @listing.latitude %>, radius: 25000, strokeColor: "#FF0000"}]
You currently have it in Ruby syntax.