FUIProfileMarkerAnnotationView
@available(iOS 11.0, *)
@MainActor
open class FUIProfileMarkerAnnotationView : MKMarkerAnnotationView
The FUIProfileMarkerAnnotationView inherits from the MKMarkerAnnotationView and is presented as an annotation on the MKMapView. It is used to distinguish between static points on a map and person location. The annotation can either display a profilePicture or a set of initials to represent the person being annotated.
Example Initialization and Configuration
@available(iOS 11.0, *)
class MyProfileMarker: FUIProfileMarkerAnnotationView {
override var annotation: MKAnnotation? {
willSet {
markerTintColor = UIColor.preferredFioriColor(forStyle: .map1)
glyphImage = FUIIconLibrary.map.marker.venue.withRenderingMode(.alwaysTemplate)
}
}
}
Register within the viewDidLoad()
if #available(iOS 11.0, *) {
mapView.register(MyProfileMarker.self, forAnnotationViewWithReuseIdentifier: MKMapViewDefaultAnnotationViewReuseIdentifier)
} else {
// Fallback on earlier versions
}
let point1 = MKPointAnnotation()
point1.coordinate = CLLocationCoordinate2D(latitude: 37.3318, longitude: -122.0312)
let point2 = MKPointAnnotation()
point2.coordinate = CLLocationCoordinate2D(latitude: 37.3988313, longitude: -122.1487375)
let annotations = [point1 as MKAnnotation, point2 as MKAnnotation]
mapView.addAnnotations(annotations)
mapView.showAnnotations(annotations, animated: true)
Set the annotation view in the mapView(_:viewFor:) method.
var view: MKAnnotationView!
if let pointAnnotation = annotation as? MKPointAnnotation {
if #available(iOS 11.0, *) {
if pointAnnotation.coordinate.latitude == 37.3318 {
view = FUIProfileMarkerAnnotationView(annotation: pointAnnotation, reuseIdentifier: "cell")
(view as! FUIProfileMarkerAnnotationView).glyphText = "ME"
return view
} else {
view = FUIProfileMarkerAnnotationView(annotation: pointAnnotation, reuseIdentifier: "cell")
(view as! FUIProfileMarkerAnnotationView).glyphImage = #imageLiteral(resourceName: "ProfilePic").withRenderingMode(.alwaysOriginal)
(view as! FUIProfileMarkerAnnotationView).selectedGlyphImage = #imageLiteral(resourceName: "ProfilePic").withRenderingMode(.alwaysOriginal)
return view
}
} else {
// Fallback on earlier versions
return nil
}
}
return view
Note:
- Set the
profileImageto a 24x24 icon.
-
An optional
Stringrepresenting the initials of the person being annotated. Font style is fixed and does not change with accessibility.glyphTextis only displayed when there is noglyphImageavailable and is limited to 2 characters.Declaration
Swift
@MainActor override open var glyphText: String? { get set } -
Profile image to display when the annotationView is first loaded.
Declaration
Swift
@MainActor override open var glyphImage: UIImage? { get set } -
Optional profile image to display when the annotationView is in a selected state. Will use glyphImage if not supplied.
Declaration
Swift
@MainActor override open var selectedGlyphImage: UIImage? { get set }
-
An initializer that instantiates a
FUIProfileMarkerAnnotationViewwith some reuseIdentifier. Sets the tint color to a default value of.map1Declaration
Swift
@MainActor override public init(annotation: MKAnnotation?, reuseIdentifier: String?)