Collecting Position Data¶
This document shows how to collect position data from the SDK.
PositionManager is the manager class which you should listen using an implementation of PositionManager.Listener in order to collect position data from the sdk. After you add an implementation of PositionManager.Listener as a listener to PositionManager and implement its onPositionManagerCalculatedLocation(CalculatedLocation calculatedLocation) callback, it will be notified at every position update. The CalculatedLocation object you receive from the callback parameter includes type, state, orientation, timestamp and some accuracy metrics in addition to the regular Location fields.
Pointr.getPointr()?.positionManager?.addListener(object : PositionManager.Listener {
override fun onPositionManagerCalculatedLocation(calculatedLocation: CalculatedLocation?) {
// Do operations with the new location
}
override fun onPositionManagerDetectedPositionLevelChange(level: Level) {}
override fun onPositionManagerPositionIsFading() {}
override fun onPositionManagerPositionIsLost() {}
override fun onPositionManagerPositioningServiceStateChangedTo(state: PositioningTypes.PositioningServiceState?) {}
})
You can check all API regarding position from Pointr Docs Center.
PTRPositionManager is the manager class which you should listen to in order to collect position data from the sdk. You can add a desired object of your app as a listener of PTRPositionManager and implement its func onPositionManagerCalculatedLocation(_ calculatedLocation: PTRCalculatedLocation) callback to be notified every time position data becomes available. The PTRCalculatedLocation object you receive via the callback includes type, state, orientation, timestamp and some accuracy metrics in addition to the regular PTRLocation fields.
class ExamplePointrStart: UIViewController, PTRPositionManagerDelegate {
override func viewDidLoad() {
let positionManager = Pointr.shared.positionManager
positionManager.addListener(self)
}
func onPositionManagerCalculatedLocation(_ calculatedLocation: PTRCalculatedLocation) {
// Do operations with the new location
}
}
You can check all API regarding position from [Pointr Docs Center](/docs/reference/ios/8.4/Protocols/PTRPositionManagerInterface.html).
Note
As with all managers in Pointr SDK, Pointr.State needs to be running in order to access the PositionManager