Skip to content

Commit 5fac865

Browse files
committed
Removed unused code from MapView class.
1 parent 1c55c74 commit 5fac865

3 files changed

Lines changed: 6 additions & 20 deletions

File tree

SwiftUI-MapView/Coordinator/MapViewCoordinator.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
import Foundation
1010
import MapKit
1111

12-
12+
/*
13+
Coordinator for using UIKit inside SwiftUI.
14+
*/
1315
class MapViewCoordinator: NSObject, MKMapViewDelegate {
16+
1417
var mapViewController: MapView
1518

1619
init(_ control: MapView) {

SwiftUI-MapView/Map View/MapView.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,6 @@ struct MapView: UIViewRepresentable {
3131
view.delegate = context.coordinator
3232
view.addAnnotations(landmarks)
3333
}
34-
35-
36-
class MapView: NSObject, MKMapViewDelegate {
37-
38-
var mapViewController: MapView
39-
40-
init(_ control: MapView) {
41-
self.mapViewController = control
42-
}
43-
44-
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView?{
45-
let annotationView = MKAnnotationView(annotation: annotation,
46-
reuseIdentifier: "customView")
47-
annotationView.canShowCallout = true
48-
annotationView.image = UIImage(named: "locationPin")
49-
return annotationView
50-
}
51-
}
5234
}
5335

5436
struct MapView_Previews: PreviewProvider {

SwiftUI-MapView/SceneDelegate.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
2020
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
2121

2222
// Create the SwiftUI view that provides the window contents.
23-
let contentView = MapView().edgesIgnoringSafeArea(.top)
23+
let contentView = MapView()
24+
.edgesIgnoringSafeArea(.top)
2425

2526
// Use a UIHostingController as window root view controller.
2627
if let windowScene = scene as? UIWindowScene {

0 commit comments

Comments
 (0)