/
AnnotationSample.swift
44 lines (41 loc) · 1.22 KB
/
AnnotationSample.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
42
43
44
//
// AnnotationSample.swift
// MapKitSamplerForiOS17
//
// Created by yuji on 2024/03/13.
//
import SwiftUI
import MapKit
struct AnnotationSample: View {
var body: some View {
Map() {
Annotation(coordinate: .tokyoStation, anchor: UnitPoint(x: 2, y: -2)) {
Image(systemName: "tram.fill")
.foregroundStyle(.yellow)
.padding(8)
.background(
RoundedRectangle(cornerRadius: 8)
.fill(.blue))
} label: {
VStack {
// title
Text("東京駅")
.bold()
.foregroundColor(.white)
.padding([.top, .horizontal], 5)
// subtitle
Text("メインターミナル")
.foregroundColor(.white)
.padding([.bottom, .horizontal], 5)
}
.background(Color.black.opacity(0.7))
.cornerRadius(5)
}
.annotationTitles(.hidden)
.annotationSubtitles(.visible)
}
}
}
#Preview {
AnnotationSample()
}