Hello everyone!
I have a weird problem with google maps in a modular page and I hope someone may have a guess on what is causing this.
I have a modular page with a module for showing googlemaps. Since this is the only page with a map I loaded the script only in this module template with:
{% do assets.addJs(‘https://maps.googleapis.com/maps/api/js?key=’, {‘priority’:‘90’,‘loading’: ‘defer’}) %}
Here the problem. On localhost everything is fine, but online the script is not loaded and it doesn’t appear at the bottom. Any ideas?
You are including the javascript within the modular page itself?
Where in the modular page is the javascript being called? It is outside of the content block you are likely using to render the page?
@seb3000 I’ve the API key, but I haven’t posted here
@Sockfuzz Actually I didn’t add the javascript to the modular.html.twig, I added it to the module template map.html.twig that is one of modules in “contacts page”.
Like this:
page folder structure
06.contacts
_module01
_module02
_map < this is the module where I want to put the map javascript
The structure of my map.html.twig is the following:
Sorry for the delay guys. @paul actually that solution can not work since it’s not possible to add a block to a module template (it can’t have the extends twig tag) @chris_jung well I didn’t thought about that and it was a possible solution, unfortunatelly it didn’t worked aah.
Well I made a lot of tests and nothing worked, I’m just going to leave the script in base template for now. If I can find a solution I’ll let you know.