PhoneGap。无法启动地理位置服务 [英] PhoneGap. Failed to start Geolocation service

查看:196
本文介绍了PhoneGap。无法启动地理位置服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PhoneGap版本:2.0.0。 Android API级别16(4.0.3版本)。提示错误的代码示例:

PhoneGap version: 2.0.0. Android API level 16 (4.0.3 version). Code sample which prompts an error:

navigator.geolocation.getCurrentPosition(onSuccess, onError, {enableHighAccuracy:true});

function onSuccess(position) {
    console.log('latitude: '+ position.coords.latitude);
    console.log('longitude: '+ position.coords.longitude);                  
}

function onError(error) {
    console.log('Appeared error : '+ error.message);                
}

始终在模拟器中出现错误无法启动地理位置service ,错误代码 2 。即使通过 Android控制台 DDMS

Always getting an error in emulator Failed to start Geolocation service, error code 2. Even if send GPS coordinates through Android console or DDMS

发送GPS坐标Android清单权限:

Android manifest permissions:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />


推荐答案

您需要设置

You need to set the enableHighAccuracy option to true while you are trying to get the location.

navigator.geolocation.getCurrentPosition(onSuccess, onError,{enableHighAccuracy:true});

此外,要在模拟器中指定位置的坐标

Moreover, to specify the coordinates of your position in the emulator,

Eclipse - >打开透视图 - > DDMS - >仿真器控件 - >位置控件

指定位置的坐标,然后按发送

Specify the coordinates of the position and press "Send" .

这篇关于PhoneGap。无法启动地理位置服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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