3

这个问题已经被问过很多次了,但每个答案都是一样的,但它对我不起作用......

当我调用 navigator.geolocation.getCurrentPosition 时,我得到两个警报框。一个是本地的,另一个来自 webview (Safari)。一般的答案是将呼叫置于 Deviceready 呼叫中。我将它放在那个监听器中,但我仍然收到两个警报。(第二个很丑!)。

有想法该怎么解决这个吗??

document.addEventListener('deviceready', function() {
    navigator.geolocation.getCurrentPosition(initialize, onError, { enableHighAccuracy: true });
}

任何帮助都会很棒!

谢谢

4

1 回答 1

2

如果您使用的是 Cordova/PhoneGap 3.0 或更高版本,请确保您已将Geolocation 插件添加到您的应用项目中,否则您将收到双重警报。

如果使用 Cordova,请 cd 进入您的项目目录,然后在命令行中输入以下命令:

cordova plugin add org.apache.cordova.geolocation

如果使用 PhoneGap,您可以尝试以下命令:

phonegap local plugin add org.apache.cordova.geolocation

感谢https://stackoverflow.com/a/18839828上的 Robert Verge

于 2013-10-06T14:27:47.810 回答