哈01-baidumap

来源:互联网 发布:淘宝品质退款率处罚 编辑:程序博客网 时间:2024/06/05 08:00

添加百度地图,基本步骤如下:

1、


2


3




4



5

6

#import <UIKit/UIKit.h>

#import "BMapKit.h"

@class LverViewController;


@interface LverAppDelegate :UIResponder <UIApplicationDelegate>

{

    BMKMapManager *_mapManager;

}

@property (strong, nonatomic) UIWindow *window;


@property (strong, nonatomic) LverViewController *viewController;


@end

7

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    _mapManager=[[BMKMapManageralloc]init];

    BOOL ret = [_mapManagerstart:@"hUU9k1rFENmuuIecCGZmCEv0" generalDelegate:nil];

    if (!ret) {

        NSLog(@"manager start failed!");

    }

8

#import <UIKit/UIKit.h>

#import "BMapKit.h"

@interface LverViewController : UIViewController<BMKMapViewDelegate>

@property(retain,nonatomic)BMKMapView* mapView;

@end

9


#import "LverViewController.h"

@interface LverViewController ()


@end


@implementation LverViewController


- (void)viewDidLoad

{

    [superviewDidLoad];

    self.view.backgroundColor=[UIColororangeColor];

   

_mapView = [[BMKMapViewalloc]initWithFrame:CGRectMake(0,0,320,480)];

    self.view = _mapView;

// Do any additional setup after loading the view, typically from a nib.

}

-(void)viewWillAppear:(BOOL)animated

{

    [_mapViewviewWillAppear];

    _mapView.delegate =self;//此处记得不用的时候需要置nil,否则影响内存的释放

}

-(void)viewWillDisappear:(BOOL)animated

{

    [_mapViewviewWillDisappear];

    _mapView.delegate =nil;//不用时,置nil

}

- (void)didReceiveMemoryWarning

{

    [superdidReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

10

做完以上步骤就可以显示如下效


11。加上以下两句就可以实现3D俯视效果

_mapView.rotation=90;//分别表示地图旋转角度(0°~360°

    _mapView.overlooking=-30;//俯视角度(-45°~ 0°





12添加以下几句将会添加指南针和比例尺

  //设定指南针位置

    CGPoint pt= CGPointMake(10,10);

    [_mapViewsetCompassPosition:pt];

    //地图手势

    _mapView.scrollEnabled=YES;

    _mapView.zoomEnabled=YES;

    //自定义比例尺位置

    _mapView.showMapScaleBar=YES;

    _mapView.mapScaleBarPosition =CGPointMake(200,0);

13添加标注

- (void)addPointAnnotation

{

    pointAnnotation = [[BMKPointAnnotationalloc]init];

    CLLocationCoordinate2D coor;

    coor.latitude = 39.915175;

    coor.longitude = 116.403865;

    pointAnnotation.coordinate = coor;

    pointAnnotation.title =@"test";

    pointAnnotation.subtitle =@"Annotation可拖拽!";

    [_mapView addAnnotation:pointAnnotation];

    [pointAnnotationrelease];

    

}




未完待续。。。。。。等我亮瞎你的眼还要很久,耐心等待吧!!!

0 0
原创粉丝点击