0
我使用gmaps4rails和我有很多標記,現在當我點擊標記出現infowindow我需要點擊標記,並被重定向到另一個頁面。點擊標記谷歌地圖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 2012-04-23 17:50:44
讓我看看你的整個代碼,沒有它就無法理解。 – apneadiving 2012-04-23 18:24:27
這是我第一次使用rails應用程序,我跟着你的youtube視頻來到這裏,對於初學者的錯誤感到抱歉。 – Ludimila 2012-04-24 19:37:41