Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
@Ajay I'm also trying to display a google map with routing info in a custom LWC. I can't get it to work and the out of box lighting-map component does not offer the extra's I need. Are you having any luck using Leaflet?
Unfortunately, Lightning Web Components require that an external library like this one be uploaded to Salesforce as a static resource. The Content Security Policies in place demands it for security purposes. This is likely why Salesforce collaborated with Google on the lightning map components that exist currently. That being said, there are some free, open-source map libraries out there that can get what you want (e.g. Leaflet, OpenLayers, Modest Maps) or you can embed a Visualforce page and use Google Maps with your custom code.
And on that page it states: "You can’t load JavaScript resources from a third-party site, even if it’s a CSP Trusted Site. To use a JavaScript library from a third-party site, add it to a static resource, and then add the static resource to your component. After the library is loaded from the static resource, you can use it as normal."
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.