Change apiKey on runtime Leaflet Google map


#1

Hi, I am using leaflet with google map. I’ve set apiKey in config/environment. It is possible to change the key dynamically? where and how, before it is used by google mutant plugin?

Thanks.


#2

Not sure I understand the question correctly but the key in the config ends up in the generated index.html .You could change the index.html on the backend.


#3

Hi, Thanks for the answer. I am not sure why all google map API ad-dons are made like this. I should be able to set the key when the user logs in. The idea is that I do not want to pay for all clients / users that want to use google map, but I want that each of them to have theirs own key.


#4

You cannot change google API keys without reloading the page, unfortunately.


#5

Thanks for the answers.