Track-Car makes it easy to add tracking functionalities to your iOS app!
- Use Combine framework for location handling
- Use Decodable protocol for JSON parsing
- Support Landscape mode
- Dark mode
- iOS 13.0+
- Xcode 11.0+
- Swift 5.0+
Just download the project, drag and drop the "TrackCar" folder in your application.
- Create the LocationService and implement in your view controller
class YourViewController: {
let locationService = LocationService()
}
- Subscribe the PassthroughSubject subject which send the location at 1 second interval
cancelSubject = locationService.locationSubject
.receive(on: DispatchQueue.main)
.sink(receiveCompletion: { (completion) in
switch completion {
case .failure(let error):
....
case .finished:
break
}
}) { [weak self] (item) in
self?.updateCarLocation(model: item)
}
locationService.setupTimerPublisher()
And cancel the subscriber when it no longer needs to receive elements. For ie. cancelSubject.cancel()
- Implement the updateLocationOnMap method of LocationService class where you need to pass the refernce of your MapView, location and MKAnnotation
func updateCarLocation(model: CarModel) {
self.locationService?.updateLocationOnMap(model: model, myAnnotation: myAnnotation, mapView: mapView)
}
- Add CocoaPods
- Show the path on the map
- Show the callout view when tapping on car icon
- Apply the smooth animation while moving the car on the map
Track-Car
is available under the MIT license, see the LICENSE file for more information.