【问题标题】:Google geolocation.getcurrentposition doesn't work after refresh page on mobileGoogle geolocation.getcurrentposition 在移动设备上刷新页面后不起作用
【发布时间】:2019-04-02 19:38:53
【问题描述】:

A 制作了一个使用Google Geolocation Javascipt APIvue2-google-maps 包的网站。相关代码如:

`geolocate () {
            var self = this
            this.loading = true
            navigator.geolocation.getCurrentPosition(position => {
                this.loading = true
                this.center = {
                    lat: position.coords.latitude,
                    lng: position.coords.longitude
                }
}`

问题是,如果用户打开页面,然后单击弹出窗口并且不允许定位,移动浏览器会将其保存在某处,如果用户刷新页面,则会弹出窗口,询问想要分享自己的位置的用户,没有再次出现。

有什么办法,如果刷新页面,每次刷新都会弹出窗口?

我试图删除 -> 设置 -> 网页设置 -> 位置 -> 我的网站,但刷新并再次接受后,浏览器会自动在后台保存我的答案并第三次刷新,弹出窗口再次出现没有出现:(

【问题讨论】:

    标签: javascript vue.js geolocation google-geolocation vue2-google-maps


    【解决方案1】:

    正如@matthew-shwery 所说,你不能。

    用户必须手动管理他们的浏览器设置,因为您的网站在被拒绝位置权限时会被添加到黑名单中。

    您可以考虑通知用户。看 Request location coordinates after user has blocked access in javascript

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-11-07
      • 2016-08-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-23
      • 2020-02-15
      相关资源
      最近更新 更多