You need to sign in to do that
Don't have an account?

Exception on apex:map when re-rendering
Hi,
When re-rendering the parent element of a apex:map, I get this error message displayed instead of the map:
"HTTP ERROR 401 Problem accessing /maps/JavascriptHandler. Reason: Unauthorized Powered by Jetty://".
It works fine on the first loading. Any idea?
When re-rendering the parent element of a apex:map, I get this error message displayed instead of the map:
"HTTP ERROR 401 Problem accessing /maps/JavascriptHandler. Reason: Unauthorized Powered by Jetty://".
It works fine on the first loading. Any idea?
I found the cause of that exception and it is because there is a limit for 10 geocoding requests per map. I was able to work around this issue calculating the geocode first and then setting the latitude and longitude in the postion.
However this is working fine in my sandbox (winter 16), but I am not getting the same result in production, under this environment I have to set limit 10 in the SOQL.
Sandbox:---------
public PageReference Nearby()
{
rend = true;
try{
objAccounts = new list<Account>();
objAccounts.addAll([SELECT Name,BillingStreet,BillingCity,BillingPostalCode,
BillingCountry,Phone,BillingState,Location__Latitude__s,Location__Longitude__s FROM Account
Where BillingState =: centerstate and Location__Latitude__s <> null order by Name ]);
}catch(Exception ex){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'
+ex.getMessage()));
}
return null;
}
Production:--------
public PageReference Nearby()
{
rend = true;
try{
objAccounts = new list<Account>();
objAccounts.addAll([SELECT Name,BillingStreet,BillingCity,BillingPostalCode,
BillingCountry,Phone,BillingState,Location__Latitude__s,Location__Longitude__s FROM Account
Where BillingState =: centerstate and Location__Latitude__s <> null order by Name limit 10 ]);
}catch(Exception ex){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'
+ex.getMessage()));
}
return null;
}
Thanks
Can you please also post the Visualforce page code, or at least the part that is related to the map and map re-rendering?
<apex:outputPanel id="Map" >
<apex:pageBlockSection Title="GRCS Fund Managers Location Center Point: {!city} {!state} {!country} " rendered="{!IF(rend, true , false)}" columns="1" collapsible="False">
<apex:map width="1595px" height="500px" mapType="roadmap" center="{!city},{!state},{!country}">
<!-- center="{latitude: 40.7638848, longitude: -73.9707834}"> -->
<!-- Add markers for account -->
<apex:repeat value="{! objAccounts }" var="ct">
<apex:mapMarker title="{! ct.Name }" position="{latitude:{!ct.Location__Latitude__s},longitude:{!ct.Location__Longitude__s}}">
</apex:mapMarker>
</apex:repeat>
</apex:map>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
here is the controller:
<apex:page Controller="GRCSAccountList">
<apex:pagemessages id="ErrMsg"></apex:pagemessages>
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons location="top">
<apex:commandButton value="Nearby Accounts/Fund Managers" action="{!Nearby}" id="theButton" rerender="Map,ErrMsg"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Enter Center Location" columns="1" collapsible="False">
<apex:pageblockSectionItem >
<apex:outputLabel value="Country"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!country}">
<apex:selectOptions value="{!objcountries}"/>
<apex:actionSupport event="onchange" reRender="a,c"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="State"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!state}" id="a">
<apex:selectOptions value="{!states}"/>
<apex:actionSupport event="onchange" reRender="c"/>
</apex:selectList>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:outputLabel value="City"/>
</apex:pageblockSectionItem>
<apex:pageblockSectionItem >
<apex:selectList size="1" value="{!City}" id="c" >
<apex:selectOptions value="{!Cities}"/>
</apex:selectList>
</apex:pageblockSectionItem>
</apex:pageBlockSection>
<apex:outputPanel id="Map" >
<apex:pageBlockSection Title="GRCS Fund Managers Location Center Point: {!city} {!state} {!country} " rendered="{!IF(rend, true , false)}" columns="1" collapsible="False">
<apex:map width="1595px" height="500px" mapType="roadmap" center="{!city},{!state},{!country}">
<!-- center="{latitude: 40.7638848, longitude: -73.9707834}"> -->
<!-- Add markers for account contacts -->
<apex:repeat value="{! objAccounts }" var="ct">
<apex:mapMarker title="{! ct.Name }" position="{latitude:{!ct.Location__Latitude__s},longitude:{!ct.Location__Longitude__s}}">
</apex:mapMarker>
</apex:repeat>
</apex:map>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
-------------------------------------------------< Controller >-------------------------------------------------------------
public with sharing class GRCSAccountList {
public list<Account> objAccounts {get;set;}
public string country {get;set;}
public string state {get;set;}
public string City {get;set;}
public string query {get;set;}
public boolean rend {get;set;}
public GRCSAccountList()
{}
public PageReference Nearby()
{ string acsubtype = 'FOF Public Market Alternative';
query = 'SELECT Name,BillingStreet,BillingCity,BillingPostalCode,BillingCountry,Phone,BillingState,Location__Latitude__s,Location__Longitude__s FROM Account Where Location__Latitude__s <> null and AC_Sub_Type__c = \'' + acsubtype +'\'';
rend = true;
try{
objAccounts = new list<Account>();
if (country != 'None' && country != null)
{ query = query + ' and BillingCountry =: country';}
if (state != 'None' && state != null)
{ query = query + ' and BillingState =: state';}
if (city != 'None' && city != null)
{ query = query + ' and BillingCity =: city';}
system.debug('Query -->' + query);
objAccounts = (Database.query(query));
}catch(Exception ex){
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error:'
+ex.getMessage()));
}
return null;
}
public list<SelectOption> getobjcountries()
{
List<SelectOption> ccountry = new List<SelectOption>();
ccountry.add(new SelectOption('None','--- Select ---'));
list<AggregateResult> results = [SELECT BillingCountry FROM Account where BillingCountry != null and AC_Sub_Type__c = 'FOF Public Market Alternative' group by BillingCountry];
system.debug(country);
for (AggregateResult cont : results)
{
ccountry.add( new SelectOption(String.valueof(cont.get('BillingCountry')),String.valueof(cont.get('BillingCountry'))));
}
return ccountry;
}
public List<SelectOption> getStates()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--- Select ---'));
if(country != null && country != 'None')
{
list<AggregateResult> results = [SELECT BillingState FROM Account where BillingState != null and BillingCountry=:country and AC_Sub_Type__c = 'FOF Public Market Alternative' group by BillingState];
for (AggregateResult cont : results)
{
options.add( new SelectOption(String.valueof(cont.get('BillingState')),String.valueof(cont.get('BillingState'))));
}
}
return options;
}
public List<SelectOption> getCities()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--- Select ---'));
if (state != 'None' && state != null)
{ system.debug('City---->' + city);
list<AggregateResult> results = [SELECT BillingCity FROM Account where BillingCity != null and BillingState =: state and BillingCountry=:country and AC_Sub_Type__c = 'FOF Public Market Alternative' group by BillingCity];
for (AggregateResult cont : results)
{
options.add( new SelectOption(String.valueof(cont.get('BillingCity')),String.valueof(cont.get('BillingCity'))));
}
}
return options;
}
}
What is your browser encoding set to when you run into this issue?
Thanks.
The error can occur when using account name or site in either a mapMarker or mapInfoWindow.
Sample code:
<apex:map width="600px" height="400px" mapType="roadmap" rendered="{!isCalJobs}">
<apex:repeat var="mapjob" value="{!calJobs}">
<apex:mapMarker title="{!mapjob.Account__r.Name} - {!mapjob.Account__r.Site}" position="{latitude:{!mapjob.Account__r.geopointe__Geocode__r.geopointe__Latitude__c}, longitude:{!mapjob.Account__r.geopointe__Geocode__r.geopointe__Longitude__c}}" rendered="true">
<apex:mapInfoWindow >
<apex:outputPanel layout="block">
<apex:outputText value="{!mapjob.Account__r.Name} - {!mapjob.Account__r.Site}"/>
</apex:outputPanel>
<apex:outputPanel layout="block">
<apex:outputText value="{!mapjob.Account__r.ShippingCity}, {!mapjob.Account__r.ShippingState}"/>
</apex:outputPanel>
<apex:outputPanel layout="block">
<apex:outputText value="Dates: {0,date,MM/dd/yy} - {1,date,MM/dd/yy}">
<apex:param value="{!mapjob.Start_Date__c}"/>
<apex:param value="{!mapjob.End_Date__c}"/>
</apex:outputText>
</apex:outputPanel>
<apex:outputPanel layout="block">
<apex:outputText value="Days: {!mapjob.Billing_Days__c}"/>
</apex:outputPanel>
<apex:outputPanel layout="block">
<apex:outputText value="Job No.: {!mapjob.Name}"/>
</apex:outputPanel>
<apex:outputPanel layout="block">
<apex:outputText value="Status: {!mapjob.Status__c}"/>
</apex:outputPanel>
</apex:mapInfoWindow>
</apex:mapMarker>
</apex:repeat>
</apex:map>
To reproduce the issue:
Jeff,
I submitted the issue on your behalf. Here is a link to it: https://success.salesforce.com/issues_view?id=a1p300000008c2YAAQ. You can subscribe to this issue by clicking "This Issue Affects me" button.
Thank you!