44 lines
1.1 KiB
Swift
44 lines
1.1 KiB
Swift
//
|
|
// EQNMapAnnotationUserReport.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Andrea Busi on 06/03/21.
|
|
// Copyright © 2021 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
|
|
class EQNMapAnnotationUserReport: NSObject, MKAnnotation {
|
|
|
|
var coordinate: CLLocationCoordinate2D
|
|
|
|
private let magnitute: Int
|
|
private let date: Date
|
|
|
|
// MARK: - Init
|
|
|
|
init(report: EQNSegnalazione) {
|
|
self.coordinate = CLLocationCoordinate2D(latitude: report.coordinate.coordinate.latitude, longitude: report.coordinate.coordinate.longitude)
|
|
self.magnitute = report.magnitude
|
|
self.date = report.date
|
|
|
|
super.init()
|
|
}
|
|
|
|
// MARK: - Public
|
|
|
|
var image: UIImage? {
|
|
switch magnitute {
|
|
case 1: return UIImage(named: "star_report_green")
|
|
case 2: return UIImage(named: "star_report_yellow")
|
|
case 3: return UIImage(named: "star_report_red")
|
|
default: return nil
|
|
}
|
|
}
|
|
|
|
var title: String? {
|
|
EQNUtility.formattedTimeDifference(from: date)
|
|
}
|
|
}
|