You need to sign in to do that
Don't have an account?
Carter85
Need assistance passing the index of map items in a list as a variable to marker icon parameter on VF page
I have having difficulty getting the index of a list item contained within the <apex:map> tag
I am trying to access the index of a list contained within the map tag on my VF page to pass to a resource call in order to assign custom map markers to each line item because we want more varied markers than the standard. My VF snippet it thus:
And my apex snippet controlling it is here:
All I really want to do is to pass the index to the icon parameter here:
<apex:mapMarker title="{!apt.item.Subject}" position="{!apt.item.loc}" icon="{!URLFOR($Resource.GoogleMarkers,!apt.counter+'.png')}">
I've tried just using apex:variable or apex:param but apparently they're prohibited from use anywhere within the map markup.
This is how far I've gotten to try and bypass that. However, when I try to save I get this error: "Incorrect parameter type for function 'not()'. Expected Boolean, received Number" so I'm a bit stuck on how I could go about getting past assigning the counter value so it doesn't think I'm trying to do a comparison function, because any other way to try to save it gives me a syntax error, so any suggestions would be appreciated, or if anyone knows of a simpler way to do it overall in order to individually style each map marker and can point me in the right direction that would be great.
I am trying to access the index of a list contained within the map tag on my VF page to pass to a resource call in order to assign custom map markers to each line item because we want more varied markers than the standard. My VF snippet it thus:
<apex:pageBlockSection title="Service Area For {!companyName}"> <apex:map width="1300px" height="600px" mapType="roadmap" center="{!mapCenter}"> <apex:repeat value="{!locations}" var="apt"> <apex:mapMarker title="{!apt.item.Subject}" position="{!apt.item.loc}" icon="{!URLFOR($Resource.GoogleMarkers, + '.png')}"> <apex:mapInfoWindow > <apex:outputPanel layout="block" style="font-weight: bold;"> <apex:outputText >{!apt.item.Subject}</apex:outputText> </apex:outputPanel> <apex:outputPanel layout="block"> <apex:outputText >{!apt.item.loc}</apex:outputText> </apex:outputPanel> <apex:outputPanel layout="block"> <apex:outputText >{!apt.item.ServiceTime}</apex:outputText> </apex:outputPanel> </apex:mapInfoWindow> </apex:mapMarker> </apex:repeat> </apex:map>
And my apex snippet controlling it is here:
public PageReference specificDate(){ try{ dte = date.parse(dteInput); } catch(Exception E){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Date formatted incorrectly. Check entry and try again.')); } locations = new list<mapWrapper>(); names = new Map<String, String>(); integer i = 0; integer counter = 1; for(Event evnt: [SELECT Id, Subject, Location, Service_Time__c, StartDateTime FROM Event WHERE OwnerID IN: users AND RecordType.ID = '01213000001CDUu' AND ActivityDate =: dte ORDER BY StartDateTime ASC]){ names.put(evnt.Subject + ': ' + evnt.Service_Time__c,evnt.Location); mapEvent myMap = new mapEvent(); myMap.Subject = evnt.subject; myMap.ServiceTime = evnt.Service_Time__c; myMap.loc = evnt.Location; myMap.icon = i; //locations.add(myMap); locations.add(new mapWrapper(myMap, counter)); counter = counter + 1; i++; } //if(locations.size() > 0){ // mapCenter = locations[0].loc; // } // else{ mapCenter = companyAddr; // } return null; } class mapWrapper { public Integer counter {get;set;} public mapEvent item { get; set;} public mapWrapper(mapEvent item, Integer counter) { this.item = item; this.counter = counter; } }
All I really want to do is to pass the index to the icon parameter here:
<apex:mapMarker title="{!apt.item.Subject}" position="{!apt.item.loc}" icon="{!URLFOR($Resource.GoogleMarkers,!apt.counter+'.png')}">
I've tried just using apex:variable or apex:param but apparently they're prohibited from use anywhere within the map markup.
This is how far I've gotten to try and bypass that. However, when I try to save I get this error: "Incorrect parameter type for function 'not()'. Expected Boolean, received Number" so I'm a bit stuck on how I could go about getting past assigning the counter value so it doesn't think I'm trying to do a comparison function, because any other way to try to save it gives me a syntax error, so any suggestions would be appreciated, or if anyone knows of a simpler way to do it overall in order to individually style each map marker and can point me in the right direction that would be great.
If not - you might try.... icon="{!URLFOR($Resource.GoogleMarkers)}{!apt.counter}.png" ...