【发布时间】:2018-03-20 15:42:48
【问题描述】:
我在我的应用程序中使用谷歌地图 API,如下所示:
在 index.html 中使用 api 键导入 url:
<script src="https://maps.googleapis.com/maps/api/js?key=myKey"></script>
并在组件中像这样声明 google:
declare let google: any;
并像这样在组件中使用它:
this.map = new google.maps.Map(document.getElementById('googleMap'), this.mapProp);
如何动态更改 index.html 中存在的 API 密钥?
【问题讨论】:
-
你真的应该把你的 api 密钥涂掉,这样人们就不会拿走它
-
不需要使用declare let,使用declare即可。为什么要更改 api 密钥?
-
这是一个假的 api 密钥,只是为了展示
-
很高兴知道,很高兴你没有通过它那里
-
你找到答案了吗?
标签: angular google-maps google-maps-api-3 angular7 angular2-services