function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sai Shanmukh 15Sai Shanmukh 15 

I have a requirement to display opportunity records on Google Maps. Here is my LWC Code on Opportunity. I'm unable to retrieve address from Account object: import { LightningElement, api,wire } from 'lwc'; import getOpportunityList from '@salesforce/apex/

Sai Shanmukh 15Sai Shanmukh 15
import { LightningElement, api,wire } from 'lwc';
import getOpportunityList from '@salesforce/apex/OpportunityMap.getOpportunityList';
export default class OpportunityOnMap extends LightningElement {
   @api opportunityIdS;
    mapMarkers = [];
        console.log('++++ opportunityIdS :  ' + this.opportunityIdS);
            getOpportunityList({ opportunityIdS: this.opportunityIdS }).then(result=> {
                console.log('@@@@ result '+result);
                result.forEach(dataItem => {
                    this.mapMarkers = [...this.mapMarkers,

                            location: {
                                City: dataItem.BillingCity,
                                Country: dataItem.BillingCountry,
                                PostalCode: dataItem.BillingPostalCode,
                                State: dataItem.BillingState,
                                Street: dataItem.BillingStreet,
                                Type: dataItem.Type,
                                Name : dataItem.Name,
                            icon: 'standard:opportunity',
                            title : dataItem.Name,
            }).catch(error => {
aanojas lanceraanojas lancer
Here is the LWC code that you can use to display opportunity records on Google Maps
import { LightningElement, api, wire } from 'lwc';
import getOpportunityList from '@salesforce/apex/OpportunityController.getOpportunityList';

export default class OpportunityMap extends LightningElement {
  @api opportunities;

  getOpportunityList({ data, error }) {
    if (data) {
      this.opportunities = data.records;

  render() {
    const markers = => {
      const address = opportunity.Account.BillingAddress;
      return {
        location: {
          lat: address.Latitude,
          lng: address.Longitude,
        title: opportunity.Name,
        description: opportunity.Description,

    return (
      <lightning-map map-markers={markers}></lightning-map>

Using the Salesforce API, this code will first retrieve a list of opportunities getOpportunityList Apex method. It will then map each opportunity to a Google Maps marker. The opportunity name and description will be shown beside the markers.

Here are some further details regarding this code:
  • The getOpportunityList Apex method is a custom Apex method that you will need to create.
  • The @api annotation is used to expose the opportunities property to the Lightning UI.
  • The @wire annotation is used to wire the getOpportunityList service to the opportunities property.
  • The render() method is used to render the Google Maps.
I hope this helps!