68 lines
1.9 KiB
Swift
68 lines
1.9 KiB
Swift
//
|
|
// SeismicNetworksMapDetailViewController.swift
|
|
// Earthquake Network
|
|
//
|
|
// Created by Andrea Busi on 21/02/21.
|
|
// Copyright © 2021 Earthquake Network. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import MapKit
|
|
|
|
|
|
class SeismicNetworksMapDetailViewController: EQNBaseMapViewController {
|
|
|
|
// MARK: - State
|
|
|
|
let seismic: EQNSisma
|
|
override var availableFilters: [EQNFiltroMappa] {
|
|
// filters are not available for this map
|
|
[]
|
|
}
|
|
|
|
// MARK: - Init
|
|
|
|
init(seismic: EQNSisma) {
|
|
self.seismic = seismic
|
|
super.init()
|
|
}
|
|
|
|
required init?(coder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
// MARK: - Public
|
|
|
|
override func registerMapAnnotationViews() {
|
|
mapView.register(EQNCustomAnnotationView.self, forAnnotationViewWithReuseIdentifier: EQNCustomAnnotationView.Identifier)
|
|
}
|
|
|
|
override func loadDataSource() {
|
|
let annotation = EQNMapAnnotationSeismic(seismic: seismic)
|
|
updateMap(with: [annotation])
|
|
}
|
|
|
|
override func centerMap() {
|
|
// center map
|
|
let span = MKCoordinateSpan(latitudeDelta: 10.5, longitudeDelta: 10.5)
|
|
let region = MKCoordinateRegion(center: seismic.coordinate.coordinate, span: span)
|
|
mapView.setCenter(seismic.coordinate.coordinate, animated: false)
|
|
mapView.setRegion(region, animated: true)
|
|
}
|
|
|
|
// MARK: - Map
|
|
|
|
override func setupAnnotationView(for annotation: MKAnnotation, on mapView: MKMapView) -> MKAnnotationView? {
|
|
guard let annotation = annotation as? EQNMapAnnotationSeismic else {
|
|
return nil
|
|
}
|
|
|
|
let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: EQNCustomAnnotationView.Identifier, for: annotation) as! EQNCustomAnnotationView
|
|
|
|
annotationView.image = annotation.image
|
|
annotationView.title = annotation.title
|
|
|
|
return annotationView
|
|
}
|
|
}
|