Navigation SDK provides a comprehensive toolkit for integrating basic & advanced navigation capabilities into your Android applications. Whether you're developing a mobile navigation app, a fleet management solution, or a location-based service, our SDK offers the tools you need to deliver seamless and reliable navigation experiences to your users. With the Navigation SDK, you can access a wide range of features, including real-time turn-by-turn navigation, route planning, traffic-aware routing, and waypoint addition. Our SDK is designed to be easy to integrate, allowing you to focus on building compelling navigation experiences without the complexity of managing underlying navigation logic.
Purpose
The primary purpose of the Ola-Maps-Navigation SDK is to enable developers to integrate mapping, route preview and turn-by-turn navigation functionalities into their Android applications seamlessly.
Pre-Requirements for Setup
1. Version Required:
minSdkVersion: 21
Java sourceCompatibility: JavaVersion.VERSION_11
2. GPS Permission:
Ensure that your application has the necessary permissions to access the device's GPS.
GPS permission is required to load maps effectively.
Setting Up the SDK
1. Download SDK:
Obtain the OlaMapSDK.aar SDK file.
2. Add SDK Dependency:
Place the SDK file in your project's libs directory.
Include the library in your project by adding the following dependencies to your app-level build.gradle file.
3. Define view in xml:
Add OlaMapView to your XML layout file.
We integrate the OlaMapView widget into the XML layout of your activity.
4. Map view initialization:
Obtain an instance of OlaMapView using binding or findViewById.
Implement MapStatusCallback listener in your Activity.
Initialize the OlaMaps Navigation SDK using your custom configuration via the initialize() method of OlaMapView.
Override the onMapReady() method to define actions to be performed when the map is ready.
Upon receiving the OnMapReady callback, the Ola-Map is loaded, and further functionalities can be utilized.
Features
Route Preview
Riding Mode
Turn-by-turn or navigation
Route Preview
Route preview offers users a comprehensive overview of multiple routes between destinations, presenting ETA, distance, and potential traffic conditions. This allows users to compare and select the most optimal route tailored to their preferences, ensuring a smooth and efficient journey.
API Call:
Call the route direction API to obtain route information.
Transformation:
Transform the API response route data into the SDK's DirectionsRoute class asynchronously.
NavigationMapRoute:
Create an instance of NavigationMapRoute using getNavigationMapRoute() method.
Route Display:
Use addRoutesForRoutePreview() method of NavigationMapRoute to display the routes.
Route Removal:
To remove route preview, call removeRoute() method.
Marker Removal:
Remove all markers using removeAllMarkers() method.
Render the routes on the map(with traffic):
Transform Route Data, Create an instance of NavigationMapRoute, and addRoutesForRoutePreview() method to display the routes.
To enable the feature you have to follow the below code snippet.
Show ETA view:
To Show the ETA in your route you have to add the below style in your xml OlaMapView Widget.
Customization of the route line, markers:
You can customize the line width, different traffic signal colors, line shield color of your RouteLines in your .style file.
Remove Route Preview and All Markers:
Riding Mode
Bike/car Mode:
By Default the mode is Bike/Car Mode (so no need to write extra code).
Walk Mode:
To set up the NavigationMapRoute for walking navigation , you can use the setWalkingProfile(true) method. This method enables the walking profile.
Turn-by-turn or navigation
Turn-By-Turn navigation provides users with step-by-step guidance throughout their journey, offering clear and concise directions at each intersection or maneuver point. This feature ensures users stay on track by indicating upcoming turns, lane changes, and points of interest along the way, enhancing navigation accuracy and convenience for a seamless travel experience.
Initialization:
Ensure that the route API response is transformed intoDirectionsRoutedata.
Listener Implementation:
ImplementNavigationStatusCallback and RouteProgressListener.
Listener Registration:
Register listeners using addRouteProgressListener() and registerNavigationStatusCallback()methods.
NavigationViewOptions:
Create an instance of NavigationViewOptions using getNavigationViewOptions(directionsRoute) method.
Start Navigation:
Initiate turn-by-turn navigation using startNavigation(NavigationViewOptions) method.
Route Removal:
To remove routes, call removeRoute() method.
Listener Removal:
Remove listeners using removeListeners() method.
Marker Removal:
Remove all markers using removeAllMarkers() method.
Render route:
Transform Route Data, Create an instance of NavigationMapRoute, and addRoutesForRoutePreview() method to display the routes.
Remove Turn-By-Turn, Route and All Markers:
Notify route progress changes:
Implement RouteProgressListener to get the turn-by-turn instructions.
Dynamic zoom level:
OlaMaps handles the dynamic zoom level while navigating. It automatically zooms in and out and rotates the map according to the turns and road.
Voice navigation:
This feature helps users to listen to the route instruction in voice.
To enable voice instructions in the NavigationMapRoute, you can use the OlaMapView.setVoiceInstructionEnabled(true) method. This method activates voice guidance, providing audio cues during navigation.