gpt4 book ai didi

javascript - PositionError 网络位置提供程序位于 'https://www.googleapis.com/' : Returned error code 404

转载 作者:搜寻专家 更新时间:2023-10-31 21:49:36 25 4
gpt4 key购买 nike

我正在使用 Geolocation HTML5 API。我正在使用 angular.js。我写了一个小工厂函数

myApp.factory("GeolocationService", ['$q', '$window', '$rootScope',
function($q, $window, $rootScope) {
return function() {
var deferred = $q.defer();

if (!$window.navigator) {


$rootScope.$apply(function() {
deferred.reject(new Error("Geolocation is not supported"));
});
} else {
$window.navigator.geolocation.getCurrentPosition(function(position) {

$rootScope.$apply(function() {
deferred.resolve(position);
});
}, function(error) {

$rootScope.$apply(function() {
deferred.reject(error);
});
});
}

return deferred.promise;
}
}
]);

当我使用它时。它给我一个错误

PositionError {消息:“网络位置提供商位于‘https://www.googleapis.com/’:返回错误代码 404。”,代码:2,PERMISSION_DENIED:1,POSITION_UNAVAILABLE:2,TIMEOUT:3}

谁能帮忙解决一下??

最佳答案

您必须启用 wifi 连接才能使用 navigator.geolocation(即使您没有使用它!)

更多解释in this answer .

关于javascript - PositionError 网络位置提供程序位于 'https://www.googleapis.com/' : Returned error code 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25729107/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com