我正在使用科尔多瓦地理定位 api 开发一个 Jquery 移动应用程序。
Cordova:3.6.3,地理位置:cordova 插件添加 org.apache.cordova.geolocation(最新版本),
jQuery Mobile:1.4.4
我正在使用以下代码获得确切的当前位置
navigator.geolocation.getCurrentPosition(drawMap,handleError, {
enableHighAccuracy: true,
maximumAge : 0,
timeout : 60000
});
手表位置问题,它总是触发未知错误。相同的代码在 IOS-6 中运行良好
watchProcess = navigator.geolocation.watchPosition(handleSuccess,
handleError, {
enableHighAccuracy: true,
maximumAge : 0,
timeout : 60000
});
switch(error.code)
{
case error.PERMISSION_DENIED:
alert("User did not share geolocation data");
$(".ajax-loader").hide();
break;
case error.POSITION_UNAVAILABLE:
alert("Could not detect current position");
$(".ajax-loader").hide();
break;
case error.TIMEOUT:
alert("Retrieving position timed out, could not detect your location");
$(".ajax-loader").hide();
break;
default:
alert("Unknown Error"); // Always getting Unknown Error
$(".ajax-loader").hide();
break;
}
尝试在我的平台/ios/NavSustain/config.xml 文件中添加以下代码,但没有运气
<gap:config-file platform="ios" parent="NSLocationAlwaysUsageDescription" overwrite="false"> <array> <string>Allow GPS</string> </array> </gap:config-file>
我的 config.xml 文件是
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.navsustain.navsustain" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<preference name="AllowInlineMediaPlayback" value="false" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="BackupWebStorage" value="cloud" />
<preference name="DisallowOverscroll" value="false" />
<preference name="EnableViewportScale" value="false" />
<preference name="FadeSplashScreen" value="true" />
<preference name="FadeSplashScreenDuration" value=".25" />
<preference name="KeyboardDisplayRequiresUserAction" value="true" />
<preference name="MediaPlaybackRequiresUserAction" value="false" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="SuppressesIncrementalRendering" value="false" />
<preference name="TopActivityIndicator" value="gray" />
<preference name="GapBetweenPages" value="0" />
<preference name="PageLength" value="0" />
<preference name="PaginationBreakingMode" value="page" />
<preference name="PaginationMode" value="unpaginated" />
<feature name="LocalStorage">
<param name="ios-package" value="CDVLocalStorage" />
</feature>
<feature name="Geolocation">
<param name="ios-package" value="CDVLocation" />
</feature>
<name>NavSustain</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<gap:config-file platform="ios" parent="NSLocationAlwaysUsageDescription" overwrite="false"> <array> <string>Allow GPS</string> </array> </gap:config-file>
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<access origin="*" />
<feature name="NetworkStatus">
<param name="ios-package" value="CDVConnection" />
</feature>
<feature name="Notification">
<param name="ios-package" value="CDVNotification" />
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen" />
<param name="onload" value="true" />
</feature>
</widget>
非常感谢您的帮助。谢谢