【发布时间】:2016-08-12 15:53:59
【问题描述】:
在我定义的配置中:
.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' 它应该可以工作
-
继续不工作。这是错误:js?v=3.exp&callback=initGoogleMaps:37 Google Maps API 错误:MissingKeyMapError developers.google.com/maps/documentation/javascript/…@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跨度>
标签: angularjs google-maps google-maps-api-3 google-maps-api-2 api-key