iOS高德地图自定义annotation添加不同图片

时间:2016-06-29 20:34:03   收藏:0   阅读:977

// 根据anntation生成对应的View

- (MAAnnotationView *)mapView:(MAMapView *)mapView viewForAnnotation:(id<MAAnnotation>)annotation

{

  static  int a= 0;

    if ([annotation isKindOfClass:[POIAnnotation class]])

    {

        a++;

        static NSString *customReuseIndetifier = @"customReuseIndetifier";

          MAAnnotationView *annotationView = (MAAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:customReuseIndetifier];

          if (annotationView == nil)

        {

            annotationView = [[MAAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:customReuseIndetifier];

            // must set to NO, so we can show the custom callout view.

            annotationView.canShowCallout = NO;

            annotationView.highlighted = NO;

            annotationView.draggable = YES;

            annotationView.calloutOffset = CGPointMake(0, -5);

        }

 

        

        annotationView.image = [UIImage imageNamed:[NSString stringWithFormat:@"poi_marker_%d.png",a]];

 

        return annotationView;

    }

    

    return nil;

}

 

原文:http://www.cnblogs.com/liuting-1204/p/5628111.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!