1

現在、Rails 3.0.9 と gmaps4rails 0.8.6 を使用しています。

Google マップで https を有効にすると問題が発生します。

私はその解決策を使用しようとしました:

https/SSL で gmaps4rails を使用する

しかし、成功しませんでした。

レイアウト アプリケーションで、この js のインクルード タグを追加しました。

<%= javascript_include_tag "https://maps.google.com/maps/api/js?sensor=false&libraries=geometry" %>
<%= javascript_include_tag "https://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.5/src/infobox.js" %>
<%= javascript_include_tag "gmaps4rails.js" %>
<%= javascript_include_tag "https://google-maps-utility-library-v3.googlecode.com/svn/tags/markerclusterer/1.0/src/markerclusterer_compiled.js" %>

私のコントローラーコード

...
@places = Place.paginate(:page => params[:page], :per_page => 10)
@json = @places.to_gmaps4rails

意見

...
 <div id="mapLocal"> <%= gmaps4rails(@json, true false) %> </div>
...

その後、Google マップは引き続き http で動作します。

ページのソース コード

function gmaps4rails_loadScript() {
  var script = document.createElement("script");
  script.type = "text/javascript";
  script.src = "http://maps.google.com/maps/api/js?sensor=false&libraries=geometry&callback=gmaps4rails_init";
  document.body.appendChild(script);
}

gmaps4rails を gmaps に変更しようとしました。

結果:

Completed 500 Internal Server Error in 54ms


ActionView::Template::Error (undefined method `to_gmaps4rails' for #<String:0xf5d98528>):
    13: <script type="text/javascript" charset="utf-8">
    14: function gmaps4rails_init() {
    15:     <% #true is passed here to trigger map initialization %>
    16:     <%=raw options.to_gmaps4rails(true) %>
    17: }
    18:   
    19: function gmaps4rails_loadScript() {
  app/views/places/index.html.erb:4:in `_app_views_places_index_html_erb___671263203__86055108_0'

そこで、gem をアップグレードすることにしました (古いバージョンは ssl をサポートしていないのでしょうか?)。

0.8.6 から 1.1.4 にアップグレードした後、変更されていない基本的なコードではマップが生成されません。

  <div id="mapLocal"> <%= gmaps4rails(@json) %> </div>

Firebug で js ログを確認したところ、エラーが返されました

Gmaps4RailsGoogle is not defined
Gmaps.map = new Gmaps4RailsGoogle(); 
4

1 に答える 1