-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch peer reports - 24h
More file actions
56 lines (47 loc) · 2.02 KB
/
fetch peer reports - 24h
File metadata and controls
56 lines (47 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import MapKit
import OpenStreetMap
class LitterReportsViewController: UIViewController {
// MARK: - Properties
private let mapView = MKMapView()
private let overlays = OpenStreetMap.Overlays()
// MARK: - View Lifecycle
override func viewDidLoad() {
super.viewDidLoad()
// Add the map view to the view hierarchy
view.addSubview(mapView)
// Set the map view's constraints so that it fills the entire view
mapView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
mapView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
mapView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
mapView.topAnchor.constraint(equalTo: view.topAnchor),
mapView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
])
// Add the CleanAppMap overlay to the map view
overlays.addOverlay(named: "CleanAppMap") { [weak self] error in
guard let self = self else { return }
if let error = error {
print("Error adding CleanAppMap overlay: \(error)")
} else {
self.mapView.addOverlay(self.overlays.lastOverlay!)
}
}
// Set the map view's delegate to receive callbacks for map rendering and user interaction
mapView.delegate = self
}
// MARK: - Private
private func fetchLitterReports(in location: CLLocationCoordinate2D, radius: Double, timestamp: Date) {
// TODO: Implement code to fetch litter reports
// 1. Use the OpenStreetMap API to query for litter reports in the specified location and time range
// 2. Add annotations to the map view for each litter report
}
}
extension LitterReportsViewController: MKMapViewDelegate {
func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
// Use the OpenStreetMap library to render the CleanAppMap overlay
return overlays.renderer(for: overlay)
}
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
// TODO: Implement code to handle user selection of a litter report annotation
}
}