谷歌地图API密钥失效
问题描述:
在配置我定义:谷歌地图API密钥失效
.config(
['uiGmapGoogleMapApiProvider', function(GoogleMapApiProviders) {
GoogleMapApiProviders.configure({
v: '2.3.3',
libraries: 'weather,geometry,visualization',
key: 'AIzaSyCz2DCKjoWMnlrf0V23RGidagkYrwTce38'
});
}
]);
而且里面的index.html我写道:
<script src="https://maps.google.com/maps/api/js?key=AIzaSyCz2DCKjoWMnlrf0V23RGidagkYrwTce38"></script>
的问题是,我得到错误的位置:
$scope.location = function() {
window.navigator.geolocation.getCurrentPosition(function (position) {
$scope.$apply(function() {
$scope.position = position.coords;
var geocoder = new google.maps.Geocoder();
geocoder.geocode({
'latLng': {
lat: $scope.position.latitude,
lng: $scope.position.longitude
}
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
$scope.$apply(function() {
$scope.userLocation = results[0].formatted_address;
});
} else {
$scope.$apply(function() {
$scope.userLocation = "No se ha podido conseguir la dirección";
});
}
}
});
});
}, function (error) {
alert(error);
});
};
因为谷歌告诉我,我没有插入钥匙,因为你可以看到,我之前做过
错误是:
js?v=3.exp&callback=initGoogleMaps:37 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error_.hb @ js?v=3.exp&callback=initGoogleMaps:37(anonymous function) @ common.js:51(anonymous function) @ common.js:191c @ common.js:45(anonymous function) @ AuthenticationService.Authenticate?1shttp%3A%2F%2F47.62.226.23%3A9000%2Fangular%2Findex.html%23%2Fs…:1
答
如Error Messages描述,MissingKeyMapError
是显影剂错误代码,这意味着:
The script element that loads the API is missing the required authentication parameter. If you are using the standard Maps JavaScript API, you must use a key parameter with a valid API key. If you are a Premium Plan customer, you must use either a client parameter with your client ID or a key parameter with a valid API key.
而作为建议,见指南API keys and client IDs。
如果在检查文档中提供的API密钥并且问题仍然存在,请尝试在gmaps-api-issues中的Issue 9975中给出的解决方法。遇到的问题也可能与提出的问题有关。
除此之外,最近在Geo Developers Blog上发布的关于Building for Scale: Updates to Google Maps APIs Standard Plan的消息也可能有所帮助。
如果您将版本'2.3.3'替换为'3.20',它应该工作 – Dario
继续不工作。以下是错误: js?v = 3.exp&callback = initGoogleMaps:37 Google Maps API错误:MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error_ .hb @ js?v = 3.exp&callback = initGoogleMaps:37(匿名函数)@ common.js:51(匿名函数)@ common.js:191c @ common.js:45(匿名函数)@ AuthenticationService.Authenticate?1shttp %3A%2F%2F47.62.226.23%3A9000%2Fangular%2Findex.html%23个%2FS ......:1 –