项目作者: ram2386

项目描述 :
Create the application where user can track the car on the map, same like OLA and Uber application do.
高级语言: Swift
项目地址: git://github.com/ram2386/Track-Car.git
创建时间: 2020-01-30T11:48:52Z
项目社区:https://github.com/ram2386/Track-Car

开源协议:MIT License

下载


Track-Car

Track-Car makes it easy to add tracking functionalities to your iOS app!

Demo

Features

  • Use Combine framework for location handling
  • Use Decodable protocol for JSON parsing
  • Support Landscape mode
  • Dark mode

Requirements

  • iOS 13.0+
  • Xcode 11.0+
  • Swift 5.0+

Installation

Manually

Just download the project, drag and drop the “TrackCar” folder in your application.

Usage

  1. Create the LocationService and implement in your view controller

    1. class YourViewController: {
    2. let locationService = LocationService()
    3. }
  2. Subscribe the PassthroughSubject subject which send the location at 1 second interval

    1. cancelSubject = locationService.locationSubject
    2. .receive(on: DispatchQueue.main)
    3. .sink(receiveCompletion: { (completion) in
    4. switch completion {
    5. case .failure(let error):
    6. ....
    7. case .finished:
    8. break
    9. }
    10. }) { [weak self] (item) in
    11. self?.updateCarLocation(model: item)
    12. }
    13. locationService.setupTimerPublisher()

And cancel the subscriber when it no longer needs to receive elements. For ie. cancelSubject.cancel()

  1. Implement the updateLocationOnMap method of LocationService class where you need to pass the refernce of your MapView, location and MKAnnotation
    1. func updateCarLocation(model: CarModel) {
    2. self.locationService?.updateLocationOnMap(model: model, myAnnotation: myAnnotation, mapView: mapView)
    3. }

Roadmap

Feature

  • Add CocoaPods
  • Show the path on the map
  • Show the callout view when tapping on car icon

Improvements/To Do

  • Apply the smooth animation while moving the car on the map

License

Track-Car is available under the MIT license, see the LICENSE file for more information.