This example demonstrates how to reconstruct a route from a GPX track. The Routing API from the Maps SDK uses the supportingPoints
parameter to reconstruct a route from a sequence of points when planning a route. In the example a GPX file is read from the app assets
directory, and the track points from the file passed as supporting points when the route is calcuated. The route path returned by the Routing API is drawn on the map. For more information on using supporting points see Custom routes in the SDK documentation.
To simplify parsing the GPX file the example uses the Android GPX Parser library.
-
To run the example you'll need an API key with the Map Display and Routing with Extended Guidance APIs enabled.
-
Open the project in Android Studio, the file
local.properties
will be generated in your project level directory, and add the following code to local.properties, replacingYOUR_API_KEY
with your API key.
API_KEY=YOUR_API_KEY
- Save the file and run the app.