[SalesForce] Using Google Maps in Lightning Components

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?

Regards

Best Answer

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