简体   繁体   English

如何在mkmapview上显示多个图钉

[英]How to show Multiple Pins on mkmapview

I want to show multiple pin annotations on a mapview. 我想在地图视图上显示多个图钉注释。

I am getting multiple hotel location lat long from server and i have store them in NSMutableArray , now I want to show these lat long value on my mapview. 我从服务器获取了多个酒店位置纬度,并将它们存储在NSMutableArray ,现在我想在我的mapview中显示这些纬度值。

Every thing you need is here: MKMApView and here MKAnnotations 您需要的所有东西都在这里: MKMApView和这里MKAnnotations

Some a nice example code: WeatherMap 一些不错的示例代码: WeatherMap

You need to create a model object that conforms to the MKAnnotation protocol. 您需要创建一个符合MKAnnotation协议的模型对象。 At the very least, it should implement the coordinate method (which returns a CLLocationCoordinate2D struct for your latitude and longitude). 至少,它应该实现coordinate方法(该方法将为您的纬度和经度返回CLLocationCoordinate2D结构)。 If you want to display a callout for the map pin, you'll also need to implement the title method. 如果要显示地图图钉的标注,则还需要实现title方法。

You should create one of these objects for each lat,lon pair, and store these in your array. 您应该为每个纬度对创建这些对象之一,并将其​​存储在数组中。 Then call the addAnnotations: on your mapView with the array of objects 然后在mapView上使用对象数组调用addAnnotations:

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

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