html geolocation:获取位置的未知错误 [英] html geolocation: Unknown error acquiring position

查看:609
本文介绍了html geolocation:获取位置的未知错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用HTML地理位置来获取我的位置。有趣的是,它工作得非常出色,直到它刚停止工作的那一天看似随机的一点。现在我得到的是错误回调消息:

I am trying to use HTML geolocation to get my position. Funny thing is, it was working brilliantly until some seemingly random point in the day when it just stopped working. Now all I get is the error callback with a message:

Unknown error acquiring position

这发生在我第一次开始开发应用程序的那天。它是一个内置Node / Express的Web应用程序。我使用的浏览器是Firefox v53 64位。

This happened on the day I first started to develop the app. It is a web app built in Node/Express. The browser I am using is Firefox v53 64-bit.

位置是允许的,我也尝试了一个我在网上找到的修复程序,涉及到:about和config更改 geo.wifi.uri 来自:

Location is allowed, and I have also tried a fix that I found online which involves going to about:config and changing geo.wifi.uri from:

https://www.googleapis.com/geolocation/v1/geolocate?key=%GOOGLE_API_KEY%

to

https://www.googleapis.com/geolocation/v1/geolocate?key=test

这对我不起作用。

但这对我的手机Firefox应用程序有效,但不是Google Chrome应用。

This does however work on my phones Firefox app, but not the Google Chrome app.

下面是一个示例代码段:

Heres an example code snippet:

    const geo = navigator.geolocation;
    geo.getCurrentPosition(success, failure);

    function success(position) {
        lat = position.coords.latitude;
        lng = position.coords.longitude;
        $('#coords').val(lat + ',' + lng);
        mapView.setCenter(ol.proj.fromLonLat([lng, lat]));
    }

    function failure(error) {
        console.log(error.message);
    }

整页: https://github.com/ThriceGood/Spots/blob/master/views/index.html

有谁可以解释这个问题?

Can anyone shed some light on this issue?

推荐答案

什么对我有用正在将 geo.wifi.uri 更改为:

What worked for me was changing geo.wifi.uri to:

https://location.services.mozilla.com/v1/geolocate?key=test

根据此页面:< a href =https://stackoverflow.com/questions/24359073/navigator-geolocation-getcurrentposition-do-not-work-in-firefox-30-0> navigator.geolocation.getCurrentPosition在Firefox 30.0中不起作用

这篇关于html geolocation:获取位置的未知错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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