Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.05 KB | None | 0 0
  1. func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
  2. // add && view.annotation is ClusterAnnotationView
  3.         if view.annotation is MKUserLocation && view.annotation is ClusterAnnotationView  { return }
  4.        
  5.  
  6.         let mapAnnotation = view.annotation as! MapMark
  7.         companyNameLabel.text = mapAnnotation.titleName
  8.         companyAddressLabel.text = mapAnnotation.address
  9.         companyPhoneLabel.text = mapAnnotation.phone
  10.         distanseLabel.isHidden = true
  11.         getDirections(from: view)!.calculate { (response, error) in
  12.             self.distanseLabel.isHidden = false
  13.             if let response = response, let route = response.routes.first {
  14.                 self.distanseLabel.text = String(format: "%.0f", route.distance / 1609.344) + " mi"
  15.             } else {
  16.                 self.distanseLabel.text = "Error getting directions"
  17.             }
  18.         }
  19.         geolocationContainer.setViewHide(view: geolocationContainer, hidden: true)
  20.         bottomView.setViewHide(view: bottomView, hidden: false)
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement