Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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:

https://c.cs7.visual.force.com/apex/a0HM0000005AQFLMA4

rather than:

https://c.cs7.visual.force.com/a0HM0000005AQFLMA4

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

share|improve this question

2 Answers 2

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 at 12:02

    <head>
        <style type="text/css">
              html { height: 100% }
              body { height: 100%; margin: 0; padding: 0 }
              #map-canvas { height: 100% }
        </style>
            <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
            <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);

        </script>
        <script>
            function loadHotels() {
            var contentString = null;
            var count = 0;
            Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.SalesRep.findAll}',
            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);
                    count++;
                }

            } else {
                alert(event.message);
            }
        },
        {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() {

    //window.top.location = '/' + id;
    //infowindow.open(map,marker);
   // infowindow.setContent(contentString);
    infowindow.open(map,marker);

});

} loadHotels();

    </head>
    <body>
      <div id="map-canvas"/>
    </body>

controller:

global with sharing class SalesRep{

@RemoteAction
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
1  
Can you please add some explanations about your code ? –  SF_user Nov 7 at 11:22

Your Answer

 
discard

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.