在配置我定義:谷歌地圖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
如果您將版本'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 –