开发 iOS 猎鹰SDK 开发指南 轨迹查询 查询终端历史轨迹

查询终端历史轨迹 最后更新时间: 2021年01月22日

查询终端历史轨迹有两种方式,一种会查出终端的所有轨迹的轨迹点,包括不属于任何一个轨迹的散点,并将这些轨迹点按照上传时间排序;

另一种会按照轨迹查出每个轨迹下的轨迹点或特定轨迹下的轨迹点,散点不包含在内。

a.查询终端所有轨迹点

下面的代码查询出某个终端在最近12小时内上传的所有轨迹点:

    AMapTrackQueryTrackHistoryAndDistanceRequest *request = [[AMapTrackQueryTrackHistoryAndDistanceRequest alloc] init];
    request.serviceID = self.trackManager.serviceID;
    request.terminalID = kAMapTrackTerminalID;
    request.startTime = ([[NSDate date] timeIntervalSince1970] - 12*60*60) * 1000;
    request.endTime = [[NSDate date] timeIntervalSince1970] * 1000;
    [self.trackManager AMapTrackQueryTrackHistoryAndDistance:request];

    - (void)onQueryTrackHistoryAndDistanceDone:(AMapTrackQueryTrackHistoryAndDistanceRequest *)request response:(AMapTrackQueryTrackHistoryAndDistanceResponse *)response {
        //查询成功
        NSLog(@"onQueryTrackHistoryAndDistanceDone%@", response.formattedDescription);
    }

    - (void)didFailWithError:(NSError *)error associatedRequest:(id)request {
        if ([request isKindOfClass:[AMapTrackQueryTrackHistoryAndDistanceRequest class]]) {
            //查询失败
        }
    }

b.查询终端下属于某个轨迹的轨迹点

搜索最近12小时以内上报的属于某个轨迹的轨迹点信息,散点上报不会包含在该查询结果中:

    AMapTrackQueryTrackInfoRequest *request = [[AMapTrackQueryTrackInfoRequest alloc] init];
    request.serviceID = self.trackManager.serviceID;
    request.terminalID = kAMapTrackTerminalID;
    request.trackID = @"您要查询的轨迹(track id)";
    request.startTime = ([[NSDate date] timeIntervalSince1970] - 12*60*60) * 1000;
    request.endTime = [[NSDate date] timeIntervalSince1970] * 1000;
    
    [self.trackManager AMapTrackQueryTrackInfo:request];

    - (void)onQueryTrackInfoDone:(AMapTrackQueryTrackInfoRequest *)request response:(AMapTrackQueryTrackInfoResponse *)response {
        //查询成功
        NSLog(@"onQueryTrackInfoDone%@", response.formattedDescription);
    }

    - (void)didFailWithError:(NSError *)error associatedRequest:(id)request {
        if ([request isKindOfClass:[AMapTrackQueryTrackInfoRequest class]]) {
            //查询失败
        }
    }


返回顶部 示例中心 常见问题 智能客服 公众号
二维码