-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorldView.swift
41 lines (35 loc) · 1.14 KB
/
WorldView.swift
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
//
// WorldView.swift
// Travel_app
//
// Created by Marcin Basinski on 11/10/2021.
//
import MapKit
import SwiftUI
struct WorldView: View {
@EnvironmentObject var locations: Locations
@State var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(latitude: 51.507222,
longitude: -0.1275),
span: MKCoordinateSpan(latitudeDelta: 40, longitudeDelta: 40))
var body: some View {
Map(coordinateRegion: $region, annotationItems: locations.places) {
location in
MapAnnotation(coordinate: CLLocationCoordinate2D(latitude: location.latitude, longitude: location.longitude)){
NavigationLink(destination: ContentView(location: location)){
Image(location.country)
.resizable()
.cornerRadius(10)
.frame(width: 80, height:40)
.shadow(radius: 3)
}
}
}
.navigationTitle("Locations")
}
}
struct WorldView_Previews: PreviewProvider {
static var previews: some View {
WorldView()
}
}