Reputation: 3451
I use geocoder
in my app and to show the markers on the map, using json
.
it look like this:
...
$.get("get_organizations.json", function( data ) {
$.each( data, function( index, organization ) {
var organizationLatLng = new google.maps.LatLng( organization.latitude, organization.longitude );
var infowindow = new google.maps.InfoWindow({content: contentString});
var contentString = organization.title;
var marker = new google.maps.Marker({
position: organizationLatLng,
map: map,
title: organization.title
});
and all works fine, but I want to link in infowindow
and need solution in this question!
if I change value of contentString
, I don't know what should be in href
of link
var contentString = '<a href="???">' + organization.title + '</a>';
link should redirect to the selected organization in infowindow
!
thanks in advance!
Upvotes: 1
Views: 372
Reputation: 44360
Assume you have a REST route and the relative path to an organization looks like /organizations/1234
where 1234
it is id
of organization:
var orgId = organization.id;
var orgTitle = organization.title;
var contentString = '<a href="/organizations/' + orgId +">' + orgTitle + '</a>';
Upvotes: 2