2

I want to go to new SwiftUI View by tapping a pin annotation I have made a mapView and pin annotation on it I want to go to a SwiftUI view by Tapping on this pin how can I go to SwiftUi view in Uiviewrepresentable View

this is my mapView

func updateUIView(_ view: MKMapView, context: Context) {
let locationManager = CLLocationManager()
    let path = Datas.path
    var locationsDic: [[String: Any]] = [["latitude": 0, "longitude": 0],["latitude": 0, "longitude": 0],["latitude": 0, "longitude": 0]]

    view.showsUserLocation = true

    locationManager.requestAlwaysAuthorization()

    locationManager.requestWhenInUseAuthorization()

    if CLLocationManager.locationServicesEnabled() {
        locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters
        locationManager.startUpdatingLocation()

        DispatchQueue.main.asyncAfter(deadline: .now() + 1.0, execute: {
            let locValue:CLLocationCoordinate2D = locationManager.location!.coordinate


            let coordinate = CLLocationCoordinate2D(
                latitude: locValue.latitude, longitude: locValue.longitude)

            locationsDic[0]["latitude"] = locValue.latitude.advanced(by: 0.0)
            locationsDic[0]["longitude"] = locValue.longitude.advanced(by: 0.0)

            (locationsDic as NSArray).write(toFile: path, atomically: true)


            let span = MKCoordinateSpan(latitudeDelta: 0.02, longitudeDelta: 0.02)
            let region = MKCoordinateRegion(center: coordinate, span: span)
            view.setRegion(region, animated: true)


            let originAnnotation = MKPointAnnotation()
            originAnnotation.title = "origin"
            originAnnotation.coordinate = CLLocationCoordinate2D(latitude: 37.332072300, longitude: -122.011138100)


            view.addAnnotation(originAnnotation)



        })



    }
    locationsDic = NSArray(contentsOfFile: path) as! [[String: Any]]}} 
Community
  • 1
  • 1
Alireza12t
  • 377
  • 1
  • 4
  • 14

0 Answers0