gmaps4rails没有居中且没有显示圆圈

时间:2012-12-31 10:13:01

标签: ruby-on-rails-3 gmaps4rails

在我的Rails应用程序中,地图标记加载完全正常,但我无法将地图放在加拿大AB卡尔加里市中心。我正在使用用户的位置(通过IP进行地理编码),而且我似乎无法在地图上显示红色圆圈(描绘范围)。

我的控制器中有以下内容:

if !request.xhr?
  @json = @students.to_gmaps4rails do |student, marker|
    marker.infowindow render_to_string(:partial => "/map/infowindow", :locals => {:student => student}) 
    marker.title "#{student.name}, Grade: #{student.grade}"
    marker.json({:name => student.name, :address => student.full_address, :grade => student.grade, :subjects => student.subjects})
  end
  @mapOptions = "[{ 'map_options' => { 'type' => 'SATELLITE', 'detect_location' => true, 'center_on_user' => true, 'center_latitude' => 50, 'center_longitude' => -114, 'auto_adjust' => true} }]"
end
  @circles = "[{'lng': '#{results['address']['lng']}', 'lat': '#{results['address']['lat']}', 'radius': '#{(results['radius'] * 1000)}', 'strokeColor': '#{ '#FF0000'}'}]"
.
.
.
respond_to do |format|
  format.html
  format.xml {render :xml => [@subjects,@students,@address].to_xml}
  format.json {render :json => [@subjects,@students,@address].to_json}
end

index.haml:

= gmaps({"map_options" => {"data" => @mapOptions}, "markers" => {"data" => @json}, "circles" => {"data" => @circles} })

现在,最终,我希望能够通过使用ajax请求更改圈子中的地址。

0 个答案:

没有答案