目前我正在使用tizen web应用程序(javascript)为三星齿轮的智能手表创建应用程序。我的小部件/应用程序需要到处获取位置数据(它是一个安全应用程序)。基本的GPS位置工作正常,您可以在下面的代码中看到。问题是GPS只能在外面工作,因为我的应用程序是一个安全应用程序我需要到处获取位置。在手机上,您可以使用Wifi和移动网络获取位置。我的问题是有可能在智能手表上使用wifi或移动网络获取位置数据(三星齿轮有移动网络和wifi连接,所以你会认为这是可能的)?如果可能的话。
使用HTML 5地理位置的基本GPS位置代码:
function getBestGPSLocation(){
//GPS
navigator.geolocation.getCurrentPosition(success, error, {maximumAge:60000, timeout:5000});
//Wifi
//Mobile Network
}
function error(error) {
// just some error codes they work either
switch(error.code) {
case error.PERMISSION_DENIED:
console.log("permission denied");
break;
case error.POSITION_UNAVAILABLE:
console.log("your position is unavailable");
break;
case error.TIMEOUT:
console.log("a timeout occured");
break;
case error.UNKNOWN_ERROR:
console.log("an unknow error occured");
break;
}
}
function success(position) {
// this works i get all the data
alert(position);
alert(position.coords.latitude);
}