直接上代码
<QMSSearchDelegate>
@property (nonatomic, strong) QMSSearcher *mySearcher;
- (QMSSearcher *)mySearcher {
if (!_mySearcher) {
_mySearcher = [[QMSSearcher alloc]initWithDelegate:self];
}
return _mySearcher;
}
- (void)viewDidLoad {//1
[super viewDidLoad];
QMSWalkingRouteSearchOption *WalkingOpt = [[QMSWalkingRouteSearchOption alloc] init];
[WalkingOpt setFrom:[NSString stringWithFormat:@"%f,%f",Alatitude,Alongitude]];
[WalkingOpt setTo:[NSString stringWithFormat:@"%f,%f",Blatitude,Blongitude]];
[self.mySearcher searchWithWalkingRouteSearchOption:WalkingOpt];
QMSBicyclingRouteSearchOption *BicyclingOpt = [[QMSBicyclingRouteSearchOption alloc] init];
[BicyclingOpt setFrom:[NSString stringWithFormat:@"%f,%f",Alatitude,Alongitude]];
[BicyclingOpt setTo:[NSString stringWithFormat:@"%f,%f",Blatitude,Blongitude]];
[self.mySearcher searchWithBicyclingRouteSearchOption:BicyclingOpt];
QMSDrivingRouteSearchOption *drivingOpt = [[QMSDrivingRouteSearchOption alloc] init];
[drivingOpt setPolicyWithType:QMSDrivingRoutePolicyTypeLeastTime];
[drivingOpt setFrom:[NSString stringWithFormat:@"%f,%f",Alatitude,Alongitude]];
[drivingOpt setTo:[NSString stringWithFormat:@"%f,%f",Blatitude,Blongitude]];
[self.mySearcher searchWithDrivingRouteSearchOption:drivingOpt];
}
#pragma mark - Search Delegates
//error
- (void)searchWithSearchOption:(QMSSearchOption *)searchOption didFailWithError:(NSError *)error
{
NSLog(@"error:%@", error);
}
//步行路径结果回调
- (void)searchWithWalkingRouteSearchOption:(QMSWalkingRouteSearchOption *)walkingRouteSearchOption didRecevieResult:(QMSWalkingRouteSearchResult *)walkingRouteSearchResult
{
NSLog(@"Walking result:%@. count:%ld", walkingRouteSearchResult, walkingRouteSearchResult.routes.count);
QMSRoutePlan *routeLine = [walkingRouteSearchResult.routes firstObject];
float dis = routeLine.distance;
NSString *scopeStr = [NSString stringWithFormat:@"%.3f", dis/1000];
NSLog(@"disdisdisdisdis %f %@",dis,scopeStr);
}
//骑行路径结果回调
- (void)searchWithBicyclingRouteSearchOption:(QMSBicyclingRouteSearchOption *)bicyclingRouteSearchOption didRecevieResult:(QMSBicyclingRouteSearchResult *)bicyclingRouteSearchResult {
NSLog(@"Walking result:%@. count:%ld", bicyclingRouteSearchResult, bicyclingRouteSearchResult.routes.count);
QMSRoutePlan *routeLine = [bicyclingRouteSearchResult.routes firstObject];
float dis = routeLine.distance;
NSString *scopeStr = [NSString stringWithFormat:@"%.3f", dis/1000];
NSLog(@"disdisdisdisdis %f %@",dis,scopeStr);
}
//驾车路径结果回调
- (void)searchWithDrivingRouteSearchOption:(QMSDrivingRouteSearchOption *)drivingRouteSearchOption didRecevieResult:(QMSDrivingRouteSearchResult *)drivingRouteSearchResult {
NSLog(@"Walking result:%@. count:%ld", drivingRouteSearchOption, drivingRouteSearchResult.routes.count);
QMSRoutePlan *routeLine = [drivingRouteSearchResult.routes firstObject];
float dis = routeLine.distance;
NSString *scopeStr = [NSString stringWithFormat:@"%.3f", dis/1000];
NSLog(@"disdisdisdisdis %f %@",dis,scopeStr);
}
网友评论