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))
を答えに記載されているコード行を追加すると、次のエラーが発生します。SyntaxError:予約語 "function" – Ludimila
あなたの全体のコードを表示、それなしで理解することはできません。 – apneadiving
これは私の最初のレールのアプリケーションです、私はあなたのYouTubeのビデオをここに来る、ミス初心者のために申し訳ありませんでした。 – Ludimila