Mercurial > public > geoquiz
comparison GeoQuiz/Helpers/CityMap.swift @ 7:d945e52b0704
implement dynamic map
author | Dennis C. M. <dennis@denniscm.com> |
---|---|
date | Tue, 04 Oct 2022 18:54:24 +0200 |
parents | 1946bbfde4af |
children | e09959b4e4a8 |
comparison
equal
deleted
inserted
replaced
6:1946bbfde4af | 7:d945e52b0704 |
---|---|
1 // | 1 // |
2 // CityMap.swift | 2 // CityMap.swift |
3 // GeoQuiz | 3 // GeoQuiz |
4 // | 4 // |
5 // Created by Dennis Concepción Martín on 24/9/22. | 5 // Created by Dennis Concepción Martín on 4/10/22. |
6 // | 6 // |
7 | 7 |
8 import SwiftUI | 8 import SwiftUI |
9 import MapKit | |
10 | 9 |
11 struct CityMap: View { | 10 struct CityMap: View { |
12 @State var region: MKCoordinateRegion | 11 @ObservedObject var game: CityGame |
13 | 12 |
14 var body: some View { | 13 var body: some View { |
15 Map(coordinateRegion: $region, interactionModes: MapInteractionModes()) | 14 Group { |
16 .clipShape(RoundedRectangle(cornerRadius: 20)) | 15 if let mapImage = game.mapImage { |
17 .shadow(radius: 10) | 16 Image(uiImage: mapImage) |
17 .resizable() | |
18 .scaledToFit() | |
19 .clipShape(RoundedRectangle(cornerRadius: 20)) | |
20 .shadow(radius: 10) | |
21 } else { | |
22 ProgressView() | |
23 } | |
24 } | |
18 } | 25 } |
19 } | 26 } |
20 | 27 |
21 struct CityMap_Previews: PreviewProvider { | 28 struct CityMap_Previews: PreviewProvider { |
22 static var region = MKCoordinateRegion( | |
23 center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), | |
24 span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5) | |
25 ) | |
26 | |
27 static var previews: some View { | 29 static var previews: some View { |
28 CityMap(region: region) | 30 CityMap(game: CityGame()) |
29 .frame(width: 300, height: 300) | |
30 } | 31 } |
31 } | 32 } |