Ios7 MKDirectionsResponse始终返回nil
如果这个问题再次出现,我深表歉意,但我很难使用mkdirectionrequest显示两地之间的路线Ios7 MKDirectionsResponse始终返回nil,ios7,routes,mkmapview,mapkit,Ios7,Routes,Mkmapview,Mapkit,如果这个问题再次出现,我深表歉意,但我很难使用mkdirectionrequest显示两地之间的路线 MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init]; request.source = [MKMapItem mapItemForCurrentLocation]; request.transportType = MKDirectionsTransportTypeAny; request.de
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}
我收到了同样的错误信息。如果你提供的是印度的lat long,它将不起作用,因为苹果尚未为印度添加rout功能,但尝试使用不同的lat long,希望它能起作用。我尝试了相同的,它对我起作用
Error Domain=MKErrorDomain Code=5 "Directions Not Available"
如果该位置不属于此列表中的任何国家/地区,则最有可能出现此错误:
在iOS模拟器上,您可以轻松自定义当前位置。有两种方法:
- iOS模拟器->“调试”选项卡->位置->{Choose}
- Xcode->“调试”选项卡->模拟位置->{Choose}
`-(iAction)刷新路由:(id)发送方{
[自路由计算];
}`
而不是
<hr/>
-(void)viewDidLoad {
[super viewDidLoad];
_manager = [[CLLocationManager alloc]init];
[_manager requestWhenInUseAuthorization];
[_manager requestAlwaysAuthorization];
_manager.desiredAccuracy = kCLLocationAccuracyBest;
_manager.distanceFilter =kCLDistanceFilterNone;
[_manager requestWhenInUseAuthorization];
[_manager requestAlwaysAuthorization];
[_manager startUpdatingLocation];
[_manager delegate];
self.pinMap.delegate = self;
// [self routeCalculate]; ***** This Call ****
}
<hr/>
-(无效)viewDidLoad{
[超级视图下载];
_manager=[[CLLocationManager alloc]init];
[_经理请求使用授权];
[_经理始终请求授权];
_manager.desiredAccuracy=KCallocationAccuracyBest;
_manager.distanceFilter=kCLDistanceFilterNone;
[_经理请求使用授权];
[_经理始终请求授权];
[_经理startUpdatingLocation];
[_经理代表];
self.pinMap.delegate=self;
//[自路由计算];******此呼叫****
}
<hr/>
-(void)viewDidLoad {
[super viewDidLoad];
_manager = [[CLLocationManager alloc]init];
[_manager requestWhenInUseAuthorization];
[_manager requestAlwaysAuthorization];
_manager.desiredAccuracy = kCLLocationAccuracyBest;
_manager.distanceFilter =kCLDistanceFilterNone;
[_manager requestWhenInUseAuthorization];
[_manager requestAlwaysAuthorization];
[_manager startUpdatingLocation];
[_manager delegate];
self.pinMap.delegate = self;
// [self routeCalculate]; ***** This Call ****
}
<hr/>