1

I am learning iOS development I want to show userTracking mode to follow with customer marker. Below is how I have tried to create marker on map

 @IBOutlet weak var mapKIT: MKMapView!
@objc func labelAction(_ sender: UIGestureRecognizer) {
        //Haptic Engine
        let impact = UIImpactFeedbackGenerator()
        impact.impactOccurred()
        
        let regionDistance:CLLocationDistance = 1000
        let coordinates = CLLocationCoordinate2DMake((latitude)!, (longitude)!)
        let regionSpant = MKCoordinateRegion(center: coordinates, latitudinalMeters: regionDistance, longitudinalMeters: regionDistance)
        let placeMark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)        
        mapKIT.isZoomEnabled = true
        
        mapKIT.setRegion(regionSpant, animated: true)
        mapKIT.layer.name = "You are here"
        if counter == 0{
            mapKIT.mapType = MKMapType.satellite
            counter = 1
        }
        if speeds! <= 0.9{
            mapKIT.addAnnotation(placeMark)
            mapKIT.userLocation.title = "You are here"
        }else{
            mapKIT.showsUserLocation = true
            mapKIT.userTrackingMode = .follow
        }

And down below is how am getting User Gps information.

var lastCoordinate:CLLocationCoordinate2D?
var latitude:CLLocationDegrees?
var longitude:CLLocationDegrees?
var muda:Date?
var speeds:Double?
    func locationManager(_ _manager:CLLocationManager, didUpdateLocations Location:[CLLocation]){
            if let location = Location.first{
                coordinate.text = "Your location \(location.coordinate.latitude.description) \(location.coordinate.longitude.description) - \(location.timestamp.description) "
                speed.text = "Your moving at speed of \(location.speed.description) course \(location.courseAccuracy.description)"
                altitude.text = "Your at altitude of \(location.altitude.description )"
                muda = location.timestamp
    
                latitude = location.coordinate.latitude
                longitude = location.coordinate.longitude
                muda = location.timestamp
                speeds = location.speed
                
            }

What I want is the marker I have create on map to move or to follow the moving direction in map.For now it's just create marker all over the place I have been.I apologies for my English I am using google translator

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.