2016-11-24 87 views
0

Iam當前正在爲Chrome添加擴展程序。我的擴展應包含Google Maps API。如果我嘗試午飯我擴展我得到這個錯誤:Google Maps API與Chrome擴展程序策略衝突

Refused to load the script 'https://maps.google.com/?file=api&v=2.x&key=KEY&sensor=true&callback=initialize' because it violates the following Content Security Policy directive: "script-src 'self'". 
  • 我有鑰匙
  • 我設置權限的API:"permissions":"https://maps.google.com/*"
  • 我改變了CSP一些時間。如果設置CSU到API的URL像上面我有這樣的事情:Refused to load script because it because it violates the following Content Security Policy directive: "script-src 'self' https://maps.google.com/?file=api&amp".'
  • 我試圖將參數設置爲&sensor=true & &callback=initialize

我也讀了很多老的請求至極的類似於我的情況下,但我沒有找到任何可能有用的東西。

我會很高興,如果有人可以幫助我,謝謝:)

+1

如何使用V3代替V2。 –

+0

@EmmanuelDelay我可以,但我想我會遇到同樣的問題 – jokey

+0

自從2012年左右起,API v2已被棄用,任何對'v2'的請求都將真正使用v3,但功能可能有限。閱讀:https://developers.google.com/maps/documentation/javascript/v2tov3 – duncan

回答

0

一個可能這裏的問題是,你沒有正確設置谷歌地圖URL的內容安全策略。你應該改變你的"content_security_policy"清單文件看起來像這樣:

"content_security_policy": "script-src 'self' https://maps.googleapis.com https://maps.gstatic.com; object-src 'self'" 

欲瞭解更多信息,您可以檢查如何解決這種錯誤的這些線程:

+0

它不適用於我,它顯示了我:https://www.screencast.com/t/eLAvOHRmA – Mohammad