Lightning:Map show data on Google Map

Winter 19 is rolling for everyone. I have shared some points which I like most in winter 19. Which you can read here.  with winter 19 Salesforce introduce many components, one of them is lightning:map. It is very useful for developers. Previously when you want to show address on google map you need google api key and lots of script to make it happen. With Lightning:map component you don’t need to worry about anything as it provide this functionality out of box. Also we can use this component in standalone app, lightning app, Lightning out and visualforce so we can use it in classic view as well.

Today we will use this component to show child contact address on google map as marker.

Lightning map show Contact on Parent account

To show this we simply use lightning:map tag and will provide data.

Here we have created two wrapper to send data to map component.  Location wrapper is used to store the address while Address wrapper is used to provide marker specific details.

Do you like the component or want to add anything. Let me know in comments section. Happy Programming 🙂


4 thoughts on “Lightning:Map show data on Google Map

    1. Hi David, I am able to reproduce the issue but unable to find fix. We need to handle them in apex using some third party address validation api. If I found anything else will update here.

      1. Hi Tushar,
        I’ve found that adding the geolocation info overides the address.
        Hard coded works:
        location: {
        Street:’74767 Dexter Road’,
        City: ‘Asbest’,
        PostalCode: ‘11407’,
        Country: ‘United States’,
        Longitude: -73.806100
        but I can’t get it safely back from the remote call. It doesn’t recognise it.
        I’ve tried double, decimal and string but nothing has worked.

        public class locationDetailWrapper{
        @AuraEnabled public string Street{get;set;}
        @AuraEnabled public string PostalCode{get;set;}
        @AuraEnabled public string City{get;set;}
        @AuraEnabled public string State{get;set;}
        @AuraEnabled public string Country{get;set;}
        @AuraEnabled public double Latitude{get;set;}
        @AuraEnabled public double Longitude{get;set;}

        oLocationWrap.Latitude = acc.BillingLatitude;
        oLocationWrap.Longitude = acc.BillingLongitude;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.