如果被拒绝,请再次请求地理定位许可 [英] ask for geolocation permission again if it was denied

查看:22
本文介绍了如果被拒绝,请再次请求地理定位许可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过 phonegap 构建了一个带有地理定位按钮的应用.

im building an app through phonegap, with a geolocation button.

如果用户第一次拒绝了地理定位的许可,当他们再次点击地理定位按钮时,我如何再次请求许可?

if a user denies permission for geolocation the first time, how can i ask for permission again when they click the geolocation button again?

我目前的代码结构是:

function getLocation() {    
    if(navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(showPosition, positionError);

    } else {
        hideLoadingDiv()
        showError('Geolocation is not supported by this device')
    }
}

function positionError() {
    hideLoadingDiv()
    showError('Geolocation is not enabled. Please enable to use this feature')
}

推荐答案

你不能.

您唯一能做的就是在浏览器的设置中显示重新激活位置共享的说明 (https://support.google.com/chrome/answer/142065?hl=zh-CN).

The only thing you can do is to display the instructions to reactivate the location sharing in his browser's settings (https://support.google.com/chrome/answer/142065?hl=en).

这篇关于如果被拒绝,请再次请求地理定位许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆