2016-07-27 54 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