如何在加载地图时直接显示多个注释的标题

如何在加载地图时直接显示多个注释的标题

本文介绍了如何在加载地图时直接显示多个注释的标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在将多个注释加载到我的地图视图中。加载地图时,这些注释显示为图钉。

I am loading Multiple annotations onto my map view. These annotations displays as a pin when the map is loaded.

通过使用以下代码,我可以直接显示一个注释的标题,但对于剩余的注释,用户需要点击在要查看标题的引脚上。

By using the below code i can display title directly for one annotation, but for remaining annotations user is required to tap on the pin for title to see.

我想在没有触及注释引脚的情况下显示Mapview加载时所有注释的标题

I want to display the title for all the annotations when the Mapview Loaded without touching the annotation pin

NSMutableArray * locations = [[NSMutableArray alloc] init];

_myAnn = [[MKPointAnnotation alloc] init];
_locationCoordinate.latitude = 27.175015;
_locationCoordinate.longitude = 78.042155;
_myAnn.coordinate = _locationCoordinate;
_myAnn.title = @"A";
[locations addObject:_myAnn];

_myAnn = [[MKPointAnnotation alloc] init];
_locationCoordinate.latitude = 28.171391;
_locationCoordinate.longitude = 79.037090;
_myAnn.coordinate = _locationCoordinate;
_myAnn.title = @"B";
[locations addObject:_myAnn];

_myAnn = [[MKPointAnnotation alloc] init];
_locationCoordinate.latitude = 29.169005;
_locationCoordinate.longitude = 80.043206;
_myAnn.coordinate = _locationCoordinate;
_myAnn.title = @"C ";
[locations addObject:_myAnn];

[self.map_View addAnnotations:locations];

  // i am using below method to display title for one annotation

      // [self.map_View selectAnnotation:_myAnn animated:YES];

     for (MKPointAnnotation *annotation in locations) {
  [self.map_View selectAnnotation:annotation animated:NO];
  }

MKCoordinateSpan span;
Span. latitudeDelta = 10;
Span. longitudeDelta = 10;

MKCoordinateRegion region;

region.span = span;
region.center = _locationCoordinate;

[self.map_View setRegion:region animated:YES];

先谢谢..

推荐答案

更新这似乎确实无法做到 - 至少没有地图视图注释API。尽管存在select和deselect方法,并且选定的annotations属性是一个数组,但似乎一次只能选择一个注释。

Update It does indeed seem that this isn't possible - at least not with the map view annotation APIs. Despite the existence of the select and deselect methods and the selected annotations property being an array, it seems that only a single annotation can be selected at a time.

它看起来像您将需要按照本答案中的建议创建自定义注释视图 -

It looks like you will need to create a custom annotation view as suggested in this answer - Multiple annotation callouts displaying in MKMapView

这篇关于如何在加载地图时直接显示多个注释的标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 17:46