分篇介紹最新百度地圖相關(guān)應(yīng)用
一、環(huán)境配置:
http://www.lxweimin.com/p/be592ed98ebf
二、顯示與定位:
http://www.lxweimin.com/p/154c7840ffa5
三、根據(jù)經(jīng)緯度描點:
http://www.lxweimin.com/p/a4065c3f0457
四、大頭針與氣泡:
http://www.lxweimin.com/p/bb8f8f3c1ef1
五、給大頭針加tag值:
http://www.lxweimin.com/p/6023465da2e7
六、問題處理:
http://www.lxweimin.com/p/c8b1449efea7
本篇介紹給大頭針加tag值!
項目demo:
https://github.com/Dongxk/XKBMKMap.git
本篇效果:
方法:
在- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation方法中替換掉原先的BMKAnnotationView;
#pragma mark --- BMKMapViewDelegate
- (BMKAnnotationView *)mapView:(BMKMapView *)mapView viewForAnnotation:(id<BMKAnnotation>)annotation{
if ([annotation isKindOfClass:[self.pointAnnotation class]]) {
//數(shù)組對應(yīng)大頭針
paopaoIndex++;
UIView *paopaoView = [UIView new];
static NSString *identifier = @"XKAnnotationView";
//自定義的XKAnnotationView 替換掉原先的BMKAnnotationView
XKAnnotationView *annotationView = [[XKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier customView:paopaoView WithData: self.pointArray[paopaoIndex - 1] WithTag:1000 + paopaoIndex];
return annotationView;
}else{
//定位大頭針
}
return nil;
}
自定義AnnotationView
- (id)initWithAnnotation:(id<BMKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier customView:(UIView *)detailView WithData:(NSDictionary *)dataDict WithTag:(NSInteger)tag{
if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
if (self) {
[self setBounds:CGRectMake(0, 0, 100.f, 100.f)];
self.canShowCallout = YES;
self.centerOffset = CGPointMake(0, 0); //設(shè)置中心點偏移
detailView.tag = tag;
[self configCellWithData:dataDict];
[self addSubview: detailView];
}
}
return self;
}
具體請看demo:
demo