How to use Mappls Direction Plugin in android application?

Mappls Direction Plugin is a ready to use Fragment to show the Routes in an Android platform. It offers the following basic functionalities:

  1. Takes support of Mappls Place search for searching locations of origin, destinations and via points.
  2. It allows to use origin and destinations in Mappls digital address (semicolon separated) mapplsPin or WGS 84 geographical coordinates both.
  3. The ability to set the vehicle profile like driving, and biking.
  4. Easily set the resource for traffic and ETA information.
    For more info visit here : mappls-android-sdk/docs/v1.0.7/Direction-Widget.md at main · mappls-api/mappls-android-sdk · GitHub

  1. Add below dependency in your app-level build.gradle file.
implementation 'com.mappls.sdk:direction-ui:2.1.0'
  1. Add your API keys to the SDK (in your application’s onCreate() or before using map)
MapplsAccountManager.getInstance().setRestAPIKey(getRestAPIKey());  	
MapplsAccountManager.getInstance().setMapSDKKey(getMapSDKKey());  		
MapplsAccountManager.getInstance().setAtlasClientId(getAtlasClientId());  	
MapplsAccountManager.getInstance().setAtlasClientSecret(getAtlasClientSecret());
  1. Add Direction Widget using direction fragments
DirectionFragment directionFragment = DirectionFragment.newInstance();  
  
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, directionFragment, DirectionFragment.class.getSimpleName())    
        .commit();  
  
                            //OR  
DirectionFragment directionFragment = DirectionFragment.newInstance(directionOptions);  
  
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, directionFragment, DirectionFragment.class.getSimpleName())    
        .commit();  

You can use DirectionOptions to set the properties of direction widget:

  1. resource(String): Below are the available resource:
  • DirectionsCriteria.RESOURCE_ROUTE (Default): to calculate a route & its duration without considering traffic conditions.
  • DirectionsCriteria.RESOURCE_ROUTE_ETA: get the updated duration of a route considering live traffic; Applicable for India only “region=ind” and “rtype=1” is not supported. This is different from route_traffic; since this doesn’t search for a route considering traffic, it only applies delays to the default route.
  • DirectionsCriteria.RESOURCE_ROUTE_TRAFFIC:
    to search for routes considering live traffic; Applicable for India only “region=ind” and “rtype=1” is not supported
  1. showAlternative(Boolean): Show alternative routes.
  2. profile(String): Below are the available profile:
  • DirectionsCriteria.PROFILE_DRIVING (Default):Meant for car routing
  • DirectionsCriteria.PROFILE_WALKING: Meant for pedestrian routing. Routing with this profile is restricted to route_adv only. region & rtype request parameters are not supported in pedestrian routing
  • DirectionsCriteria.PROFILE_BIKING:Meant for two-wheeler routing. Routing with this profile is restricted to route_adv only. region & rtype request parameters are not supported in two-wheeler routing.
  • DirectionsCriteria.PROFILE_TRUCKING:Meant for Truck routing. Routing with this profile is restricted to route_adv only. region & rtype request parameters are not supported in truck routing.
  1. overview(String): Add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all. Below are the available value:
  • DirectionsCriteria.OVERVIEW_FULL
  • DirectionsCriteria.OVERVIEW_FALSE
  • DirectionsCriteria.OVERVIEW_SIMPLIFIED
  1. steps(Boolean): Return route steps for each route leg. Possible values are true/false. By default it will be used as false.
  2. excludes(List<String>) : Additive list of road classes to avoid, order does not matter. Below are the available value:
  • DirectionsCriteria.EXCLUDE_FERRY
  • DirectionsCriteria.EXCLUDE_MOTORWAY
  • DirectionsCriteria.EXCLUDE_TOLL
  1. showStartNavigation(Boolean): To show the Start Navigation button if the origin is current location.
  2. showDefaultMap(Boolean): To add the option to show default map
  3. destination(DirectionPoint): You can use DirectionPoint to pass the destination in direction widget:
  • setDirection(Point, String, String): It takes coordinate, place name and place address
  • setDirection(String, String, String): It takes mappls pin, place name and place address
  1. searchPlaceOption(PlaceOptions): To set the properties of search widget.
  2. showAddWaypointOption(Boolean): To show/hide add waypoint functionality.
  3. showTripCostSummary(Boolean): To show/hide trip cost summary this functionality only works with DirectionsCriteria.RESOURCE_ROUTE_ETA
  4. showRouteReportSummary(Boolean): To show/hide route report summary.
  5. showRouteReportSummaryOnMap(Boolean): To show/hide Route Report summary on Map.
  6. showProfileOption(Boolean): To show the profile switch option.
  7. theme(Integer): To change the theme of the UI. Below are the available value:
  • DirectionOptions.THEME_DEFAULT
  • DirectionOptions.THEME_DAY (Default)
  • DirectionOptions.THEME_NIGHT

and so on…