-
Notifications
You must be signed in to change notification settings - Fork 14
MapmyIndia Direction Widget
mamtasharma117 edited this page May 4, 2021
·
2 revisions
A ready to use Fragment to show the Routes in an Android platform. It offers the following basic functionalities:
- Takes support of MapmyIndia Place search for searching locations of origin, destinations and via points.
- It allows to use origin and destinations in MapmyIndia's digital address (semicolon separated) eLoc or WGS 84 geographical coordinates both.
- The ability to set the vehicle profile like driving, and biking.
- Easily set the resource for traffic and ETA information.
For more details, please contact apisupport@mapmyindia.com.
Follow these steps to add the SDK to your project –
- Create a new project in Android Studio
- Add MapmyIndia repository in your project level build.gradle
allprojects {
repositories {
maven {
url 'https://maven.mapmyindia.com/repository/mapmyindia/'
}
}
}
- Add below dependency in your app-level build.gradle
implementation 'com.mapmyindia.sdk:direction-ui:0.1.0'
Add your API keys to the SDK (in your application's onCreate() or before using map)
MapmyIndiaAccountManager.getInstance().setRestAPIKey(getRestAPIKey());
MapmyIndiaAccountManager.getInstance().setMapSDKKey(getMapSDKKey());
MapmyIndiaAccountManager.getInstance().setAtlasClientId(getAtlasClientId());
MapmyIndiaAccountManager.getInstance().setAtlasClientSecret(getAtlasClientSecret());
MapmyIndiaAccountManager.getInstance().restAPIKey = getRestAPIKey()
MapmyIndiaAccountManager.getInstance().mapSDKKey = getMapSDKKey()
MapmyIndiaAccountManager.getInstance().atlasClientId = getAtlasClientId()
MapmyIndiaAccountManager.getInstance().atlasClientSecret = getAtlasClientSecret()
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();
val directionFragment: DirectionFragment = DirectionFragment.newInstance()
supportFragmentManager.beginTransaction().add(R.id.fragment_container, directionFragment, DirectionFragment::class.java.simpleName)
.commit()
//OR
val directionFragment: DirectionFragment = DirectionFragment.newInstance(directionOptions)
supportFragmentManager.beginTransaction().add(R.id.fragment_container, placeAutocompleteFragment, PlaceAutocompleteFragment::class.java.simpleName)
.commit()
You can use DirectionOptions
to set the properties of direction widget:
- 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
-
showAlternative(Boolean)
: Show alternative routes. -
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.
-
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
-
steps(Boolean)
: Return route steps for each route leg. Possible values are true/false. By default it will be used as false. -
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
-
showStartNavigation(Boolean)
: To show the Start Navigation button if the origin is current location. -
showDefaultMap(Boolean)
: To add the option to show default map -
destination(DirectionPoint)
: You can useDirectionPoint
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 eloc, place name and place address
-
-
searchPlaceOption(PlaceOptions
): To set the properties of search widget
directionFragment.provideMap(MapView)
Implement from DirectionCallback interface:
directionFragment.setDirectionCallback(new DirectionCallback() {
@Override
public void onCancel() {
//on Click of back button
}
@Override
public void onStartNavigation(DirectionPoint origin, DirectionPoint destination, List<DirectionPoint> waypoints, DirectionsResponse directionsResponse, int selectedIndex) {
//Get the origin, destination, waypoints, directionsResponse and the selected Index
}
});
Email us at apisupport@mapmyindia.com
Stack Overflow
Ask a question under the mapmyindia-api
Support
Need support? contact us!
Blog
Read about the latest updates & customer stories
© Copyright 2021. CE Info Systems Pvt. Ltd. All Rights Reserved. | Terms & Conditions.
- Map UI Settings
- Set Country Regions
- Set MapmyIndia MapStyle
- REST API Kit
- MapmyIndia GeoAnalytics
- Place Autocomple Widget
- MapmyIndia Safety Plugin
- MapmyIndia Interactive Layer
- MapmyIndia GeoFence View
- MapmyIndia Safety Strip
- MapmyIndia Place Picker
- MapmyIndia Scalebar Plugin
- ELocation Strategy
- MapmyIndia Direction Widget
- MapmyIndia Nearby Search Widget
- Version History
- Country List