My objective is to add circles in place of markers to show the general area of the location of the each tool in the Tool model. I was able to add circles based on other answers on SO, however using the following code I get the error in the title of this question.
In my controller:
def index
@tools = Tool.all
@json=Tool.all.to_gmaps4rails
@circles = Tool.all{|t| {:longitude => t.longitude, :latitude => t.latitude, :radius =>"1000" }}.to_json
respond_to do |format|
format.html # index.html.erb
format.json { render json: @tools }
end
end
In my view file:
<%= gmaps({ "markers" => {"data" => @circles}, "circles" => { "data" => @circles} } ) %>
The JavaScript error directs me to the line 401 in the gmaps4rails.googlemaps.js file:
this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
Any ideas why?
put a break put in this.boundsObject.extend(circle.serviceObject.getBounds().getNorthEast());
and print our the circle
if i am not wrong @circle in rails is not format correctly
@circles = Tool.map{|t| {:longitude => t.longitude, :latitude => t.latitude, :radius =>"1000" }}.to_json
it should be map instead of all to map all the array and print out in json
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