This example app demonstrates the following features:
- Calculate a route between two given pairs of coordinates then perform a navigation simulation along the route
- Navigation stats such as next turn icon, instructions and info are displayed in the top panel, as in Magic Earth
- Statistics relating to estimated time of arrival (ETA), remaining time and distance, are displayed in the bottom panel
When the example app is run, the scene is viewed from above. When the route calculation is completed a simulation will start.
- Create a custom navigation listener derived from
gem::INavigationListenerto receive navigation events, such as started, waypoint reached, or destination reached - Create an instance of a
CTouchEventListenerto make the map interactive, enabling touch events such as pan and zoom - Create an instance of
MapViewproducing an OpenGL context using ImGUI, passing in the touch event listener, and a custom GUI function,getUiRender - The custom GUI function has a button to calculate a route; latitude, longitude coordinates for a preset departure position, and a preset destination
position, are given using a
gem::LandmarkList, route preferences, such as a route for a car, fastest option, are set usinggem::RoutePreferences()and then a route is calculated usinggem::RoutingService().calculateRoute(); aProgressListeneris used to detect when the route calculation is complete, and if the result, stored using agem::RouteList, contains at least one route, the first route, at index 0, is added to the map to be rendered, usingmapView->preferences().routes().add() - Simulated navigation is started along the route using
gem::NavigationService().startSimulation() - The camera is set to follow the position indicator arrow using
mapView->startFollowingPosition(); - There is also a follow position button, to resume following the position indicator along the route, if the map is panned, which causes an exit from
follow position mode; this is resumed using
mapView->startFollowingPosition(); - There is a button to toggle display of units between miles/km
- This app is organized to look like Magic Earth, so it has a top and a bottom navigation panel, to display navigation statistics.
The next turn icon image is obtained using
navinstruct.getNextTurnDetails().getAbstractGeometryImage().render()where navinstruct is the navigation instruction,gem::NavigationService().getNavigationInstruction(); the icon image is loaded as a texture into the GPU usingBitmapImpl::LoadTextureIntoGPU()and then the texture id is passed toImGui::Image()to render it as an image. - The corresponding text instruction for the next turn is obtained using
navinstruct.getNextTurnInstruction()and also displayed; the other statistics, such as street name, time and distance to next turn are obtained from the navigation instruction in a similar fashion, as seen in the example. More statistics are available, as listed in theGEM_NavigationInstruction.hheader.
