+ Start a Discussion
Saravana Rajkumar 16Saravana Rajkumar 16 

apex:mapMarker limits to 10 positions even when using geocoded location values

I'm trying to plot more than 10 apex:mapMarker on a visualforce page using JSON object or apex Map object for the 'position' attribute, but the map limits the number of map markers to be not more than 10.

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_mapMarker.htm
As per Visualforce Developer Guide link above, there should not be limit on mapMarkers when i'm using position values that don't require geocoding. 

Controller:
Loading transportLocationContainerList with 2 entries
Loading shipmentTrackingContainerList with 10 entries

VF page:
<apex:pageBlock mode="maindetail">
    <apex:map width="100%" height="500px" mapType="roadmap" scrollBasedZooming="true" showOnlyActiveInfoWindow="true">
        <apex:repeat value="{!transportLocationContainerList}" var="transportLocationContainer">
            <apex:mapMarker title="{!transportLocationContainer.TransportLocation.Name}" position="{!transportLocationContainer.GeolocationMap}">
            </apex:mapMarker>
        </apex:repeat>
        <apex:repeat value="{!shipmentTrackingContainerList}" var="shipmentTrackingContainer">
            <apex:mapMarker title="{!shipmentTrackingContainer.ShipmentTracking.Name}" position="{!shipmentTrackingContainer.GeolocationMap}">
            </apex:mapMarker>
        </apex:repeat>
    </apex:map>
</apex:pageBlock>

Could you please explain why the geocoding limit is exceeding and how to overcome the limit?
Saravana Rajkumar 16Saravana Rajkumar 16
Controller code: (for reference)
public Class ShipmentTrackingContainer {
    public ShipmentTracking__c ShipmentTracking {get;set;}
    public Map<String, Double> GeolocationMap {get;set;}
    public ShipmentTrackingContainer(ShipmentTracking__c shipmentTracking) {
        this.ShipmentTracking = shipmentTracking;
        this.GeolocationMap = new Map<String, Double>();
        this.GeolocationMap.put('latitude', shipmentTracking.Geolocation__latitude__s);
        this.GeolocationMap.put('longitude', shipmentTracking.Geolocation__longitude__s);
    }
}

public Class TransportLocationContainer {
    public TransportLocation__c TransportLocation {get;set;}
    public String LocationType {get;set;}
    public Map<String, Double> GeolocationMap {get;set;}
    public TransportLocationContainer(TransportLocation__c transportLocation, String locationType) {
        this.TransportLocation = transportLocation;
        this.LocationType = locationType;
        this.GeolocationMap = new Map<String, Double>();
        this.GeolocationMap.put('latitude', transportLocation.Geolocation__latitude__s);
        this.GeolocationMap.put('longitude', transportLocation.Geolocation__longitude__s);
    }
}
Bertrand LeymariosBertrand Leymarios

Hi,

I had the same issue. I've just solved it by putting the geocoding directly into a string (with json format).
 

In the end, it gives something like that : <apex:mapMarker... position="{! res.GeoLoc_Location__c}" ... >
with GeoLoc_Location__c being a formula field : "{latitude: "&TEXT(ShippingLatitude)&", longitude: "&TEXT(ShippingLongitude)&"}"

I did the same with the initial location to center the map. (as it counts within the limits).
Good luck!