Tag: mkannotationview

具有集群的MapView:如何在同一个视图上显示多个注释

我已经在mkmapview上集成了FBAnnotationClustering ,它完美地工作,但是当在同一个地方有多个注释时,我不能用正确的信息显示annotationView。 我试图通过注释循环,并显示在相同的视图(每个与标注button显示更多信息)。 到目前为止,我设法做一个标注工作,以显示底部的细节,但在注解视图显示它没有正确的标题,只有一个,所以它不是很有用。 所以我想知道,是否有可能在同一个视图上显示多个注释? 任何想法我怎么能实现这个? 这是我的集群类: class FBAnnotationCluster : NSObject { var coordinate = CLLocationCoordinate2D(latitude: 39.208407, longitude: -76.799555) var title:String = "cluster" var subtitle:String? = nil var annotations:[FBAnnotation] = [] } 我的单个注释类: class FBAnnotation : NSObject { var coordinate: CLLocationCoordinate2D var id: Int var title: String var subtitle: String var distance: String init(id: Int, […]

当轻击MKAnnotation时,防止MKMapView上的触摸事件被检测到

我有一个UITapGestureRecognizer,当用户点击Map时,它会隐藏和显示我的MKMap上的一个工具栏。 但是,当用户点击MKMapAnnotation时,我不希望地图以正常方式(上图)响应水龙头。 此外,当用户点击地图上的其他地方取消select一个MKAnnotation标注,我也不希望工具栏响应。 所以,只有在当前没有选定状态的MKAnnotations时,工具栏才会响应。 当用户直接点击注释时也不应该回应。 到目前为止,我正在尝试对地图上的轻拍手势做出反应的以下操作 – 但注释视图永远不会被检测到(第一个if语句),而且无论此方法如何,注释视图也会启动。 -(void)mapViewTapped:(UITapGestureRecognizer *)tgr { CGPoint p = [tgr locationInView:self.mapView]; UIView *v = [self.mapView hitTest:p withEvent:nil]; id<MKAnnotation> ann = nil; if ([v isKindOfClass:[MKAnnotationView class]])<—- THIS CONDITION IS NEVER MET BUT ANNOTATIONS ARE SELECTED ANYWAY { //annotation view was tapped, select it… ann = ((AircraftAnnotationView *)v).annotation; [self.mapView selectAnnotation:ann animated:YES]; } […]

Swift – 将圆angular设置为注释视图图像

这是我以前的线程,我把图像设置为注释视图引脚 Swift – 将arrays中的不同图像设置为注释引脚 现在我遇到了在注解视图图像上设置圆angular的问题。 cannot show callout with clipsToBounds enabled swift 似乎我必须select圆angular或显示标注,我真的不明白为什么这两个不能来。 有没有办法做到这一点? 这里是我的viewForAnnotation函数: func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { if !(annotation is RestaurantAnnotation) { return nil } let reuseId = "restaurant" var anView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) if anView == nil { anView = MKAnnotationView(annotation: annotation, reuseIdentifier: reuseId) anView.canShowCallout = false } […]

具有自定义视图和图像视图的MKAnnotationView

在我的地图应用程序,而不是显示一个别针,我想显示一个彩色的背景圆形图像。 背景的颜色(下面的图像是绿色的阴影)是dynamic的。 它将如下图所示: 我创build了TCircleView在“drawRect”中绘制颜色 为了显示类似的注释,我创build了TCircleView和UIImageView的对象,并将它们添加到MKAnnotationView对象中。 它看起来不错,如预期般可见。 但它不允许检测点击/触摸来显示呼叫。 我使用下面的代码: – (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { if ([annotation isKindOfClass:[MKPointAnnotation class]]) { return nil; } static NSString *annotationIdentifier = @"StickerPin"; MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier]; if (!annotationView) { annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier]; annotationView.canShowCallout = YES; } TCircleView* circleView = [[TCircleView alloc] init]; circleView.green = [postObj[@"severity"] […]

拖动我的MKAnnotationView后拖动地图不会移动MKAnnotationView

MKPinAnnotationView不允许您使用自定义图像作为“插针”并同时启用拖动,因为只要开始拖动,图像就会变回默认的插针。 因此,我使用MKAnnotationView而不是MKPinAnnotationView。 虽然使用MKAnnotationView而不是MKPinAnnotationView会使您的自定义图像显示为“引脚”,但不支持使用默认引脚获取的拖放animation。 无论如何,我的问题是,我将我的自定义MKAnnotationView拖动到地图上的新点后,然后移动地图本身,MKAnnotationView不会随地图一起移动。 -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { static NSString *defaultID = @"myLocation"; if([self.annotation isKindOfClass:[PinAnnotation class]]) { //Try to get an unused annotation, similar to uitableviewcells MKAnnotationView *annotationView = [self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultID]; //If one isn't available, create a new one if(!annotationView) { annotationView = [[MKAnnotationView alloc] initWithAnnotation:self.annotation reuseIdentifier:defaultID]; annotationView.canShowCallout = YES; annotationView.draggable = YES; annotationView.enabled […]

在地图视图中显示多个注释

我是新来映射视图在iOS SDK。 我想在地图视图中使用经纬度显示多个注释。基本上所有经纬度都是从服务器端以json格式来的。 我parsing所有经纬度,并将其保存在不同的数组中。 但是如何一次性显示所有注释。 我能够一次只显示一个注释。下面是我正在使用的单个注释的代码, zoomLocation.latitude = latmpa.doubleValue; zoomLocation.longitude = logmpa.doubleValue; annotationPoint = [[MKPointAnnotation alloc] init]; annotationPoint.coordinate = zoomLocation; annotationPoint.title = @"masjid…."; [mapView selectAnnotation:annotationPoint animated:YES]; [mapView addAnnotation:annotationPoint]; mapView.centerCoordinate = annotationPoint.coordinate; MKCoordinateSpan span; span.latitudeDelta = 1.5; span.longitudeDelta = 1.0; MKCoordinateRegion newRegion; newRegion.center = zoomLocation; newRegion.span = span; [mapView setRegion:newRegion animated:YES];

引脚在地图上放置时,在注释中显示地址

目前我可以在地图上放置别针。 现在我想让注解标题显示引脚被丢弃的地址。 我已经看了这个,但不能让我的工作: 将标注的标题设置为当前地址 代码在我的ViewController.m 更新。 – (void)addPinToMap:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state != UIGestureRecognizerStateBegan) return; CGPoint touchPoint = [gestureRecognizer locationInView:self.map]; CLLocationCoordinate2D touchMapCoordinate = [self.map convertPoint:touchPoint toCoordinateFromView:self.map]; CLLocation *currentLocation = [[CLLocation alloc] initWithLatitude:touchMapCoordinate.latitude longitude:touchMapCoordinate.longitude]; [self.geocoder reverseGeocodeLocation:currentLocation completionHandler:^(NSArray *placemark, NSError *error) { //initialize the title to "unknown" in case geocode has failed… NSString *annTitle = @"Address unknown"; […]

在IOS MapView中,是否有注释标题callback函数或设置目标的方法?

我正在显示一个自定义的MKAnnotationView,单击时显示一个标题。 我知道我可以使用: – (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view; 检测注释视图上的点击。 一旦用户点击这个AnnotationView,就会popup一个标题。 我想要做的是当标题被点击的时候去一个新的控制器。 所以我的问题是:有没有办法检测标题点击?

如何在相同的注解视图下更改mapkit中的引脚颜色(swift3)

我在mapkit中有两个引脚,都在同一个注释视图下,所以它使得两个引脚都是相同的颜色。 我怎样才能使针脚不同的颜色。 我想你好是红色和hellox是蓝色的。 import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet var jmap: MKMapView! override func viewDidLoad() { jmap.delegate = self; let hello = MKPointAnnotation() hello.coordinate = CLLocationCoordinate2D(latitude: 40, longitude: -73) jmap.addAnnotation(hello) let hellox = MKPointAnnotation() hellox.coordinate = CLLocationCoordinate2D(latitude: 34, longitude: -72) jmap.addAnnotation(hellox) } func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? […]

显示自定义多个引脚显示位置错误的引脚

这个问题已经困扰了我几个星期了! 我有一个标签栏应用程序。 在一个选项卡上input点,在另一个选项卡上,点显示在地图上。 针脚应该不同,取决于点的types。 我面临的问题是,每当我从一个标签切换到另一个标签时,图钉图像就会从应该更改为其他图像。 例如,如果我在地图上有四个点,三个显示为一个圆形,一个显示为三angular形,则三angular形将从一个点移动到另一个点。 图像似乎随机改变。 所以,这是代码: ViewController.m -(void) viewWillAppear:(BOOL)animated { // Select the type of map if (isMapSelected == NO) { self.mapView.mapType = MKMapTypeSatellite; } else { self.mapView.mapType = MKMapTypeStandard; } // Add region to the map (center and span) [self addRegion]; // Removing old annotation [self.mapView removeAnnotations:mapLocations]; // Initializing arrays for the […]