I need to implement Google Maps in Lightning Components. With So much of research, I get to know the following things

  1. External CDN cant be used in Component which is described as security feature of Salesforce
  2. It is also documented that, this feature will be available for Developer Org currently to activate LockerService.

Now the question is, I don't see any documentation for using CDN in lightning Component while I have LockerService activated.

Is there any documentation for using CDN in Lighning Components?

Please let me know.

My Requirement is : I need to mark a location on Map with the address provided. I may or may not have Longitude and Latitude of the location. So I need Forwarding Geolocation functionality implemented.

Is there any other way?


2 Answers 2


You can use lightning:container to get around the locker service if thats stopping .The principle behind lighnting:container is it iframes your page inside the static source in a lightning component framework .

However the caveat with this approach is that it is currently in developer preview and has its own performance issues with the same .

The other viable approach is use visualforce as an iframe and use window.postMessage() to communicate between lightning component framework and the visualforce .

There are already good blogposts from salesforce that can easily help you understand the approach

Communicating between Lightning Components and Visualforce Pages

Using the above approach you need not worry about using CDN as you are essentially working with Visualforce container for all your JS and DOM and using post messages to communicate between lightning UI and visualforce page .

There is already an example with google maps .The source code is also available for reference here

  • Shrivatsava - Yes, true. We are trying to build a App Exchange Component, so I am not sure how both approaches will work for us because of this reason. - iFrame. In both of the case, the api is rendered in iFrame and I am not sure how Salesforce Security review handles this. There is no proper documentation around this which is hurting us badly. Any Thoughts?? May 16, 2017 at 1:59
  • 1
    Here is a session from dreamforce .youtube.com/watch?v=UpXxelyb5D4 .The session will show you how to integrate with vf iframed and use window.postmessage() .As long as you verify the domain that it is inside SFDC you should be good May 16, 2017 at 2:45
  • @MohithShrivastava the example with google maps link is taking to page not found, can you pls check and post the correct link
    – JJSHHS
    Aug 4, 2017 at 6:32

lightning:map component is present in Winter19 release plan which is using Google Maps: http://releasenotes.docs.salesforce.com/en-us/winter19/release-notes/rn_lc_components.htm

We can set markers either by using Longitude & Latitude or by using postal address.

Also, lightning:inputField component now supports the geolocation field type. It displays input fields for entering latitude and longitude in decimal degrees.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .