将rails链接插入Google Maps infowindow

我想在Google Maps InfoWindow中插入一个链接,以显示用户在我的rails应用中点击的点的更多信息。 我目前的代码:

$.getJSON("/places", function(json) { if (json.length > 0) { for (i=0; i<json.length; i++) { var place = json[i]; addLocation(place); } } }); function addLocation(place) { var point = new GLatLng(place.lat, place.lng); var marker = new GMarker(point); map.addOverlay(marker); GEvent.addListener(marker, "click", function() { var info = place.name + "
[link]"; map.openInfoWindowHtml(point, info); }); }

我想链接将用户带到该标记的页面(即./place / id),但我不确定如何去做…任何帮助将不胜感激!

这是我如何做到的。 (为周日懒惰复制和粘贴,但它很简单,可以遵循)

 // inline javascript defines the places allplaces = [ [ <%- @facets.each do |facet| -%> <%- if facet.latitude && facet.longtitude -%> ['<%=h escape_javascript(facet_article(facet).title) -%>', 'be', <%= facet.latitude -%>, <%= facet.longtitude -%>, '<%= facet.photo.blank? ? "" : facet.photo.photo.url(:article) -%>', '<%=h escape_javascript(truncate(facet_article(facet).body, :length => 100, :omission => "...")) -%>', '<%=h article_url(:id => facet_article(facet)) -%>'] <%= (",") unless facet == @facets.last %> <%- end -%> <%- end -%> ] ]; // separate static external js file interacts with google map api function placeMarkers() { var shadow, html, k=0, marker; for(i=0;i' + place[0] +' 
{2}
'; markers[k].html = stringFormat(html, marker.title,place[4],place[5]); markers[k].infoWindow = new google.maps.InfoWindow({ content: markers[k].html, maxWidth: '280' }); markers[k].openlistener = makeClosure(k, markers[k].marker); k++; } } }

我发现了另一种方法可以在概念上更容易 – 我可以使用json数据包中输出的位置id为我的map.js文件中的每个位置构建适当的链接:

 Show more!" 

这似乎工作正常!