External Position Source Navigation
In this guide you will learn how to simulate navigation along a route defined by an external data source.
Navigation
A navigation is started similar to Route Simpulation With Instructions Example. The key difference is in the startSimulation(..)
method. Contine reading.
Creating an external data source
To create an external data source an array of coordinates must be provided. These coordinates would normally be provided by the backend but for our example a simple local array of coordinates will be used.
To start a navigation a destination must also be provided :
In the code below is shown how to create an external data source.
Let's break it down and understand what is happening!
The arrayListOf(EDataType.Position)
tells the factory that the data types that are going to be pushed in data source are of type position.
After an external data source is produced succesfully it's started and provided to PositionService
. The PositionService
receives a PositionListener
that will start navigation as soon as teh first valid position is received then remove itself.
After this PositioDate
will be fed to the source at fixed time intervals. The PositionData
must have : acquisitionTimestamp, latitude and longitude. However for a better representation extra data has been provided.
To get bearing value:
To get speed value: