百度地图SDK中如何默认显示一个地图中心点

貌似最近有很多人在使用百度地图的时候都需要一个需求,在当前地图view中始终显示一个中心点的大头针,然后用这个大头针来实现其他效果,废话不多说了,直接上代码

 

 

    BMKMapView *mapview = [[BMKMapView alloc] init];

    [self.view addSubview:mapview];

    mapview.frame = self.view.frame;

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];

    [btn setImage:[UIImage imageNamed:@"pin_red"] forState:UIControlStateNormal];

    btn.frame = CGRectMake(0, 0, 30, 30);

    btn.center = mapview.center;

    [mapview addSubview:btn];

    [mapview bringSubviewToFront:btn];

 

 

posted @ 2015-12-25 16:31  技术哥丶  阅读(611)  评论(0编辑  收藏  举报