Uncaught RangeError: Maximum call stack size exceeded

Uncaught RangeError: Maximum call stack size exceeded

所以,我正在尝试实现一项功能,让用户在登录时搜索供应商。我正在使用地理编码器和 gmap4rails。但是,当我设置地图并尝试 运行 应用程序时,地图根本不显示。

这是我的观点:

    <%= form_tag dashboard_path, :method => :get do %>
<div class= "row">
  <p>
    <%= text_field_tag :search, params[:search], class: "col-md-4"%>
    <%= submit_tag "Search Near", class: "btn btn-info", :name => nil  %>
  </p>
  </div>
<% end %>

<div style='width: 800px;'>
  <div id="map" style='width: 9000px; height: 500px;'></div>
</div>

<script type="text/javascript">
  handler = Gmaps.build('Google');
  handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){
  markers = handler.addMarkers(<%=raw @hash.to_json %>);
  handler.bounds.extendWith(markers);
  handler.fitMapToBounds();
  handler.getMap().setZoom(15);

});

</script>

仪表板视图的控制器:

def dashboard
    if params.empty?
        gflash notice: "you cant search without a term"
        redirect_to "/"

    elsif params[:search].present?
        @vendors = Vendor.near(params[:search], 50)
        @hash = Gmaps4rails.build_markers(@vendors) do |vendor, marker|
            marker.lat vendor.latitude
            marker.lng vendor.longitude
            marker.infowindow vendor.discount_info
            marker.picture ({
            "url" => "assets/marker.png",
            "width" => 32,
            "height" => 32})
       end
    else
        @vendors = Vendor.all
        @hash = Gmaps4rails.build_markers(@vendors) do |vendor, marker|
            marker.lat vendor.latitude
            marker.lng vendor.longitude
            marker.picture ({
            "url" => "assets/marker.png",
            "width" => 32,
            "height" => 32})

        end
    end

在开发模式下打开浏览器登录web控制台报错是:

Uncaught RangeError: Maximum call stack size exceeded

我不确定是什么导致了这个错误,我已经适当地设置了地图大小。

解决了这个问题,代码进入无限循环导致gmap在搜索参数为空的情况下崩溃,它不知道在哪里设置标记,所以我只为这种情况设置经度和纬度。