ios – Swift5 make a marker on maps


I’m studying iOS growth And I wish to create a marker on maps however after I keep to that place to given time frame then I can create a marker however when I’m strolling or shifting then the marker ought to transfer not create new marker.Right here under is how I achieved to create the marker.

@IBOutlet weak var mapKIT: MKMapView!

@objc func labelAction(_ sender: UIGestureRecognizer) {
        //Haptic Engine
        let impression = UIImpactFeedbackGenerator()
        impression.impactOccurred()
        
        let regionDistance:CLLocationDistance = 1000
        let coordinates = CLLocationCoordinate2DMake((latitude)!, (longitude)!)
        let regionSpant = MKCoordinateRegion(middle: coordinates, latitudinalMeters: regionDistance, longitudinalMeters: regionDistance)
       
        let placeMark = MKPlacemark(coordinate: coordinates, addressDictionary: nil)
        mapKIT.addAnnotation(placeMark)
        mapKIT.isZoomEnabled = true
        
        mapKIT.setRegion(regionSpant, animated: true)
        mapKIT.layer.title = "You're right here"
        if counter == 0{
            mapKIT.mapType = MKMapType.satellite tv for pc
            counter = 1
        }

And the perform under is how I get Gps data

var lastCoordinate:CLLocationCoordinate2D?
    var latitude:CLLocationDegrees?
    var longitude:CLLocationDegrees?
    var muda:Date?

func locationManager(_ _manager:CLLocationManager, didUpdateLocations Location:[CLLocation]){
        if let location = Location.first{
            coordinate.textual content = "Your location (location.coordinate.latitude.description) (location.coordinate.longitude.description) - (location.timestamp.description) "
            velocity.textual content = "Your shifting at velocity of (location.velocity.description) course (location.courseAccuracy.description)"
            altitude.textual content = "Your at altitude of (location.altitude.description )"

            latitude = location.coordinate.latitude
            longitude = location.coordinate.longitude
            muda = location.timestamp
            velocity = location.velocity

        }
        
    }

What I would like is to test for velocity which the telephone is shifting and replace the marker to maneuver with the consumer and never create a marker all of the place the consumer have been. Additionally I wish to create a marker when consumer keep to sure place for sure time.How can I obtain this. I apologies for my English am utilizing google translator.

Leave a Reply