热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

计算mkmapkit的可见rect中的pinnumber-countthepinnumberinvisiblerectofmkmapkit

IhavecreatedoneGooglemapviewusingMKMapkitandihaveannotatedpinsondifferentlocations

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?

我使用MK Mapkit创建了一个谷歌地图视图,我在不同位置有注释引脚现在我想在地图视图上计算可见矩形上的引脚数量,当我缩放地图视图时?

Thanx in advance.

提前完成。

3 个解决方案

#1


6  

The MKMapView annotationsInMapRect: method will give you the set of annotations in a given map rect.

MKMapView annotationsInMapRect:方法将为您提供给定map rect中的注释集。

To get the ones currently visible, pass it the map view's visibleMapRect property.

要获取当前可见的那些,请将地图视图的visibleMapRect属性传递给它。

To detect what annotations are visible after a zoom in, zoom out, or pan, call that method in the regionDidChangeAnimated delegate method:

要在放大,缩小或平移后检测注释是可见的,请在regionDidChangeAnimated委托方法中调用该方法:

-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
    NSSet *annSet = [mapView annotationsInMapRect:mapView.visibleMapRect];
    NSLog(@"regionDidChangeAnimated: annSet count = %d", annSet.count);
}

#2


0  

No. of pin can be counted by the following delegate method

引脚数可以通过以下代表方法计算

-(MKAnnotationView *)mapView:(MKMapView *)mapView1 viewForAnnotation:(id )annotation

- (MKAnnotationView *)mapView:(MKMapView *)mapView1 viewForAnnotation:(id)annotation

{

Count ++ NSLog(@"Count : %d", count);

Count ++ NSLog(@“Count:%d”,count);

}

#3


0  

Assuming you have a ViewController with mapView as a subview.

假设您有一个带有mapView的ViewController作为子视图。

- (void)someMethod
{
    NSArray *visibleAnnotatiOns= [[self.mapView annotationsInMapRect:self.mapView.visibleMapRect] allObjects];
    NSUInteger VisibleAnnotatiOnCounts= visibleAnnotations.count;
...
}

You can also add to a proper MKMapView Delegate Method

您还可以添加适当的MKMapView委托方法

{
...
    NSArray *visibleAnnotatiOns= [[mapView annotationsInMapRect:mapView.visibleMapRect] allObjects];
    NSUInteger VisibleAnnotatiOnCounts= visibleAnnotations.count;
...
}

推荐阅读
author-avatar
闫小芽_209
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有