Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've set up an embedded google map in my VF page that displays all records within x km. I've added info windows to each of these, with the aim that the user can click on the link in the infowindow and it'll redirect them to that records detail page. I'm using:

var infoWindow = new google.maps.InfoWindow({
            content: '<div style="font-size: 8pt;">' + '<b>' + siteName + '</b>' + '</br>' + status + '</br><a href="' + siteLink + '">Load Site</a>'

where siteLink is the id of the clicked marker. However, this redirects me to:

rather than:

and so gives me an error. Any ideas how to get round this?

share|improve this question
up vote 1 down vote accepted

Did you try "/siteName" (a leading slash)? That would usually get a link to the root URL, ignoring the /apex path.

share|improve this answer
straightforward... thanks. – paul Jan 4 '13 at 9:52
Can you share the code since I am trying to achieve the same results? Thanks Roger Francis – Roger Francis Oct 25 '14 at 12:02

        <style type="text/css">
              html { height: 100% }
              body { height: 100%; margin: 0; padding: 0 }
              #map-canvas { height: 100% }
            <script src=""></script>
            var map;

            function initialize() {
                var mapOptions = {
                    center: new google.maps.LatLng(21.0000, 78.0000),
                    zoom: 5
                map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);


            google.maps.event.addDomListener(window, 'load', initialize);

            function loadHotels() {
            var contentString = null;
            var count = 0;
            function(result, event){
            if (event.status) {
                for (var i=0; i<result.length; i++) {
                    var id = result[i].Id;
                    var name = result[i].Name;
                    var addr= result[i].Address__c;
                    var lat = result[i].Location__Latitude__s;
                    var lng = result[i].Location__Longitude__s;

                    contentString = 'Name : '+result[i].Name +'<br/>'+'Address : '+ result[i].Address__c+' <br/> '+'<a href="/'+ id + '" target="_blank">Go To The Detail Page</a>';

                   // alert(contentString);
                    addMarker(id,lat, lng,contentString);

            } else {
        {escape: true}


        function addMarker(id,lat,lng,contentString) {
       // alert('Map'+contentString);
        var marker = new google.maps.Marker({
        position: new google.maps.LatLng(lat,lng),
        map: map,
        title: name 

   // var infowindow = null;
    //var details = 'The details of the rep</br>'+name+'</br>'+addr+'</br>'+id;
   var infowindow = new google.maps.InfoWindow({content:contentString,maxWidth:2000});
  // alert(infowindow);

google.maps.event.addListener(marker, 'click', function() {

    // = '/' + id;
   // infowindow.setContent(contentString);,marker);


} loadHotels();

      <div id="map-canvas"/>


global with sharing class SalesRep{

global static List<SalesRep__c> findAll() {
    return [SELECT Id,Name,Address__C,Location__Latitude__s,Location__Longitude__s FROM SalesRep__c];


I think may be this will help you.

share|improve this answer
Can you please add some explanations about your code ? – SF_user Nov 7 '14 at 11:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.