IOS|IOS 高德地图 标注无法选中的一种情况

贴一段代码

if (!_bCenter) { [self.aMapView setCenterCoordinate:marker.coordinate]; _bCenter = YES; } if (bshow) { [self.aMapView selectAnnotation:marker animated:YES]; }

【IOS|IOS 高德地图 标注无法选中的一种情况】在执行添加annotation之后立刻执行了上述代码,先设置了地图中心位置,然后选中该annotation,结果annotation经常未被选中,我研究了一下高德地图annotationView的加载机制,发现在地图刚移入时才加载之前添加的annotation,此时立刻设置选中该annotation会出现不响应的情况。所以改了下代码写法,问题解决,代码如下:
if (!_bCenter) { [self.aMapView setCenterCoordinate:marker.coordinate]; _bCenter = YES; }/** 延时100毫秒 设置选中当前annotation 由于高德地图annotation加载机制的问题, 在地图刚移入时才加载之前添加的annotation,此时立刻设置选中该annotation会 出现不响应的情况(高德地图BUG)此处采用GCD延时方式执行选中annotation 操作。 */ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(100 * NSEC_PER_MSEC)), dispatch_get_main_queue(), ^{ if (bshow) { [self.aMapView selectAnnotation:marker animated:YES]; } });

    推荐阅读