Getting location data from Google Fit Api

让人想犯罪 __ 提交于 2020-06-27 17:22:35

问题


I am trying to fetch location data from Google fit activity which I have added through mobile. I am currently using OAuth2 Playground to test the request.

The request URI i am using is : https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate

Request Body

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

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

Response

{
  "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"
            }
          ]
        }
      ]
    }
  ]
}

But these response does not provide a from and to location information which I can show in my website.

  1. Is there any other dataTypeName which I can use to get the location information?

  2. What is the bounding box data shown? Is it useful in any way to show location?

  3. What is the data provided by "dataTypeName": "com.google.distance.delta" mean? Is it the distance between start and end location?


回答1:


"Location data can only be read by the app that wrote the data. Your app can only read back data it wrote. It cannot read location sample data written by other apps." from developers.google.com



来源:https://stackoverflow.com/questions/49632393/getting-location-data-from-google-fit-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!