首页 > 移动平台 > 详细

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

时间:2016-06-29 20:34:03      阅读:976      评论:0      收藏:0      [点我收藏+]

// 根据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;

}

 

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!