0

私はgmaps4railsを使用しています。マーカーをクリックするとinfowindowが表示されます。マーカーをクリックして別のページにリダイレクトする必要があります。マーカーをクリックするGoogleマップapiとgmaps4railsを使用してページを変更

コントローラー:

def index 
@postos = Posto.all 
@markers = Posto.all.to_gmaps4rails 

@json = Posto.all.to_gmaps4rails do |posto, marker| 
marker.json "\"id\": #{posto.id}" 
end 
    respond_to do |format| 
    format.html # index.html.erb 
    format.json { render json: @postos } 
    end 
end 

Javascriptを:

google.maps.event.addListener(marker_container.serviceObject, 'click', @openInfoWindow(currentMap, marker_container.infowindow, marker_container.serviceObject)) 

答えて

0

さて、あなたはほとんどOKですが、あなたのjsの関数は対象外のようで、あなたのような何かをコーディングする必要があります。

google.maps.event.addListener(marker_container.serviceObject, 'click', function() { your_code_to_change_page_depending_on_the_marker }) 
+0

を答えに記載されているコード行を追加すると、次のエラーが発生します。SyntaxError:予約語 "function" – Ludimila

+0

あなたの全体のコードを表示、それなしで理解することはできません。 – apneadiving

+0

これは私の最初のレールのアプリケーションです、私はあなたのYouTubeのビデオをここに来る、ミス初心者のために申し訳ありませんでした。 – Ludimila

関連する問題