SwiftUI 100 레시피/Maps
-
SwiftUI Maps 68 - 맵 타입 변경하기(일반,위성,하이브리드)SwiftUI 100 레시피/Maps 2022. 6. 28. 12:59
#1. ContentView import SwiftUI import MapKit struct ContentView: View { @State private var mapType: MKMapType = .standard var body: some View { VStack{ Picker("Select", selection: $mapType){ Text("Standard").tag(MKMapType.standard) Text("Satelite").tag(MKMapType.satellite) Text("Hybrid").tag(MKMapType.hybrid) }.pickerStyle(SegmentedPickerStyle()) MapView(mapType: mapType) } } } struct ContentVie..
-
SwiftUI Maps 67 - 사용자 위치 표시하기SwiftUI 100 레시피/Maps 2022. 6. 28. 12:32
#1. Info.plist 에서 권한 추가 (Privacy-Location When In Use Usage Description) #2. ContentView import SwiftUI import MapKit struct ContentView: View { @StateObject private var locationManager = LocationManager() var newRegion: Binding?{ guard let location = locationManager.location else { return MKCoordinateRegion.defaultRegion().asBindable() } let region = MKCoordinateRegion(center: location.coordina..
-
SwiftUI Maps 66 - 커스텀 주석(Annotations) 만들기SwiftUI 100 레시피/Maps 2022. 6. 28. 11:28
import SwiftUI import MapKit struct Place: Identifiable{ let id = UUID() let name: String let coordinate: CLLocationCoordinate2D } struct ContentView: View { @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.808208, longitude: -122.415802), latitudinalMeters: 5000, longitudinalMeters: 5000) let annotations = [ Place(name: "A지역", coordinate: CLLocationCoor..
-
SwiftUI Maps 65 - 지도에 주석(Annotations) 달기SwiftUI 100 레시피/Maps 2022. 6. 27. 18:36
import SwiftUI import MapKit struct Place: Identifiable{ let id = UUID() let name: String let coordinate: CLLocationCoordinate2D } struct ContentView: View { @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.808208, longitude: -122.415802), latitudinalMeters: 5000, longitudinalMeters: 5000) let annotations = [ Place(name: "A지역", coordinate: CLLocationCoor..
-
SwiftUI Maps 64 - 지도 표시하기SwiftUI 100 레시피/Maps 2022. 6. 27. 18:13
import SwiftUI import MapKit struct ContentView: View { @State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 37.5666805, longitude: 126.9784147), latitudinalMeters: 500, longitudinalMeters: 500) var body: some View { Map(coordinateRegion: $region) } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }