三星Galaxy设备无法使用geolocation.getCurrentPosition [英] Samsung Galaxy Devices can't use geolocation.getCurrentPosition

查看:226
本文介绍了三星Galaxy设备无法使用geolocation.getCurrentPosition的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我一直在寻找对这个问题的适当答复.我有一个使用navigator.geolocation.getCurrentPosition获取用户位置的Web应用程序.

OK, so I've been looking for an adequate response to this issue for quite some time. I have a web application that uses navigator.geolocation.getCurrentPosition to get a user's position.

Samsung Galaxy设备上的本机浏览器几乎总是在getCurrentPosition代码方面遇到问题.我已经尝试过使用回调和超时对这种代码进行各种变体,但始终是相同的问题.许多人已经记录了此问题,有些人指出重新启动设备可以工作(有时重新启动确实可以,但并非总是如此-提示用户重新启动设备的警报似乎很繁琐).

The native browser on the Samsung Galaxy devices nearly always have problems with the getCurrentPosition code. I have tried all kinds of variations of this code with callbacks and timeouts, but its always the same issue. Plenty of people have documented this issue, and some indicate that restarting the device will work (sometimes restarting does work, but not always - and an alert telling users to restart their device seems beyond rediculous).

有没有人找到使用getCurrentPosition在Samsung Galaxy Device上工作的肯定方法?这就是我正在合作的东西...

Has anyone figured out a surefire way to use getCurrentPosition to work on a Samsung Galaxy Device? Here's what I'm working with...

<script>

$(document).ready(function(){

if( navigator.geolocation ) {
    navigator.geolocation.getCurrentPosition( success, fail );
}

else {
     alert("Sorry, your browser does not support geolocation services.");
}

function success(position) {

    window.location = "mobile_set_coordinates.php?user_lat=" + position.coords.latitude + 
    "&user_lon=" + position.coords.longitude + "&accuracy=" + position.coords.accuracy;
}

function fail() {
    // Could not obtain location
}

});

</script>

此外,这是指向有关此问题的讨论之一的链接: https://groups.google .com/forum/#!topic/phonegap/ESrHAjFHgFU

Also, here's a link to one of the discussions regarding the issue: https://groups.google.com/forum/#!topic/phonegap/ESrHAjFHgFU

推荐答案

我遇到了与您几周前完全一样的问题.我尝试在互联网上进行大约2周的调查,研究可以找到的所有解决方案.毕竟,我发现:

I got exactly the same problem as you have few weeks ago. I tried to research about 2 weeks on the internet, look into all solutions that I can find. After all, I found out that:

  1. 如果从未在目标手机上打开过Google Maps,则此功能不起作用.
  2. 重置GPS状态,然后重新启动手机.可能会有帮助.
  3. 如果第2步不起作用,请重置GPS的状态,在日期时间"设置上自动打开获取时区",然后重新启动手机.

据我所知,代码没有错.实际上,我的代码与您的代码几乎相同.它不仅发生在Galaxy设备上,而且还发生在某些HTC上.我在Galaxy S2,Galaxy Note 2,HTC Nexus One,HTC One X和HTC Incredible S上遇到了这个问题.我认为这应该是Android设备与代码竞争之间的问题.

According to my knowledge, there is nothing wrong with the code. In fact, my code is nearly the same as yours. It happens not only on Galaxy devices but also on some HTC. I faced with this problem on Galaxy S2, Galaxy Note 2, HTC Nexus One, HTC One X and HTC Incredible S. I think it should be the problem between the Android devices and the competition of the code somehow.

干杯

这篇关于三星Galaxy设备无法使用geolocation.getCurrentPosition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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