MapView.swift 711 B

12345678910111213141516171819202122232425262728
  1. //
  2. // MapView.swift
  3. // Landmarks
  4. //
  5. // Created by Admin on 07.10.2020.
  6. //
  7. import SwiftUI
  8. import MapKit
  9. struct MapView: UIViewRepresentable {
  10. func makeUIView(context: Context) -> MKMapView {
  11. MKMapView(frame: .zero)
  12. }
  13. func updateUIView(_ uiView: MKMapView, context: Context) {
  14. let coordinate = CLLocationCoordinate2D(latitude: 34.011286, longitude: -116.166868)
  15. let span = MKCoordinateSpan(latitudeDelta: 2.0, longitudeDelta: 2.0)
  16. let region = MKCoordinateRegion(center: coordinate, span: span)
  17. uiView.setRegion(region, animated: true)
  18. }
  19. }
  20. struct MapView_Previews: PreviewProvider {
  21. static var previews: some View {
  22. MapView()
  23. }
  24. }