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 

Is it possible to plot only records from list view on Map using lightning / Lwc?

Arun Kumar 1141Arun Kumar 1141

Hello Sai,

Yes it is absolutely possible to plot records from a list view on a map using Lightning Web Components (LWC) in Salesforce. Salesforce offers a range of tools and APIs that can help you achieve this functionality seamlessly. Let me break down the process for you:

1. Get the records: You'll begin by retrieving the desired records from the list view. This can be done by leveraging the power of Salesforce Object Query Language (SOQL) or the Salesforce REST API to query and fetch the records.

2. Create a Lightning Web Component: Create a Lightning Web Component that will serve as the foundation for displaying the map and handling the rendering of records on it.

3. Choose a Map API: Decide on a suitable map API that you'd like to utilize for presenting the records on the map. Salesforce provides the Lightning Map Component, which is built upon the Google Maps API. Alternatively, you can opt for other renowned map APIs like Mapbox or Leaflet.

4. Integrate the map component in LWC: Incorporate the chosen map API into your Lightning Web Component. This will involve writing the necessary JavaScript code to initialize the map, generate markers, and manage map-related interactions.

5. Plot the records on the map: Once you have the list of records and the map component set up, you can iterate through the records and generate markers for each one on the map. By leveraging address or geolocation data, assign the appropriate coordinates (latitude and longitude) to each marker.

6. Customize the map display: Add further enhancements and customization to the map as per your requirements. For example, you can cluster markers together, implement pop-up windows to display record details, or apply distinct colors or icons to differentiate between various record types.

7. Handle user interactions: Implement any necessary logic to handle user interactions with the map. This can involve actions such as clicking on markers to view record details or applying filters to display records based on the map's boundaries.

  If the above answer helped you,mark it as best answer.

Thank You!
 

ShannuShannu
Hi Arun,

Thanks for your reply.
I have developed Maps using Lightning and class. So now i should work on LWC if at all i need to display the records from list view on Map?