从Google Fit Api获取位置数据

时间:2018-04-03 14:18:25

标签: javascript google-maps google-api google-fit

我正在尝试从我通过移动设备添加的Google适合活动中获取位置数据。我目前正在使用OAuth2 Playground来测试请求。

我正在使用的请求URI是:https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

请求正文

{
  "aggregateBy": [{
    "dataTypeName": "com.google.location.sample"
  }, {
    "dataTypeName": "com.google.distance.delta"
  }],

bucketBySession:{
minDurationMillis: 1
}, 
  "startTimeMillis": 1522281600000,
  "endTimeMillis": 1522368000000
}

响应

{
  "bucket": [
    {
      "session": {
        "modifiedTimeMillis": "1522382434459", 
        "endTimeMillis": "1522316136834", 
        "description": "", 
        "activityType": 7, 
        "application": {
          "packageName": "com.google.android.apps.fitness"
        }, 
        "startTimeMillis": "1522316098654", 
        "id": "cfd891371580xxxx:activemode:walking:152231609xxxx", 
        "name": "Afternoon walking"
      }, 
      "startTimeMillis": "1522316098654", 
      "endTimeMillis": "1522316136834", 
      "dataset": [
        {
          "dataSourceId": "derived:com.google.location.bounding_box:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1522316101582000000", 
              "originDataSourceId": "raw:com.google.location.sample:com.google.android.gms:motorola:Moto G (4):cfd891371580xxxx:live_location", 
              "endTimeNanos": "1522316134619000000", 
              "value": [
                {
                  "mapVal": [], 
                  "fpVal": 9.7610998153686523
                }, 
                {
                  "mapVal": [], 
                  "fpVal": 76.626411437988281
                }, 
                {
                  "mapVal": [], 
                  "fpVal": 9.7616653442382812
                }, 
                {
                  "mapVal": [], 
                  "fpVal": 76.626708984375
                }
              ], 
              "dataTypeName": "com.google.location.bounding_box"
            }
          ]
        }, 
        {
          "dataSourceId": "derived:com.google.distance.delta:com.google.android.gms:aggregated", 
          "point": [
            {
              "startTimeNanos": "1522316098654000000", 
              "originDataSourceId": "raw:com.google.location.sample:com.google.android.gms:motorola:Moto G (4):cfd891371580xxxx:live_location", 
              "endTimeNanos": "1522316136834000000", 
              "value": [
                {
                  "mapVal": [], 
                  "fpVal": 83.398760318756104
                }
              ], 
              "dataTypeName": "com.google.distance.delta"
            }
          ]
        }
      ]
    }
  ]
}

但是这些回复并未提供我可以在我的网站上显示的位置信息。

  1. 我可以使用其他dataTypeName来获取位置信息吗?

  2. 显示的边界框数据是什么?以任何方式显示位置是否有用?

  3. "dataTypeName": "com.google.distance.delta"提供的数据是什么意思?是开始位置和结束位置之间的距离吗?

1 个答案:

答案 0 :(得分:0)

“位置数据只能由写入数据的应用程序读取。您的应用程序只能读取其写入的数据。它无法读取其他应用程序写入的位置样本数据。” from developers.google.com