我已经创建了一个MKMapView,但我需要在Swift 2中添加带有图像的多个注释,我该怎么做?
答案 0 :(得分:0)
首先,您必须创建一个MKAnnotationView,使用此功能创建您的标记:
.woocommerce ul.products li.product h3,
.woocommerce-page ul.products li.product h3
{text-align: center;}
创建标记:
internal func setupMarker(image:UIImage,long:Double,lat:Double,title:String,subtitle:String) -> MKAnnotationView{
var pinAnnotationView:MKAnnotationView!
var pointAnnotation:MKPointAnnotation!
pointAnnotation = MKPointAnnotation()
pointAnnotation.title = title
pointAnnotation.subtitle = subtitle
pointAnnotation.coordinate = CLLocationCoordinate2D(latitude:lat, longitude:long)
pinAnnotationView = MKPinAnnotationView(annotation: pointAnnotation, reuseIdentifier: nil)
pinAnnotationView.image = image
pinAnnotationView.canShowCallout = true
return pinAnnotationView
}
将标记添加到MapView
var marker = setupMarker(store.image.image, long: store.location.longitude, lat: store.location.latitude, param: "store",storeId: store.description))