Update UserLocationAnnotation to handle annotation selection.

This commit is contained in:
SBiOSoftWhare
2022-04-05 21:31:26 +02:00
parent 68238044ca
commit 3f2ab01579
@@ -17,26 +17,36 @@
import Foundation
import Mapbox
/// Base class to handle a map annotation
class LocationAnnotation: NSObject, MGLAnnotation {
// MARK: - Properties
// Title property is needed to enable annotation selection and callout view showing
var title: String?
let coordinate: CLLocationCoordinate2D
// MARK: - Setup
init(coordinate: CLLocationCoordinate2D) {
self.coordinate = coordinate
super.init()
}
}
/// POI map annotation
class PinLocationAnnotation: LocationAnnotation {}
/// User map annotation
class UserLocationAnnotation: LocationAnnotation {
// MARK: - Properties
var userId: String {
return avatarData.matrixItemId
}
let avatarData: AvatarInputProtocol
// MARK: - Setup
@@ -45,7 +55,8 @@ class UserLocationAnnotation: LocationAnnotation {
coordinate: CLLocationCoordinate2D) {
self.avatarData = avatarData
super.init(coordinate: coordinate)
super.title = self.avatarData.displayName ?? self.userId
}
}