隐藏,在MkMapView上显示注释 [英] Hide, show annotation on MkMapView

查看:68
本文介绍了隐藏,在MkMapView上显示注释的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

缩小地图视图时如何隐藏注释。我必须隐藏大量注释,因为如果在地图上显示的区域太大,则只能看到注释。

How to hide annotation when zooming out the map view. I have a big number of annotation i have to hide them because if the region displayed on the map is too big you can see only the annotations.

推荐答案

要执行此操作,必须检查区域的大小,并根据其大小将视图设置为隐藏还是不隐藏。

To do this, you have to check the size of your region, and depending of it you set the views hidden or not.

我测试了代码在下面,但是,您可能需要进行一些调整。

I tested the code bellow but, you will probably need some adjustments.


- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    NSArray *annotations = [_mapView annotations];  
    MyAnnotation *annotation = nil; 
    for (int i=0; i<[annotations count]; i++)
    {
        annotation = (MyAnnotation*)[annotations objectAtIndex:i];
        if (_mapView.region.span.latitudeDelta > .010)
        {
            [[_mapView viewForAnnotation:annotation] setHidden:YES];
        }
        else {
            [[_mapView viewForAnnotation:annotation] setHidden:NO];
        }
    }
}

干杯,

VFN

Cheers,
VFN

这篇关于隐藏,在MkMapView上显示注释的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆