Angular 2:Google地图和Angular Google地方信息

时间:2017-07-02 04:17:35

标签: javascript angular google-maps api-key

我在同一页面中使用了两个组件,https://angular-maps.com和angular2-google-map-auto-complete。 https://www.npmjs.com/package/angular2-google-map-auto-complete。我用这种方式定义了角度贴图键:

AgmCoreModule.forRoot({
 apiKey: 'API_KEY'
})

对于索引文件上的谷歌地图自动完成:

<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places"></script>

问题是当我在同一页面上使用该组件时抛出错误

You have included the Google Maps API multiple times on this page. This may cause unexpected errors.

我知道问题是什么,但是,hoy定义单个API_KEY以避免错误

1 个答案:

答案 0 :(得分:0)

只需删除

即可
<script src="https://maps.googleapis.com/maps/api/js?key=API_KEY&libraries=places"></script>
从index.html

并在amgCoreModule声明中添加api键。