Inserting a rails link into a Google Maps infowindow

Posted by Sonia on Stack Overflow See other posts from Stack Overflow or by Sonia
Published on 2010-06-13T10:10:22Z Indexed on 2010/06/13 10:12 UTC
Read the original article Hit count: 286

Filed under:
|
|

Hi,

I would like to insert a link into the Google Maps InfoWindow to show more information about the point the user has clicked on in my rails app. My current code:

$.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 + "<br>[link]";
    map.openInfoWindowHtml(point, info);
  });
}

I would like the link to take the user to the page for that marker (ie. /places/id), but am unsure of how to go about this...any help would be much appreciated!

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby-on-rails