谷歌地图错误与角度+ JavaScript

时间:2018-07-16 15:16:55

标签: javascript angular google-maps google-maps-api-3

我对Angular和Javascript不太满意。我想在本地使用Google地图运行现有应用程序。

页面已加载,并应显示地图。但是我得到了那些错误:

js?v=3&callback=angular2GoogleMapsLazyMapsAPILoader:42 Google Maps API error: MissingKeyMapError 
https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
_.Hb @ js?v=3&callback=angular2GoogleMapsLazyMapsAPILoader:42
(anonymous) @ common.js:54
(anonymous) @ common.js:152
c @ common.js:48
(anonymous) @ AuthenticationService.Authenticate?1shttp%3A%2F%2F167.99.133.34%3A4200%2F%23%2Fpages%2Fgyms%2Fadd&callback=_xdc_._hrm6mx&token=23882:1
util.js:228 Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

我今天已经生成了新的API密钥,但是由于它是一个角度库,所以我不知道将其放在哪里。

在我的chrome调试器中,我可以看到我的错误可能来自此调用

"js?v=3&callback=angular2GoogleMapsLazyMapsAPILoader:64"


 <script type="text/javascript" async="" defer="" 
    src="https://maps.googleapis.com/maps/api/js? 
    v=3&amp;callback=angular2GoogleMapsLazyMapsAPILoader"></script>

您对此有任何想法吗?

1 个答案:

答案 0 :(得分:1)

请尝试放入 <script src="https://maps.googleapis.com/maps/api/js?key=yourKeyIsHere&libraries=places" async defer></script>

进入Angular项目:index.html