Salesforce Google Maps Integration
-
Upload
cloudanalogy -
Category
Technology
-
view
268 -
download
1
Transcript of Salesforce Google Maps Integration
www.cloudanalogy.com
Salesforce ExpertAjay Dubedi
[email protected] +1 (415) 830-3899
Salesforce
Google Map
Integration
www.cloudanalogy.com
Description of the requirement:
Starting with description of the Project we have worked upon, there’s an app we created for searching and showing Account’s location on the Map and knowing a route map from one location to another location via some locations(Checkpoints).
Integrating Google Maps into Salesforce
www.cloudanalogy.com
For the requirement we used Google maps api which is in Javascript format. There are some predefined javascript functions used in the Google map api. We used Google Maps library whoz source is coming from a link i.e., “https://maps.google.com/maps/api/”.
There are several Javascript functions we used here which are as follows:
Solution we came with:
Integrating Google Maps into Salesforce
www.cloudanalogy.com
1. Function to get the current location of the User by using the browser’s location.
Integrating Google Maps into Salesforce
www.cloudanalogy.com
2. We created an apex class method which will take Address of the Account as a string and will return a Geolocation for that address i.e., in Latitude and longitude of the string address passed in the function as a parameter to it.
Suppose a string will be as shown below: public Account accObj{get;set;}
Integrating Google Maps into Salesforce
www.cloudanalogy.com
Now we used the below method to get the Latitude & Longitude:
Integrating Google Maps into Salesforce
www.cloudanalogy.com
We also did authentication for Google Apis in this method by passing the Access Key like this:
Integrating Google Maps into Salesforce
www.cloudanalogy.com
This Code will get User’s location from browser on load of the page and it will be stored in Start as “My location”. See below:
For Directions services we used “directionsService.route(request, function(response, status) { }” function.
Integrating Google Maps into Salesforce