Mercurial > public > geoquiz
view GeoQuiz/Controllers/MapController.swift @ 29:f5a2c2dab208
fix files structure
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Thu, 10 Nov 2022 10:27:28 +0100 |
parents | GeoQuiz/Models/Controllers/MapController.swift@425078c01194 |
children |
line wrap: on
line source
// // MapController.swift // GeoQuiz // // Created by Dennis Concepción Martín on 22/10/22. // import Foundation import MapKit class MapController: ObservableObject { @Published var image: UIImage? = nil func getMapImage(lat: Double, lon: Double) { let region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: lat, longitude: lon), span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) ) // Map options let mapOptions = MKMapSnapshotter.Options() mapOptions.region = region mapOptions.size = CGSize(width: 500, height: 500) mapOptions.pointOfInterestFilter = .excludingAll // Create the snapshotter and run it let snapshotter = MKMapSnapshotter(options: mapOptions) snapshotter.start { (snapshot, error) in if let snapshot = snapshot { self.image = snapshot.image } else if let error = error { print(error.localizedDescription) } } } }