Monday 23 March 2015

Integrating Google Map Using New Spring 15 Visualforce Components

            Most of us already known about the Google Map integration in Salesforce. For integrating Google map in previous releases we used Java script calls, referring some of resource files, etc.  But in Spring’15 release it is too simplified. There are two new Visualforce mapping components introduced that are,

            <apex: map>              - Display an interactive map with Zooming, Scrolling, markers.
            <apex: mapMarker>    - Defines a marker to be displayed at a location.

Steps to Enable Map Feature

Before using this new feature, we need to enable this in salesforce organization,

            Go to App Setup in the Side Bar à Maps and Location à Setting à Edit à Check Enable Maps and Location Services.

  1. <apex:page standardController="Account">
  2.     <apex:pageBlock>
  3.         <apex:map width="1000px" height="400px" mapType="roadmap"
  4.                   center="{!Account.BillingStreet},{!Account.BillingCity},{!Account.BillinState}">
  5.             <apex:repeat value="{!Account.Contacts}" var="contact">
  6.                 <apex:mapMarker title="{!contact.Name}"
  7.                                 position="{!contact.MailingStreet},{!contact.MailingCity},{!contact.MailingState}"/>
  8.             </apex:repeat>
  9.         </apex:map>
  10.     </apex:pageBlock>
  11. </apex:page>

Limitation

1. Visualforce mapping components aren’t currently available in Developer Edition organizations.
2. There’s a limit of 10 geocoded address lookups per page request. It means you can see maximum of 10 pointers in the map.  Center and Position attribute values counted in this limit.

Reference



No comments:

Post a Comment

Activities: Assign Tasks to a Queue Salesforce Lightning

Salesforce announced to assign Tasks to a Queue beginning from Spring'20 release. How does it work? In Setup, enter Queues in th...