取得行動裝置目前的地理位置。

用法

                    .appium.getGeolocation([callback])
                

範例

module.exports = {
  'get device geolocation': function (app) {
    app
      .appium.getGeolocation(function (result) {
        console.log('current device geolocation is:', result.value);
      });
  },

  'get device geolocation with ES6 async/await': async function (app) {
    const location = await app.appium.getGeolocation();
    console.log('current device geolocation is:', location);
  }
};

參數

名稱 類型 描述
callback
選填
function

以結果值呼叫的回呼函式。

傳回

類型 描述
object

目前的地理位置:{latitude: number, longitude: number, altitude: number}

另請參閱