Live Navigation
The NaviSession class contains all the logic and related operations required for navigation, such as calculations, analog navigation, intersection magnification control, and electronic eye broadcast control. Navigation positioning provides an interface that allows users to use custom positioning methods to provide the GPS information necessary for navigation. Users can also customize the voice announcement logic.
The navigation initialization code example is as follows:
/** * Initialize navigation basic parameters */ // Set navigation basic parameters mNaviSetting = NaviSetting.getInstance(); // Initialize the route plan NaviSessionParams params = new NaviSessionParams(); // Navigation initialization parameter configuration information /** * Configure the submodule used: cameraWarning (electronic eye module); expandView (magnified image module); * arrowRenderer (turning arrow drawing module); highwayGuide (high speed mode module); * speedLimitWarning (speed limit setting module); adminSpeaker (administrative area broadcast) */ // Is it enabled to enlarge the line at the line? params.enableOnlineJunctionView = true; // Use the GPS module positioning provided by the engine params.useNaviCoreGPS = true; // Whether the route result is automatically adopted for navigation after the completion of the calculation. params.autoTakeRoute = true; // Is it automatically recalculated after yaw? params.autoReroute = true; // Get the navigation instance mNaviSession = NaviSession.getInstance(); // Initialize the navigation engine module. The NaviSession module related resources used to initialize the engine should be called during the application initialization phase. mNaviSession.init(this, this, params); // The default navigation state is paused mNaviSession.pauseNavi(); // default online navigation mNaviSession.setNaviMode(NaviSession.Mode.offline); // The generation mode of the current route details mNaviSetting.setRouteDirectionsFlag(RouteBase.DirectionsFlag.origin); /** * Set the way to calculate: * Single way NaviSession.RouteMethod.single * Multi-rule NaviSession.RouteMethod.multipleRule * Multiple results NaviSession.RouteMethod.multipleResult **/ mNaviSetting.setRouteMethod(NaviSession.RouteMethod. single); // default online query mNaviSetting.setPoiQueryMode(PoiQuery.Mode.online);
Real-time navigation, also known as GPS navigation, is a navigation that is driven by continuous GPS positioning information for the actual navigation process. After the route is successfully planned (driving or walking), you can start navigating. The sample code is as follows:
// real-time navigation mNaviSession.endManeualStartState(); // End manual start state mNaviSession.enableSound(true); // Open real-time voice announcement // Click the navigation button to resume navigation, the navigation starts, and the navigation state is set to the pause state by default when the navigation is initialized. if (mNaviSession.isNaviPaused()) { mNaviSession.resumeNavi(); }