Thursday, April 2, 2015

Google Map : Simplifying Map In Visualforce

Salesforce spring15 release which bring some cheers to developer where implementing requirement
related to google map.

As earlier a lot of work needs to be done like div componant to create canvas for map binding dynamically data to marker ,use of javascript url(Map api)  on VF  to show location specific data.

Now we have quick solution to show google map on Vf using simple <apex:> Tag.We have <apex:map> component to show  a map canvas on Visualforce page.Using  <apex:map> and <apex:mapMarker> we can easily implement location on map.

There are certain attribute that need to be set while displaying map.
<apex:map>
Attriute : mapType
The type of map to display. Must be one of the following:

  • hybrid
  • roadmap
  • satellite



height: sets size
width : sets size

<apex:MapMarker>
position Object Specifies the location of the marker.

Code Snippet:

<apex:map width="600px" height="400px" mapType="roadmap"  center="Account Billing address">
   <apex:mapMarker title="{! contact.Name }"
     position="{!contact.MailingStreet},{!contact.MailingCity},{!contact.MailingState}"/>
</apex:map>

Note : Enable Map setting:
Customize-->Map and Location-->enable



http://docs.releasenotes.salesforce.com/en-us/spring15/release-notes/rn_vf_mapping_components.htm

No comments:

Post a Comment