路线规划
使用百度地图SDK版本为2.9.1。
需要将改
代码:
#import
#import
#import
#import
#import
#import
#import "HXRouteViewController.h"
#import "UIView+Extension.h"
#import "HXAnnotationView.h"
#import "HXAnnotation.h"
#import "HXMenDDetail.h"
#import "UIImage+Rotate.h"
#import "UIColor+HexString.h"
#import "FMActionSheet.h"
#import "ZoomInOrOutButton.h"
#define MYBUNDLE_NAME @ "mapapi.bundle"
#define MYBUNDLE_PATH [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent: MYBUNDLE_NAME]
#define MYBUNDLE [NSBundle bundleWithPath: MYBUNDLE_PATH]
/**
* 路线的标注
*/
@interface RouteAnnotation : BMKPointAnnotation
{
int _type; ///<0:起点 1:终点 2:公交 3:地铁 4:驾乘 5:途经点
int _degree;
}
@property (nonatomic) int type;
@property (nonatomic) int degree;
@end
@implementation RouteAnnotation
@synthesize type = _type;
@synthesize degree = _degree;
@end
@interface HXRouteViewController (){
BMKMapView *_mapView;
NSString *_cityName;
BMKRouteSearch *_routesearch;
}
/**
* 返回按钮
*/
//@property (nonatomic , weak)UIButton *preBtn;
/**
* 存放标注数组
*/
@property(nonatomic , strong) NSMutableArray *annotations;
/**
* 用户当前位置
*/
@property(nonatomic , strong) BMKUserLocation *userLocation;
@property(nonatomic , strong) HXAnnotation *anno;
@end
@implementation HXRouteViewController
- (NSString*)getMyBundlePath1:(NSString *)filename
{
NSBundle * libBundle = MYBUNDLE ;
if ( libBundle && filename ){
NSString * s=[[libBundle resourcePath ] stringByAppendingPathComponent:filename];
return s;
}
return nil ;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *statusView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREENW, 20)];
statusView.backgroundColor = [UIColor colorWithR:46 G:139 B:84 alpha:1.];
[self.view addSubview:statusView];
_routesearch = [[BMKRouteSearch alloc] init];
_routesearch.delegate = self;
//初始化BMKMapView并设置代理
_mapView = [[BMKMapView alloc] initWithFrame:CGRectMake(0, 20, SCREENW, SCREENH - 140)];
[self.view addSubview:_mapView];
_mapView.delegate = self;
_mapView.buildingsEnabled = YES;
_mapView.overlookEnabled = YES;
_mapView.showMapScaleBar = YES;
_mapView.overlooking = -45;
//设置放大/缩小按钮
[self setupNavButton];
//返回按钮
[self backButton];
//设置导航按钮
// [self setupNavButton];
//驾车路线
[self showDriveSearch];
//设置放大/缩小按钮
[self setupZoomButton];
}
#pragma mark 设置放大/缩小按钮
-(void)setupZoomButton{
ZoomInOrOutButton *zoomInOrOutBtn = [[[NSBundle mainBundle] loadNibNamed:@"ZoomInOrOutButton" owner:nil options:nil] lastObject];
zoomInOrOutBtn.layer.cornerRadius =