title: How to calculate the distance travelled by user from current location in swift 3.0
body: <p>I am using UImapkit &amp; core location frameworks
  How will I get the total polyLine distance &amp; travelled time </p>
  
  <p>this my code</p>
  
  <pre><code>func locationManager(_ manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!) {
  
  
  
        if let oldLocationNew = oldLocation as CLLocation?{
          let oldCoordinates = oldLocationNew.coordinate
  
  
          let newCoordinates = newLocation.coordinate
          var area = [oldCoordinates, newCoordinates]
          print(area)
          let polyline = MKPolyline(coordinates: &amp;area, count: area.count)
          mkMapView.add(polyline)
  
  
      }
  
  //calculation for location selection for pointing annoation
      if (previousLocation as CLLocation?) != nil{
  
          if previousLocation.distance(from: newLocation) &gt; 10 {
              addAnnotationsOnMap(newLocation)
              previousLocation = newLocation
          }
      }else{
          //case if previous location doesn't exists
          addAnnotationsOnMap(newLocation)
          previousLocation = newLocation
      }
  }
  </code></pre>