ContentView.swift
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | struct ContentView: View { @State var inputText: String = "" @State var dispSearchKey: String = "" var body: some View { VStack { TextField("キーワード", text: $inputText, prompt: Text("キーワードを入力してください")) .onSubmit { dispSearchKey = inputText } .padding() MapView(searchKey: dispSearchKey) } } } |
ContentView.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 | struct ContentView: View { @State var inputText: String = "" @State var dispSearchKey: String = "" @State var dispMapType: MKMapType = .standard var body: some View { VStack { TextField("キーワード", text: $inputText, prompt: Text("キーワードを入力してください")) .onSubmit { dispSearchKey = inputText } .padding() ZStack(alignment: .bottomTrailing){ MapView(searchKey: dispSearchKey, mapType: dispMapType) Button(action: { if dispMapType == .standard { dispMapType = .satellite } else if dispMapType == .satellite { dispMapType = .hybrid } else if dispMapType == .hybrid { dispMapType = .hybridFlyover } else if dispMapType == .hybridFlyover { dispMapType = .mutedStandard } else { dispMapType = .standard } }) { Image(systemName: "map") .resizable() .frame(width: 35.0, height: 35.0, alignment: .leading) } .padding(.trailing, 20.0) .padding(.bottom, 30.0) } } } } |
うーむ、これは凄いわ