Skip to content

Live Mapping

Eric Internicola edited this page Jan 6, 2019 · 2 revisions

Prerequisites

  • See the Getting Started guide for the prerequisites
  • It's assumed you've already installed GeoTrackKit
  • It's assumed you've already updated your Info.plist to allow access to Location Services

Live Mapping with GeoTrackKit

Overview

  1. Import GeoTrackKit
  2. Add a map to your view controller: @IBOutlet weak var liveMapView: GeoTrackMap!
  3. Register with NotificationCenter for the Notification.Name.GeoTrackKit.didUpdateLocations notification
  4. When you catch that event update the map

Code Examples:

Importing GeoTrackKit:

import GeoTrackKit

Registering with Notification Center:

NotificationCenter.default.addObserver(self, 
            selector: #selector(locationDidUpdate(_:)), 
            name: Notification.Name.GeoTrackKit.didUpdateLocations, 
            object: nil)
@objc
func locationDidUpdate() {
    guard let track = GeoTrackManager.shared.track else {
        return
    }
    liveMapView.model = UIGeoTrack(with: track)
}

Reference Screenshot

live_tracking

Clone this wiki locally