Integrating Google Maps with Salesforce - All You Need to Know About : shreya yadav

Integrating Google Maps with Salesforce - All You Need to Know About
by: shreya yadav
blow post content copied from  Forcetalks
click here to view original post

In this blog, we learned how to use the MARKER API to integrate Google Maps with the Salesforce. 

An area on a map is designated by a marker. A marker always uses the same image by default. When markers display bespoke images, they are sometimes referred to as "icons." Icons and markers are Marker-type objects. 

Generating Google API Key

  • Visit the Google Maps Platform > Dashboard page > API page. 

 Go to the Credentials page 

  • Click Create credentials > API key on the Dashboard page. 

Your freshly created API key is displayed in the window for creating API keys. 

  • To close, click.  

The new API key is listed on the Credentials page under API keys.        


dont miss out iconDon't forget to check out: Access Salesforce Maps Schedule and Manage Saved Events

Adding Marker to the Map

Using Google.maps the initial properties of the marker are specified by single Marker options object literal that is passed to the function Object () {[native code]} of the marker. 

When building a marker, the following fields are highly significant and frequently set: 

  • position (mandatory) specifies a LatLng indicating the marker's original location. a method of getting a LatLng. 
  • map (optional) means the Map that the marker should be placed on. The marker is created but not attached to (or displayed on) the map if the map is not specified during marker construction.  

The vf page's source code can be found below. 

<apex:page id="GoogleMap" docType="html-5.0" sidebar="false" showheader="false" > 
        <style type="text/css"> 
            html { height: 100% } 
            body { height: 100%; margin: 0; padding: 0 } 
            #map-canvas { height: 100% } 
        <script src=""></script> 
            Location Map 
                var map;          
        function initialize() { 
            var mapOptions = { 
                center: new google.maps.LatLng(28.535517, 77.391029), 
                zoom: 20 
                map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);              
        google.maps.event.addDomListener(window, 'load', initialize);          
        <div id="map-canvas"/> 

Script Tag Attributes

src: All of the symbols and definitions required for utilizing the Maps JavaScript API are included in the URL from which the Maps JavaScript API is loaded. The URL in this illustration contains two parameters: key and callback, where key is your API key and callback is the name of a global function that will be invoked after the Maps JavaScript API has fully loaded. 

Map DOM Elements

We need to set up space for the map in order for it to appear on a web page. Typically, we accomplish this by generating a named div element and locating a reference to it in the document object model of the browser (DOM). 

Map Options

Every map must have two options Centre and zoom. 

Zoom Levels

The zoom attribute determines the starting resolution at which to display the map; zoom 0 corresponds to a fully zoomed-out map of the Earth, and higher zoom levels zoom in at a higher resolution. 

Zoom level: 

  • 1: World 
  • 5: Landmass/continent 
  • 10: City 
  • 15: Streets 
  • 20: Buildings 

dont miss out iconCheck out another amazing blog by Shreya here: How to Build a Basic Salesforce REST API Integration

The Map Object

The Map class in JavaScript is the class that symbolises a map. This class of objects specifies a single map on a page. (You are allowed to construct many objects of this class; each object will define a different map on the page.) Using the JavaScript new operator, a new instance of this class is created. 

This code creates a new Map object and assigns the variable "map" to it. The function Object() { [native code] } is the method Map(). 

The post Integrating Google Maps with Salesforce - All You Need to Know About appeared first on Forcetalks.

July 18, 2022 at 09:19PM
Click here for more details...

The original post is available in Forcetalks by shreya yadav
this post has been published as it is through automation. Automation script brings all the top bloggers post under a single umbrella.
The purpose of this blog, Follow the top Salesforce bloggers and collect all blogs in a single place through automation.