计算mkmapkit的可见rect中的引脚号 [英] count the pinnumber in visible rect of mkmapkit
问题描述
我已经使用MK Mapkit创建了一个Google地图视图,并且我在不同位置添加了带注释的图钉,现在我想在缩放地图视图时也计算在地图视图上可见的rect上的图钉数量?
I have created one Google map view using MK Mapkit and i have annotated pins on different locations now i want to calculate number of pins on visible rect on map view also on when i zoom the map view?
先感谢
推荐答案
MKMapView
annotationsInMapRect:
方法将为您提供给定地图矩形中的一组注释.
The MKMapView
annotationsInMapRect:
method will give you the set of annotations in a given map rect.
要获取当前可见的图像,请将其传递给地图视图的 visibleMapRect
属性.
To get the ones currently visible, pass it the map view's visibleMapRect
property.
要检测放大,缩小或平移后可见的注释,请在 regionDidChangeAnimated
委托方法中调用该方法:
To detect what annotations are visible after a zoom in, zoom out, or pan, call that method in the regionDidChangeAnimated
delegate method:
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
NSSet *annSet = [mapView annotationsInMapRect:mapView.visibleMapRect];
NSLog(@"regionDidChangeAnimated: annSet count = %d", annSet.count);
}
这篇关于计算mkmapkit的可见rect中的引脚号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!