You need to sign in to do that
Don't have an account?
Issues wih multiple location map
I am creating a map that pinpoints multiple locations (multiple locations in a MSA). The map involves two custom objects: Markets (MSA) and Properties. I have created the Visualforce Page and a related extension (both included below). The output should be split into two sections: the first (left) will be a list of the properties in the MSA, and the second block (right) will be the map itself. The VF Page and the extension compile without issue. When I run the page for an MSA value, the list appears on the left; however, the map does not appear. I must be missing something.
Visualforce Page
<apex:page sidebar="false" showHeader="false" standardController="Market__c" extensions="MSAProperty" >
<!-- This page must be accessed with an Market Id in the URL. For example:
https://cs41.salesforce.com/apex/rrmultipropmap?id=a1255000002hr4G -->
<apex:pageBlock >
<apex:pageBlockSection Title="Properties in {!Market__c.Name} MSA">
<apex:pageBlockTable value="{!mprops}" var="mp">
<apex:column value="{!mp['Name']}"/>
<apex:column value="{!mp['Address__c']}"/>
<apex:column value="{!mp['City__c']}"/>
<apex:column value="{!mp['State__c']}"/>
<apex:column value="{!mp['Zip__c']}"/>
<apex:map width="600px" height="400px" mapType="roadmap"
center="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{mp.Zip__c}">
<apex:repeat value="{!mprops}" var="mp">
<apex:mapMarker title="{! mp.Name }"
position="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{mp.Zip__c}"/>
</apex:repeat>
</apex:map>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Apex Controller Extension
/*Controller class for the Multimktmap visualforce page used inline on Market layouts
to show only active Units related to the Property
*/
public class MSAProperty{
public MSAProperty() {
}
public List<Property__c> mprops {get;set;}
public MSAProperty(ApexPages.StandardController cont) {
String ID = cont.getId();
mprops = [Select Name, Address__c, City__c, State__c, Zip__c
from Property__c
where Market__c = :cont.getId()];
}
}
Visualforce Page
<apex:page sidebar="false" showHeader="false" standardController="Market__c" extensions="MSAProperty" >
<!-- This page must be accessed with an Market Id in the URL. For example:
https://cs41.salesforce.com/apex/rrmultipropmap?id=a1255000002hr4G -->
<apex:pageBlock >
<apex:pageBlockSection Title="Properties in {!Market__c.Name} MSA">
<apex:pageBlockTable value="{!mprops}" var="mp">
<apex:column value="{!mp['Name']}"/>
<apex:column value="{!mp['Address__c']}"/>
<apex:column value="{!mp['City__c']}"/>
<apex:column value="{!mp['State__c']}"/>
<apex:column value="{!mp['Zip__c']}"/>
<apex:map width="600px" height="400px" mapType="roadmap"
center="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{mp.Zip__c}">
<apex:repeat value="{!mprops}" var="mp">
<apex:mapMarker title="{! mp.Name }"
position="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{mp.Zip__c}"/>
</apex:repeat>
</apex:map>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
Apex Controller Extension
/*Controller class for the Multimktmap visualforce page used inline on Market layouts
to show only active Units related to the Property
*/
public class MSAProperty{
public MSAProperty() {
}
public List<Property__c> mprops {get;set;}
public MSAProperty(ApexPages.StandardController cont) {
String ID = cont.getId();
mprops = [Select Name, Address__c, City__c, State__c, Zip__c
from Property__c
where Market__c = :cont.getId()];
}
}
So you need to pull out the map from the pageBlockTable, so I think you meant you have your page look like this.
All Answers
Also not sure if you meant to have a repeat inside of your pageBlockTable. Both are looping on the same list and using the same var alias "mp".
<apex:page sidebar="false" showHeader="false" standardController="Market__c" extensions="MSAProperty" >
<!-- This page must be accessed with an Market Id in the URL. For example:
https://cs41.salesforce.com/apex/rrmultipropmap?id=a1255000002hr4G -->
<apex:pageBlock >
<apex:pageBlockSection Title="Properties in {!Market__c.Name} MSA">
<apex:pageBlockTable value="{!mprops}" var="mp">
<apex:column value="{!mp['Name']}"/>
<apex:column value="{!mp['Address__c']}"/>
<apex:column value="{!mp['City__c']}"/>
<apex:column value="{!mp['State__c']}"/>
<apex:column value="{!mp['Zip__c']}"/>
<apex:map width="600px" height="400px" mapType="hybrid"
center="{!Market__c.Address__c},{!Market__c.City__c},{!Market__c.State__c}">
<apex:repeat value="{!mprops}" var="mp">
<apex:mapMarker title="{! mp.Name }"
position="{!mp.Address__c},{!mp.City__c},{!mp.State__c},{!mp.Zip__c}"/>
</apex:repeat>
</apex:map>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
And the Apex Controller extension remains the same:
/*Controller class for the Multimktmap visualforce page used inline on Market layouts
to show only active Units related to the Property
*/
public class MSAProperty{
public MSAProperty() {
}
public List<Property__c> mprops {get;set;}
public MSAProperty(ApexPages.StandardController cont) {
String ID = cont.getId();
mprops = [Select Name, Address__c, City__c, State__c, Zip__c
from Property__c
where Market__c = :cont.getId()];
}
}
So you need to pull out the map from the pageBlockTable, so I think you meant you have your page look like this.
Now the last trick will be to assign different colors to each pin.