【问题标题】:Angular 2:Google Maps and Angular Google PlacesAngular 2:谷歌地图和 Angular 谷歌地方
【发布时间】:2017-07-02 04:17:35
【问题描述】:

我在同一页面中使用了两个组件,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.

我知道问题出在哪里,但请定义单个 API_KEY 以避免错误

【问题讨论】:

    标签: javascript angular google-maps api-key


    【解决方案1】:

    只需删除

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

    从您的 index.html 并在 amgCoreModule 声明中添加您的 api 密钥。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-13
      • 2016-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多