0

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))
4

1 に答える 1

0

さて、あなたはほとんど大丈夫ですが、あなたのjs関数は主題から外れているようです、あなたは次のようなものをコーディングする必要があります:

 google.maps.event.addListener(marker_container.serviceObject, 'click', function() { your_code_to_change_page_depending_on_the_marker })
于 2012-04-21T17:43:42.077 に答える