【问题标题】:PositionError Network location provider at 'https://www.googleapis.com/' : Returned error code 404PositionError 网络位置提供程序位于“https://www.googleapis.com/”:返回错误代码 404
【发布时间】:2014-11-01 23:00:54
【问题描述】:

我正在使用 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 {message: "网络位置提供程序'https://www.googleapis.com/' : 返回错误代码 404。", 代码: 2, PERMISSION_DENIED: 1, POSITION_UNAVAILABLE: 2, TIMEOUT: 3}

谁能帮忙解决一下??

【问题讨论】:

标签: javascript html angularjs


【解决方案1】:

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

更多解释in this answer.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多