I have integrated a Google Map on my Website. I have saved my token_api in a variable in .env and declare as global in twig.yaml. If i access the token via {{token_google_api}} my map display only if i refresh my page.
I have tried to paste my token in raw and it work well, but i don't want to have a secret token write in raw in my code.
Display on refresh:
<script async defer src="https://maps.googleapis.com/maps/api/js?key={{token_google_api}}&callback=initMap"></script>
Display well:
<script async defer src="https://maps.googleapis.com/maps/api/js?key=my_token_in_raw&callback=initMap"></script>
my .env
TOKEN_GOOGLE_API=my_token_in_raw
my twig.yaml
twig:
globals:
token_google_api: '%env(TOKEN_GOOGLE_API)%'
Actually i have to refresh my page to display the map. I expect the map display when i come to the page the first time.
Edit: It seems to work properly on Edge. but not in Firefox & Chrome so, there is the css for my map div maybe should be helpful.
#map {
height: 600px;
width: 100%;
}