简体   繁体   English

通过 iPhone 中的代码显示 map 标注

[英]show map callout through code in iPhone

I have tried several things but am unable to solve it out.我尝试了几件事,但无法解决。

I have 10 custom annotations on the map depending upon the area visible.我在 map 上有 10 个自定义注释,具体取决于可见区域。

Now I have 2 buttons next and previous.现在我有 2 个按钮下一个和上一个。 Clicking on which the callout of annotation must get displayed.单击必须显示注释的标注。

ie if i click on next buton then callout of annotation 1 will appear and when i click next again then the callout of first will hide and callout of second will appear.即,如果我单击下一个按钮,则会出现注释 1 的标注,当我再次单击下一步时,第一个的标注将隐藏,而第二个的标注将出现。

I have tried out我试过了

[self.mapView selectAnnotation:self.nextSelectedAnnotationView.annotation animated:YES]

and

[self.mapView deselectAnnotation:self.selectedAnnotationView.annotation animated:YES];

But the main problem is how to get the annotation here??但主要问题是如何在这里获取注释?

I have tried NSArray* selectedAnnotations=self.mapview.annotations to get the annotations array我试过NSArray* selectedAnnotations=self.mapview.annotations来获取注释数组

id annotationView =[selectedAnnotations objectAtIndex:i];
[self.mapView selectAnnotation:annotationView animated:YES];

But no luck:(但没有运气:(

Any other way to solve my issue.??还有其他方法可以解决我的问题吗??

it may help you.它可能会帮助你。

 NSArray *selectedAnnotations = mapView.selectedAnnotations;
for(id annotationView in selectedAnnotations) {
    [mapView deselectAnnotation:[annotationView annotation] animated:NO];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM