This example demonstrates how to calculate a route and fly the camera to a traffic event along it. A route is computed between two waypoints (London and Paris), presented on the map, and the camera is then animated to centre on the first traffic event found on the route. The map remains fully interactive, supporting pan, pinch-zoom, rotate and tilt.
The route presented on the map with the camera centered on a traffic event
Once the worldwide road map is confirmed up to date, the callback is cleared so it fires only once, then a route is calculated between two Landmark waypoints with calculateRoute.
calculateRoute returns an error code synchronously, indicating whether the calculation could be started. A non-NoError value means it never started, so the onCompleted callback won't fire - the error is therefore reported here with an error dialog.
When routing completes, the first route is taken and its trafficEvents are read. If the route has no traffic events, an error dialog is shown; otherwise the route is presented on the map without auto-centering and the first traffic event is passed to flyToTraffic.
flyToTraffic animates the camera to the chosen traffic event with centerOnRouteTrafficEvent, framing it inside the free-space rectangle so it is not hidden behind the toolbar or the system bars.