×
Calculate Route | Maps SDK for C++ | General Magic Calculate Route — Maps & Navigation SDKs documentation
Skip to content

Calculate Route

Calculate a route and show it on map.

Calculate Route

Use case

Calculate a route between two given pairs of coordinates then display it on map.

How to use the sample

First, get an API key token, see the Getting Started guide.

Download the Maps & Navigation SDK for C++ archive file for Linux or Windows

When you open the sample, you’ll be viewing the scene from above. A fly will be performed to the calculated route.

How it works

  1. Create a MapViewListener, OpenGLContext and MapView.

  2. Create a RouteList, a LandmarkList with two Landmarks in it and a RoutePreferences object.

  3. Call the RoutingService using RouteList, LandmarkList, RoutePreferences and the progress listener.

  4. Once the route calculation operation completes, add the first calculated route to the MapViewPreferences routes collection.

  5. Instruct the MapView to center on the first route.

C++ Examples

Maps SDK for C++ Examples can be downloaded or cloned with Git