Google Maps with lightning:map component

with salesforce winter 19 release, Salesforce introduced the lightning:map component that will display the google maps on lightning experience. Prior to winter 19 release, we used to do a hack to show the google maps on the lightning experience by using visualforce page. The lightning:map component securely displays a map of one or more locations using Google Maps.

You can pass markers to the component to define the locations to map. A marker can be a coordinate pair of latitude and longitude, or a set of address elements: City, Country, PostalCode, State, and Street. You need to pass the locationmapMarkers property to display the map.

For example:

map-markers is an array of markers that indicate location. A marker contains

  • Location Information: This can be a coordinate pair of latitude and longitude or an address composed of address elements.
  • Descriptive Information: This is information like title, description and an icon which is information relevant to the marker but not specifically related to location.

The location information supports the following address elements: CityCountryPostalCodeState, and Street. Note that to support reliable geocoding of addresses, if Street is specified then at least one of CityCountryPostalCode or State must be specified.

Here’s an example of a marker that uses address elements.

 

Apex Class : 

the below apex class will get the billing  address information from the account will display on the maps

 

Here is the component

javascript controller

After creating the component you can able to the see the map with markers as shown below