【问题标题】:IBM MobileFirst -- get locationIBM MobileFirst -- 获取位置
【发布时间】:2016-02-25 12:42:33
【问题描述】:

我有 MobileFirst (V7.O) 应用程序。如何获取设备的当前纬度/经度。基本上,我在我的应用程序的各个点记录一些信息,并且用户可以移动.. 所以,在各种情况下,我想获取当前的纬度/日志..

您能否提供一些提示以及如何获取此信息

感谢您的帮助

【问题讨论】:

    标签: ibm-mobilefirst


    【解决方案1】:

    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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多