Use Google Maps in Salesforce.

Hi Guys,

Today I am going to share my experience with google maps on Salesforce. First of all, I must tell you that working with google maps is very cool, interesting & addictive. You can spent hours and hours digging into this. Let's start this post.

There are many libraries available for Google Maps that can be directly embedded into anywhere like Native Android/IOS application or in any web page. You can find all libraries here.

In this tutorial, I am going to use Google Map JavaScript API as I have made a web demo. This app is sample demo app to search for nearby agents of a company and customers can contact their nearby agents for query. At the same time, Agents can locate their current position onto system for real time updates to customers/companies.

Screenshots below will make more sense:

Let's start building a page

To start off, you have to request an API key for Maps from google. That can be done by going to Google API Console and following steps:

Create or select a project.

Click Continue to enable the API and any related services.

On the Credentials page, get a Browser key (and set the API Credentials). Note: If you are using this page for Salesforce 1, You have to create two more keys i.e. Android key & IOS key to support Salesforce 1 otherwise maps won't behave properly

After creating a project & getting API Keys, you have to refer google maps on your page like below:

Now to make this page intuitive & dynamic, We can add some VF remoting methods that will get agents nearby & set location for agents on Salesforce. I am not going to list all things here, the detailed code can be simply seen at this github repo.