响应对象为null,代码未执行。
MKPlacemark *source=[[MKPlacemark alloc]initWithCoordinate:sourceloc addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil]];
MKPlacemark *source=[[MKPlacemark alloc]initWithCoordinate:sourceloc addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil]];
MKMapItem *srcmapItem=[[MKMapItem alloc]initWithPlacemark:source];
[srcmapItem setName:@""];
MKPlacemark *destination=[[MKPlacemark alloc]initWithCoordinate:destinationloc addressDictionary:[NSDictionary dictionaryWithObjectsAndKeys:@"",@"", nil]];
MKMapItem *desmapItem=[[MKMapItem alloc]initWithPlacemark:destination];
[desmapItem setName:@""];
MKDirectionsRequest *request=[[MKDirectionsRequest alloc]init];
[request setSource:srcmapItem];
[request setDestination:desmapItem];
[request setTransportType:MKDirectionsTransportTypeWalking];
MKDirections *direction = [[MKDirections alloc]initWithRequest:request];
[direction calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
NSLog(@"response = %@",response);
NSArray *arrRoutes = [response routes];
[arrRoutes enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
MKRoute *rout = obj;
MKPolyline *line = [rout polyline];
[self.routeMap addOverlay:line];
NSLog(@"Rout Name : %@",rout.name);
NSLog(@"Total Distance (in Meters) :%f",rout.distance);
NSArray *steps = [rout steps];
NSLog(@"Total Steps : %lu",(unsigned long)[steps count]);
[steps enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
NSLog(@"Rout Instruction : %@",[obj instructions]);
NSLog(@"Rout Distance : %f",[obj distance]);
}];
}];
}];
答案 0 :(得分:1)
苹果官员的方向功能可用性列表
https://nodejs.org/api/events.html
因此,根据Apple文档,此功能在INDIA中不可用。这只是获得NULL响应的原因。
你可以使用谷歌地图有一些限制, Google Maps Geocoding API具有以下限制。
https://www.apple.com/in/ios/feature-availability/#maps-directions
其他替代解决方案是使用其他开源。