我正在使用JavaScript,HTML,CSS進行谷歌瀏覽器擴展。爲此,我需要讀取用戶提供的地址的經度和緯度。在測試我的分機,我不斷收到以下錯誤谷歌地圖api不能在谷歌瀏覽器擴展
這裏是我的js代碼
result: {
data: function (from, to, hrs, mins) {
fromaddress = from;
toaddress = to;
hours = hrs;
minutes = mins;
View.result.readLatLng();
},
readLatLng: function() {
//var addressone = document.getElementById("addressone").value;
geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': fromaddress}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var latitude = results[0].geometry.location.latitude;
var longitude = results[0].geometry.location.longitude;
console.log('lat: ' + latitude + ', lng: ' + longitude);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
}
這裏是我的manifest.json文件
{
"name": "Name",
"version": "1.0",
"manifest_version": 2,
"background": {
"scripts": [
"js/result.js",
"js/script.js"
]
},
"description": "Desc",
"browser_action": {
"default_icon": "images/icon.png",
"default_title": "Title",
"default_popup": "html/popup.html"
},
"permissions": [
"http://*/",
"https://maps.google.com/*",
"https://maps.googleapis.com/*",
"http://localhost/*",
"geolocation"
],
"content_security_policy": "script-src 'self' https://maps.googleapis.com https://maps.gstatic.com; object-src 'self'"
}
請幫助我如何我能解決這個問題嗎?
你見過這個問題嗎? http://stackoverflow.com/questions/11968234/chrome-extension-uncaught-error-code-generation-from-strings-disallowed-for-th – Marcelo
是的,我讀過一個。我沒有在我的擴展中使用任何模板。所以這沒有幫助。 – 2619
@Marcelo你能幫我一下嗎?預先感謝您 – 2619