You can Add your favorite places to a list to find them easily later. Manage your saved places
- UITableView
- Realm
- RatingControl
- CosmosStar
- MapVC
- User Location
Find out your location address
Take pictures of places
Sort by date added and by name
let locationManager = CLLocationManager()
func getDirections(for mapView: MKMapView, previousLocation: (CLLocation) -> ()) {
User Location Coordinates
guard let location = locationManager.location?.coordinate else {
showAlert(title: "Error", message: "Current location is not found")
return
}
The mode used to track the user location
locationManager.startUpdatingLocation()
previousLocation(CLLocation(latitude: location.latitude, longitude: location.longitude))
Route request
guard let request = createDirectionRequest(from: location) else {
showAlert(title: "Error", message: "Destination is not found")
return
}
Draw a route
let directions = MKDirections(request: request)
resetMapView(withNew: directions, mapView: mapView)
Route calculation
directions.calculate { (response, error) in
if let error = error {
print(error)
return
}
Fetch route
guard let response = response else {
self.showAlert(title: "Error", message: "Destinations are not available")
return
}
Route selection. Overlay routes
for route in response.routes {
mapView.addOverlay(route.polyline)
Focusing the map
mapView.setVisibleMapRect(route.polyline.boundingMapRect, animated: true)
Travel Time and Distance. %.1f - round up to 0,1
let distance = String(format: "%.1f", route.distance / 1000)
let timeInterval = route.expectedTravelTime
}
}
}