Can I change/set the Google Maps API Key dynamically from JavaScript?

后端 未结 2 1552
长情又很酷
长情又很酷 2021-01-03 04:20

I\'m faced with a problem with a small web application I\'m developping: My HTML-source will be integrated into the HTML source on another site. I\'m using a Google Map in m

相关标签:
2条回答
  • 2021-01-03 04:44

    Use

    var script = document.createElement("script");
    script.setAttribute("src",whatever);
    document.getElementsByTagName("head")[0].appendChild(script);
    

    Replace whatever with the script source you want to use

    0 讨论(0)
  • 2021-01-03 04:46

    I just blogged a would-be solution to this problem. Take a look and let me know what you think. It's a context processor that dynamically loads the key based on the domain in the request.

    0 讨论(0)
提交回复
热议问题