navigator.geolocation.GetCurrentPosition抛出"最后一个位置提供被禁用"错误 [英] navigator.geolocation.GetCurrentPosition throws "The last location provider was disabled" error

查看:244
本文介绍了navigator.geolocation.GetCurrentPosition抛出"最后一个位置提供被禁用"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建抓住地理位置非常基本的HTML5页面,但我发现了一个错误。

I am trying to create a very basic HTML5 page that grabs the geolocation, but I'm getting an error.

下面就是我有我的'script'标签中:

Here's what I have inside my 'script' tags:

 function GetGeo() {
        if (!navigator.geolocation) {
            alert("Could not find geolocation");
        }
        else {
            navigator.geolocation.getCurrentPosition(showMap, function (error) { alert("error encountered: " + error.message ); });
        }
    }

    function showMap(position) {
        window.alert(position.coords.latitude + ", " + position.coords.longitude);
    }

页面只是上有一个按钮,调用GetGeo()函数。

The page just has a button on it, that calls the GetGeo() function.

我所做的.html文件滴到我的手机的SD卡。然后,我浏览到内容://com.android.htmlfileprovider/sdcard/GetGeo.html和页面正确显示出来。当我点击该按钮并执行,我得到以下错误:最后的位置提供被禁用

What I did is dropped the .html file onto the SDCard of my phone. Then, I browsed to "content://com.android.htmlfileprovider/sdcard/GetGeo.html" and the page shows up correctly. When I click the button and execute, I get the following error: "The last location provider was disabled"

我有几个问题:
1:这是错误的刚落对SD卡的HTML文件,并尝试运行它?
2:有什么基本的,我做错了就是不让它获得来自移动浏览器的地理位置

I have a couple questions: 1: Is it wrong to just drop the html file on the SDCard and try to run it there? 2: Is there something basic that I'm doing wrong that is not letting it get the geolocation from the mobile browser?

在此先感谢您的帮助!

推荐答案

我想通了这一点:我需要进入我的手机浏览器的设置,并检查启用位置

I figured this out: I needed to go into the setting of my mobile browser and check 'Enable Location'

这篇关于navigator.geolocation.GetCurrentPosition抛出"最后一个位置提供被禁用"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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