Skip to content

Commit e1d799e

Browse files
committed
Add map playground
1 parent 3fec481 commit e1d799e

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
import MapKit
6+
#endif
7+
8+
struct MapPlayground: View {
9+
@State private var lima = MKCoordinateRegion(
10+
center: CLLocationCoordinate2D(latitude: -12.046, longitude: -77.043),
11+
span: MKCoordinateSpan(latitudeDelta: 0.12, longitudeDelta: 0.12)
12+
)
13+
@State private var cupertino = MKCoordinateRegion(
14+
center: CLLocationCoordinate2D(latitude: 37.334, longitude: -122.009),
15+
span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)
16+
)
17+
var body: some View {
18+
ScrollView {
19+
VStack(alignment: .leading, spacing: 0) {
20+
Example("Region with markers") {
21+
Map(coordinateRegion: $lima, markers: [
22+
MapMarker("Plaza Mayor", coordinate: CLLocationCoordinate2D(latitude: -12.046, longitude: -77.030)),
23+
MapMarker("Miraflores", coordinate: CLLocationCoordinate2D(latitude: -12.120, longitude: -77.030), tint: .blue),
24+
MapMarker("Callao", coordinate: CLLocationCoordinate2D(latitude: -12.055, longitude: -77.100), tint: .green),
25+
])
26+
}
27+
Example("Plain region") {
28+
Map(coordinateRegion: $cupertino)
29+
.frame(height: 140)
30+
.cornerRadius(12)
31+
}
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)