function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Arun KArun K 

Googla map clickable

I am trying to navigate to account detial page when user clicks it.

When I try to hard code the account id from "https://na15.salesforce.com/addrInstances[i].id"  to a001ljsdklsd213.It is navigating to right account but it si not going to detail page when I use "https://na15.salesforce.com/addrInstances[i].id"

 

What I am doing wrong here..

 

 

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

window.location ='https://na15.salesforce.com/addrInstances[i].id';
alert(addresses[i].name);
});

 

Neeraj_ChauriyaNeeraj_Chauriya

Hi,

 

The issue I could see is the URL string your are creating, it should be like:

window.location ='https://na15.salesforce.com/' + addrInstances[i].id;


 And if you do not want to hardcode the SF instance prefix URL then, this should work:

window.location = '/' + addrInstances[i].id;

 

Important :
Hit Kudos if this provides you with useful information and if this is what you where looking for then please mark it as a solution for other's benefit.

 

Arun KArun K

Thanks for the reply.

 

But It didnt solved the issue.

I tried to debug using alerts also

 

below code is giving alert-1 and went to account id and gave alert-2

 alert('1');
                             window.location ='/001i000000AohSE' ;
                             alert('2');

 But when I tried as below code, It is giving alert and not doing anything.

 

window.location = '/' + addrInstances[i].id;
Neeraj_ChauriyaNeeraj_Chauriya

Hi,

 

It should work!

 

Can you please post the exact script you are using and try to alert the generated URL to check whether proper URl is generated or not?

 

alert('/' + addrInstances[i].id);

Arun KArun K

 

 

I gave alert as said but It is not giving alert..

Below is the code that I am using

 

 <script>
                  var addrInstances;
            
                  Visualforce.remoting.Manager.invokeAction
                  (
                    '{!$RemoteAction.RemotingController_differential_pc.getAllAddresses}',
                    function(result, event) 
                    {
                      
                       addrInstances = result;
                      
                       var myLatlng = new google.maps.LatLng(addrInstances[0].Location__Latitude__s,addrInstances[0].Location__Longitude__s);
                    
                       var mapOptions = {
                       zoom: 8,
                       center: myLatlng,
                       mapTypeId: google.maps.MapTypeId.ROADMAP
                      
                        }
                       var map = new google.maps.Map(document.getElementById("map"), mapOptions);
                      // map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds)); 
                       for(var i = 0; i < addrInstances.length; i++)
                        {
                            var currLatLng = new google.maps.LatLng(addrInstances[i].Location__Latitude__s,addrInstances[i].Location__Longitude__s )
                            var marker = new google.maps.Marker({
                            position: currLatLng,
                            map: map,
                            title:addrInstances[i].Name+'\n'+addrInstances[i].Parent_Name__c + '\n'  +addrInstances[i].BillingStreet + '\n'  +addrInstances[i].BillingCity + '\n'  +addrInstances[i].BillingState  
                            });
                       google.maps.event.addListener(marker, 'click', function() {
                              
                             /*  window.location ='https://na15.salesforce.com/addrInstances[i].id';
                               alert(addresses[i].name);*/
                               alert('Hi');
                               alert('/' + addrInstances[i].id);
                            });
                            
                            
                          
                    }
                     
                         }
                         
                  );   
                    
            </script>

 

Neeraj_ChauriyaNeeraj_Chauriya
Have you checked what value addrInstances[i].id is returning? try to debug that.