首页 > 其他 > 详细

高德地图作业二

时间:2016-01-02 14:14:58      阅读:106      评论:0      收藏:0      [点我收藏+]

在该方法中- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath,添加如下代码,即可简单实现不重复添加和移动到中心:

    /*

     遍历_annotations数组,如果有同名字符串就不添加到地图中

     */

    for (MAPointAnnotation *annotationS in _annotations) {

        if ([annotationS.title isEqualToString:annotation.title]) {

            return;

        }

        

    }

    //按annotation.coordinate为中心开始移动

    [_mapView setCenterCoordinate:annotation.coordinate animated:YES];

 

需要注意的是,该代码应该要放在添加 [_mapView addAnnotation:annotation]和  [_annotations addObject:annotation]之前。

高德地图作业二

原文:http://www.cnblogs.com/vshiron/p/5094582.html

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