Stack Exchange Network
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.
Visit Stack Exchange
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.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
3 years, 4 months ago
Closed. This question is off-topic. It is not currently accepting answers.
Questions about implementation problems need to include a
specific description of the problem (including exact errors and stack traces, if any) and the code or metadata to reproduce the problem. Please limit code inclusions to only the relevant elements, such as an MVR (minimum viable reproduction). This question can be reopened when it is edited to include those details.
As we know that standard base component lightning-map has limited customizations, so I am planning to use a custom map using Google Maps API.
I know that we can import the JS file and use it as static resources, however, in this case, Google API is a dynamic URL "
https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap". How do we import this into LWC and use it?
I am trying to achieve something similar to this.
Jan 3, 2020 at 20:46
1,509 3 3 gold badges 28 28 silver badges 61 61 bronze badges
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.
Jan 3, 2020 at 21:12
3,849 2 2 gold badges 14 14 silver badges 37 37 bronze badges
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our
Accept all cookies
Necessary cookies only