Friday, January 18, 2019

Lightning:map - Way to display location on map either by using address or geo-location

Salesforce introduces new tag in lightning framework "lightning:map" which can be used to securely displays map of one location or many locations.

You can either use address (make sure postalcode,country are specified) or geolocation (latitude and longitude).

Below is syntax to use lightning:map

<lightning:map
    mapMarkers="{!v.mapMarkers}">
</lightning:map>

where mapMarkers is an array of marker to display location. Below is JSON sample for markers:

[{
"location": {
"Country": "USA",
"State": "CA"
},
"icon": "standard:account",
"title": "Western Telecommunications Corp.",
"description": "CA,USA"
},
{
"location": {
"City": "Lawrence",
"Country": "USA",
"PostalCode": "66045",
"State": "KS"
},
"icon": "standard:account",
"title": "Dickenson plc",
"description": "Lawrence,KS,66045,USA"
}]

If you know geo-location of address then, you can pass latitude and longitude in location as shown below:

[{
    location: {
'Latitude': '37.790197',
'Longitude': '-122.396879'
},
    title: 'Western Telecommunications Corp',
    description: 'Western Telecommunications Corp',
    icon: 'standard:account'
}]


I have created a sample lightning component which fetch account billing address and display it on google maps using Lightning:map tag.


Complete Code:


Note:
  • If you specify address, then you must specify City, PostalCode, State or Country.
  • If you specify both address and geo-location, then map will be plotted using latitude and longitude.
  • If any mapMarker is invalid, then nothing will be plotted on map even other map markers.

Hope this will help!!!

16 comments:

  1. Atocloud have designed solution to display all of its accounts on the google map for one of there clients in both lightning and classic, where user can select type of record he wants to search (Account, contact or any custom object). This solution has three section

    ReplyDelete
  2. Atocloud have designed solution to display all accounts on the google map in both lightning and classic, where user can select type of record he wants to search (Account, contact or any custom object).

    ReplyDelete
  3. We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. what county am i in now

    ReplyDelete
  4. I was very pleased to find this site.I wanted to thank you for this great read!! I definitely enjoying every little bit of it and I have you bookmarked to check out new stuff you post. garmin gps updates free 2016

    ReplyDelete
  5. In the same way as other ventures, the guide business is experiencing a time of solidification and change. Fókuszpályázat

    ReplyDelete
  6. Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. where to get nonsurgical cci treatment

    ReplyDelete
  7. I experience considerable difficulties my contemplations on substance, however I truly felt I ought to here. Your article is truly awesome. I like the way you composed this data. maps128

    ReplyDelete
  8. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. this page

    ReplyDelete
  9. In this manner, the main interest and supply factors for business endurance and development - i.e., stable client and stable business visionary - are emphatically connected with business location. find more

    ReplyDelete
  10. Pretty good post. I have just stumbled upon your blog and enjoyed reading your blog posts very much. I am looking for new posts to get more precious info. Big thanks for the useful info. бонгакам

    ReplyDelete
  11. There is nothing worse than feeling uncomfortable and it seems problems can worsen when there are occasions you wish to attend. With Christmas looming make sure you make the most of the holidays by having any neck or back pain problems looked at before symptoms worsen. There are specialist chiropractors within Coventry that offer consultations, diagnosis and treatments to ensure you are provided with the best care. click here

    ReplyDelete
  12. can u please send the code for based on latitude and longitude display location in google maps for custom object please send the code or any reference for this

    ReplyDelete
  13. You have been bombarded with unidentified contact numbers and inspire bordering on harassment. You would like to find information about the identity of the person behind a telephone number. You can find solutions. call history tracker

    ReplyDelete