我正在将多个注释加载到我的 map View 中。加载 map 时,这些注释会显示为图钉。
通过使用下面的代码,我可以直接显示一个注释的标题,但对于剩余的注释,用户需要点击图钉才能看到标题。
我想在 Mapview 加载时显示所有注释的标题而不触摸注释引脚
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];
提前致谢..
Best Answer-推荐答案 strong>
更新这似乎确实是不可能的——至少对于 map View 注释 API 来说是不可能的。尽管存在 select 和 deselect 方法,并且 selected annotations 属性是一个数组,但似乎一次只能选择一个 annotation。
您似乎需要按照此答案中的建议创建自定义注释 View - Multiple annotation callouts displaying in MKMapView
关于ios - 加载 map 时如何直接显示多个注释的标题,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/24253631/
|