2016-07-27 104 views
1

我试图用角谷歌地图和我通过角谷歌提供的快速设置去映射角谷歌地图API密钥未获得通过

.config(['$routeProvider','$locationProvider','uiGmapGoogleMapApiProvider, 
     function($routeProvider,$locationProvider,uiGmapGoogleMapApiProvider) { 
      // Other configurations 
      uiGmapGoogleMapApiProvider.configure({ 
      key: ‘MY_GOOGLE_API_KEY’, 
      v: ‘3.17’, 
      libraries: 'weather,geometry,visualization' 
      }); 
     } 
    ]); 

我设置在谷歌API控制台的API密钥,但是当我加载页面,我得到一个MissingKeyMapError。

Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

我在API控制台中启用了Google Javascript API。我不知道我做错了什么。任何帮助将不胜感激。

+0

我希望这两行上的单引号(键:'API_KEY', v:'3.17')正确吗? –

回答

1

我解决了这个问题。原来我是两次加载Google Maps API v3。我加载它在提供

uiGmapGoogleMapApi.then(function(maps) {});

和一旦我删除脚本标记加载脚本标签

<script src="https://maps.googleapis.com/maps/api/js"></script>

,它的工作!

感谢大家的帮助。

0

确保您使用带有有效API密钥的密钥参数。请按照此link了解如何为您的项目获取适当API密钥的步骤。

  1. Go to the Google API Console .
  2. Create or select a project.
  3. Click Continue to enable the API and any related services.
  4. On the Credentials page, get a Browser key (and set the API Credentials). Note: If you have an existing Browser key, you may use that key.
  5. To prevent quota theft, secure your API key following these best practices .
  6. (Optional) Enable billing. See Usage Limits for more information.

而基于此thread,这个问题是因为这是包括使用该库之前,谷歌地图API的寄生script标签。您也可以检查这个相关的SO question

希望这会有所帮助!

+0

感谢您的建议@abielita,但它仍然无法正常工作。我看了你建议的链接,并检查了一切。我没有收到错误,当查询字符串中的API键 'https://maps.googleapis.com/maps/api/js?key = MY_API_KEY' 地图没有显示,但我'米没有得到previuos错误。我将不得不找出一个。 – milo3169