python预测抵达时间eta_什么是从任何位置到目前位置的ETA(预计到达时间)的正确方法...

Would like to know what is proper way to get ETA (estimated time arrival) from any location to my current location, in consideration the following situation:

a. ex. - I got from another device its location (lon/lat) and want to when the other person will pick me up... In this case what web-service can I use to get this info for the user?

Does mapkit provides that kind of option?

b. In case it will be done on the server-side and I'll just send my user location, what are the tools my server-side programmer can use to get ETA info in order to send it back to my user?

Thank you all in advance.

I saw this: Is there any way to determine the driving time between two locations using Apple's Maps API?

- the problem, as I found in other places, (to my understanding)is that google api requires use of Google Maps app that isn't installed on every iOS user now.

解决方案

I know this post is a bit old but in case someone is looking at the answer since iOS 7 Apple provide an API in MapKit in order to calculate all these info.

Here is a snippet of how to use this API

MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];

[request setSource:[MKMapItem mapItemForCurrentLocation]];

[request setDestination:destination];

[request setTransportType:MKDirectionsTransportTypeAutomobile];

[request setRequestsAlternateRoutes:NO];

MKDirections *directions = [[MKDirections alloc] initWithRequest:request];

[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {

if ( ! error && [response routes] > 0) {

MKRoute *route = [[response routes] objectAtIndex:0];

//route.distance = The distance

//route.expectedTravelTime = The ETA

}

}];

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值