GMaps 在第一次打开页面时不加载,重新加载后它可以工作

GMaps don't load at first open page, after reload it works

我使用 gmaps4rails gem 地图并不总是在第一个页面打开时加载,重新加载后它可以工作。

所以,我的代码 show.html.haml

    %script{:src => "//maps.google.com/maps/api/js?v=3.13&sensor=false&libraries=geometry", :type => "text/javascript"}
    %script{:src => "//google-maps-utility-library-v3.googlecode.com/svn/tags/markerclustererplus/2.0.14/src/markerclusterer_packed.js", :type => "text/javascript"}

........

    .col-lg-8.col-sm-8.col-md-8.col-xs-12
        #map
        %br/

......

    :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(16);
        });

parks_controller.rb

  def show
    set_park
    @hash = Gmaps4rails.build_markers(@park) do |park, marker|
      marker.lat park.latitude
      marker.lng park.longitude
      marker.infowindow park.address
    end

index.html.haml

 - @parks.each do |park|
    .map_index
      .image_wrapper
        = image_tag "http://maps.google.com/maps/api/staticmap?size=400x200&sensor=false&zoom=16&markers=#{park.latitude}%2C#{park.longitude}", class: "map_image"
      %h2
        = link_to park.title, park

工作应用程序 - https://geoparks.herokuapp.com/

请告诉我要更改或添加到代码中的内容?

我只是添加到地图页面参数的链接

'data-no-turbolink' => true

代码 = link_to p.title, parkindex.html.haml 更改为

= link_to park.title, park, 'data-no-turbolink' => true