gpt4 book ai didi

ios7 - MKDirectionsResponse 总是返回 nil

转载 作者:行者123 更新时间:2023-12-04 16:00:53 25 4
gpt4 key购买 nike

如果重复这个问题,我深表歉意,但我很难尝试使用 MKDirectionsRequest 显示两地之间的路线。

MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];
request.source = [MKMapItem mapItemForCurrentLocation];
request.transportType = MKDirectionsTransportTypeAny;
request.destination = _dstItem;
request.requestsAlternateRoutes = YES;


MKDirections *directions = [[MKDirections alloc] initWithRequest:request];
// __block typeof(self) weakSelf = self;
[directions calculateDirectionsWithCompletionHandler:
^(MKDirectionsResponse *response, NSError *error) {

//stop loading animation here

if (error) {
NSLog(@"Error is %@",error);
} else {
//do something about the response, like draw it on map
MKRoute *route = [response.routes firstObject];
[self.mapView addOverlay:route.polyline level:MKOverlayLevelAboveRoads];
}
}];

MKDirectionsResponse 总是返回 nil 和错误描述

Error Domain=MKErrorDomain Code=5 "Directions Not Available" 
UserInfo=0x1700f1c80 {NSLocalizedFailureReason=A route to the nearest road cannot be determined.,
MKErrorGEOError=-403, MKDirectionsErrorCode=6, NSLocalizedDescription=Directions Not Available}

最佳答案

MKDirectionsRequest 是查找两点之间路线的正确 API。 Apple 似乎还没有为印度添加路由功能。

关于ios7 - MKDirectionsResponse 总是返回 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23009151/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com