+ Start a Discussion
Nick KeehanNick Keehan 

VF Page - Google Map Conditional displaying markers

Hey Guys.

Does anyone know how to conditionally display markers on a google map? e.g. User.Location.CreatedDate > 13/09/2016?

i have below on the user layout which could have multiple locations records.

any direction would be great.
<apex:page standardController="User">

  <!-- This page must be accessed with an Account Id in the URL. For example: 
       https://<salesforceInstance>/apex/NearbyContacts?id=001D000000JRBet -->
  
  <apex:pageBlock >
    <apex:pageBlockSection title="locations For {! User.Name }">
    
     <apex:dataList value="{! User.Locations__r }" var="location">
       <apex:outputText value="{! location.Lead_Address__c}" />
     </apex:dataList> 
    
    </apex:pageBlockSection>
  </apex:pageBlock>
   
  <apex:map width="1200px" height="1000px" mapType="roadmap"
    center="-43.5350071 172.64177229999999">


        <apex:repeat value="{! User.Locations__r }" var="location">
        <apex:mapMarker title="{! location.Name }" position="{!contact.Location_Text__c}"/>
        </apex:repeat>

  </apex:map>
  </apex:page>

 
Best Answer chosen by Nick Keehan
karthikeyan perumalkarthikeyan perumal

All Answers

karthikeyan perumalkarthikeyan perumal
Hello Nick, 

use Below code to solve your issue. 
 
<apex:mapMarker title="{! location.Name }" position="{!contact.Location_Text__c}" rendered="{!If(User.Location.CreatedDate > 13/09/2016 ,true,false) }">

Hope it will help you. Mark Best ANSWER if its work for you.
Thanks
karthik
 
Nick KeehanNick Keehan
Thanks Karthik.
Getting a error with the new mapmarker you have above.
": Literal value is required for attribute rendered in <apex:mapMarker> in locuser at line 21 column 177"

Any suggestions?
Nick KeehanNick Keehan
Thanks Karthik.
Getting a error with the new mapmarker you have above.
": Literal value is required for attribute rendered in <apex:mapMarker> in locuser at line 21 column 177"

Any suggestions?
karthikeyan perumalkarthikeyan perumal
Hello Nick, 

Create new Custom Controller   in that add the method called 
 
public boolean isDisplay {get;set;}

Public Boolean ConditionalDisplay()
{
    //Get the date using Query 
    
     if(User.Location.Createddate > '201609/03')
       {
        isDisplay=True;
       }
       else
        {
          isDisplay=fasle;
        }

return isDisplay;
}
and modify the below line. 
<apex:mapMarker title="{! location.Name }" position="{!contact.Location_Text__c}" rendered="{!isDisplay}"/>
Hope it will help you.
Thanks
karthik

 
karthikeyan perumalkarthikeyan perumal
This was selected as the best answer