Keep a reminder of how to view the map in SWift UI.
Displaying a map in Swift UI was very easy. Let's display it like the image below.
import SwiftUI
import MapKit
struct ContentView: View {
@State private var location = MKCoordinateRegion(center: .init(latitude: 35.677735, longitude: 139.764740), latitudinalMeters: 500, longitudinalMeters: 500) //Coordinates to be displayed, range setting, display centered on the set coordinates
var body: some View {
Map(coordinateRegion: self.$location)
}
}
With the above code alone, the safe area creates spaces above and below the entire screen instead of the entire screen. So, by setting the code below, you can ignore the safe area and display the map on the entire screen.
.edgesIgnoringSafeArea(.all)
import SwiftUI
import MapKit
struct ContentView: View {
@State private var location = MKCoordinateRegion(center: .init(latitude: 35.677735, longitude: 139.764740), latitudinalMeters: 500, longitudinalMeters: 500) //Coordinates to be displayed, range setting, display centered on the set coordinates
var body: some View {
Map(coordinateRegion: self.$location)
.edgesIgnoringSafeArea(.all) //By setting this, the map will be displayed on the entire screen
}
}