简体   繁体   中英

HTML5 Create Geolocation object

I have a HTML5 app that uses Geolocation. If the user has denied permissions for using geolocation, I would like to pass a default position object (latitude:0, longitude:0) so that my app continues to run.

I know how to check for permissions denied, but how can I create the Position object such that it can be passed into the method below?

$scope.setCurrentLocation = function(position) {
    $scope.myposition = position.coords;
}

could you just:

$scope.setCurrentLocation = function(position) {
    if (position) {
        $scope.myposition = position.coords;
    } else {
        $scope.myposition = {x:x, y:y}
    }
}

or something to this effect?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM