TransWikia.com

Error when setting "rendered" attribute on apex:mapMarker

Salesforce Asked on December 12, 2021

I am trying to show/hide some map markers on an <apex:map> by assigning a boolean value coming from an Apex attribute to the rendered tag. However, I am receiving a compile error on save:

Literal value is required for attribute rendered in in OfficeMap at line 26 column 6

The code:

<apex:mapMarker title="{!office.Name}" position="{!office.geo}" rendered="{!office.isShown}"/>

However, if I decide to put the value as a string, I can compile my Visualforce successfully:

<apex:mapMarker title="{!office.Name}" position="{!office.geo}" rendered="true"/>

Any idea if this is a known bug, or if there’s an alternative?

2 Answers

Definitely a bug. Here's a simple, ugly workaround:

Instead of

<apex:map>
    <apex:mapMarker title="Home Address" rendered="{!hasHomeAddress}"/>
    <apex:mapMarker title="Work Address"/>
</apex:map>

You can do:

<apex:map rendered="{!hasHomeAddress}">
    <apex:mapMarker title="Home Address"/>
    <apex:mapMarker title="Work Address"/>
</apex:map>
<apex:map rendered="{!NOT(hasHomeAddress)}">
    <apex:mapMarker title="Home Address"/>
    <apex:mapMarker title="Work Address"/>
</apex:map>

Answered by caleb.breckon on December 12, 2021

Rather than changing your application logic as suggested in the comment, an other workaround is using layoutPanel wich does not result in additional HTML if you set the display attribute to 'none'

<apex:outputPanel id="thePanel" layout="none" rendered="{!office.isShown}">
    <apex:mapMarker title="{!office.Name}" position="{!office.geo}" />
</apex:outputPanel>

Answered by Samuel De Rycke on December 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP