0
我有MobileFirst(V7.O)应用程序。我如何获得设备的当前纬度/经度?基本上,我在我的应用程序的不同点录制一些信息,用户可以移动..因此,在各种情况下,我想获得当前的经纬度/日志。获取此信息IBM MobileFirst - 获取位置
感谢您的帮助
我有MobileFirst(V7.O)应用程序。我如何获得设备的当前纬度/经度?基本上,我在我的应用程序的不同点录制一些信息,用户可以移动..因此,在各种情况下,我想获得当前的经纬度/日志。获取此信息IBM MobileFirst - 获取位置
感谢您的帮助
Cordova捆绑在您的MobileFirst项目中。因此,您可以使用Cordova API来实现这一点。
参见下面的(向下滚动到API使用):https://github.com/apache/cordova-plugin-geolocation
// onSuccess Callback
// This method accepts a Position object, which contains the
// current GPS coordinates
//
var onSuccess = function(position) {
alert('Latitude: ' + position.coords.latitude + '\n' +
'Longitude: ' + position.coords.longitude + '\n' +
'Altitude: ' + position.coords.altitude + '\n' +
'Accuracy: ' + position.coords.accuracy + '\n' +
'Altitude Accuracy: ' + position.coords.altitudeAccuracy + '\n' +
'Heading: ' + position.coords.heading + '\n' +
'Speed: ' + position.coords.speed + '\n' +
'Timestamp: ' + position.timestamp + '\n');
};
// onError Callback receives a PositionError object
//
function onError(error) {
alert('code: ' + error.code + '\n' +
'message: ' + error.message + '\n');
}
navigator.geolocation.getCurrentPosition(onSuccess, onError);