+ Start a Discussion
David Roberts 4David Roberts 4 

redirect causes map to fail

I have a page that gets criteria including current location using javascript.
I then construct a url with parameters and launch another page using apex redirect to show a map - but it doesn't draw the map.
Yet, when I launch the page directly using the constructed URL, the map appears.
When sandbox laucnches it, a complex URL is displayed.
What is happenning and how can I remedy it?
I have festooned my code with console logs and system logs but can't see why it fails.
Please help.
Shiva RajendranShiva Rajendran
Hi David,
Please do share the code to help you better.
Thanks and Regards,
Shiva RV
David Roberts 4David Roberts 4
Will do. Thanks.
David Roberts 4David Roberts 4
Hi Shiva,

It turns out to be at a fundamental level.
I added a simple VF Page and launched it from a button I added to the account page.
The URL is bizarre: 
When this in turn launches another page, the URL is corrupted.

Instead of "/https://mysandboxname--c.cs87.visual.force.comapex/DrawMap?lat=37.77493&lon=-122.419416"

The URL= "https://mysandboxname--c.cs87.visual.force.com/apex/PageOpenedFromButton?id=0018E00000VmZfDQAV&isdtp=p1"
it attempts to open an account page (I think)..

The system debug shows correct URL: launchMap with /apex/DrawMap?lat=37.77493&lon=-122.419416

My code is:

Page Opened from button VF Page:
<apex:page standardcontroller="account" extensions="LaunchMapController" > <apex:form >
<apex:CommandLink action="{!launchAnotherPage}" Value="Launch Another Page..."  target="_blank"/>
</apex:form> </apex:page>

Function from controller:

public PageReference launchAnotherPage(){
     gotLat = '37.77493';
     gotLon = '-122.419416';        
    pageref = '/apex/DrawMap?lat='+gotLat + '&lon='+ gotLon;    
    system.debug('launchMap with '+pageref);
        PageReference redirect = new PageReference(pageref); 
        return redirect;

Can you suggest how to resolve this?

Many thanks.