Routing and displaying driving directions on map, including instructions for navigation, distance to destination, traffic etc. are few of the most important parts of developing a map based application. This REST API calculates driving routes between specified locations including via points based on route type(fastest or shortest), includes delays for traffic congestion , and is capable of handling additional route parameters like: type of roads to avoid, travelling vehicle type etc.
MapmyIndiaDirections mapmyIndiaDirections = MapmyIndiaDirections.builder()
.origin(startPointLocal)
.steps(true)
.resource(DirectionsCriteria.RESOURCE_ROUTE_ETA)
.profile(DirectionsCriteria.PROFILE_DRIVING)
.overview(DirectionsCriteria.OVERVIEW_FULL)
.destination(endPointLocal)
.build();
MapmyIndiaDirectionManager.newInstance(mapmyIndiaDirections).call(new OnResponseCallback<DirectionsResponse>() {
@Override
public void onSuccess(DirectionsResponse response) {
//Handle Response
}
@Override
public void onError(int code, String message) {
//Handle Error
}
});
val mapmyIndiaDirections = MapmyIndiaDirections.builder()
.origin(startPointLocal)
.steps(true)
.resource(DirectionsCriteria.RESOURCE_ROUTE_ETA)
.profile(DirectionsCriteria.PROFILE_DRIVING)
.overview(DirectionsCriteria.OVERVIEW_FULL)
.destination(endPointLocal)
.build()
MapmyIndiaDirectionManager.newInstance(mapmyIndiaDirections).call(object : OnResponseCallback<DirectionsResponse> {
override fun onSuccess(response: DirectionsResponse) {
//handle response
}
override fun onError(code: Int, message: String) {
//handle Error
}
})
origin(Point)
: pass the origin point- origin can also takes eLoc in parameter eg.,
origin("17ZUL7")
- origin can also takes eLoc in parameter eg.,
destination(Point)
: pass the destination point- destination can also takes eLoc in parameter eg.,
destination("MMI000")
- destination can also takes eLoc in parameter eg.,
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.
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
steps(Boolean)
:Return route steps for each route leg. Possible values are true/false. By default it will be used as false.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
excludes(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
addWaypoint(Point)
: pass single waypoint at a time- addWapoint also takes eLoc in parameter eg.,
addWaypoint("MMI000")
- addWapoint also takes eLoc in parameter eg.,
alternatives(Boolean)
: Search for alternative routes.radiuses(double...)
: Limits the search to given radius in meters. For all way-points including start and end points.geometries(String)
: This parameter used to change the route geometry format/density (influences overview and per step).Below are the available value:
- DirectionsCriteria.GEOMETRY_POLYLINE: with 5 digit precision
- DirectionsCriteria.GEOMETRY_POLYLINE6 (Default): with 6 digit precision
- 200: To denote a successful API call.
- 204: To denote the API was a success but no results were found.
- 400: Bad Request, User made an error while creating a valid request.
- 401: Unauthorized, Developer’s key is not allowed to send a request with restricted parameters.
- 403: Forbidden, Developer’s key has hit its daily/hourly limit.
- 500: Internal Server Error, the request caused an error in our systems.
- 503: Service Unavailable, during our maintenance break or server downtimes.
- 200: Success.
- 204: No matches were found for the provided query.
- 400: Something’s just not right with the request.
- 401: Access Denied.
- 403: Services for this key has been suspended due to daily/hourly transactions limit.
- 500: Something went wrong.
- 503: Maintenance Break.
code()
(String): if request is successful, response is .ok.. Else, see the service dependent and general status codes. In case of error, .NoRoute. code is supported (in addition to the general ones) which means .no route found..routes()
(List<DirectionsRoute>
): A list of DirectionsRoute objects, each having potentially multiple via pointswaypoints()
(List<DirectionsWaypoint>
): Array of DirectionsWaypoint objects representing all waypoints in order
distance()
(Double): The distance travelled by the route; unit is meter.duration()
(Double): The estimated travel time; unit is second.geometry()
(String): returns the whole geometry of the route as per given parameter .geometries. default is encoded .polyline6. with 6 digit accuracy for positional coordinates.legs()
(List<RouteLeg>
): The legs between the given waypoints, representing an array of RouteLeg between two waypoints.routeClasses()
(RouteClasses
): It provides classes (Toll, motorway, ferry, tunnel) information.
distance()
(Double): The distance of travel to the subsequent legs, in metersduration()
(Double): The estimated travel time, in secondssteps()
(List<LegStep>
): Return route steps for each route leg depending upon steps parameter.
distance()
(double) :The distance of travel to the subsequent step, in metersduration()
(double): The estimated travel time, in secondsgeometry()
(double): The un-simplified geometry of the route segment, depends on the given geometries parameter.name()
(String): The name of the way along which travel proceeds.mode()
(String): signifies the mode of transportation; driving as default.maneuver()
(StepManeuver): A StepManeuver object representing a maneuverdrivingSide()
(String): .Left. (default) for India, Sri Lanka, Nepal, Bangladesh & Bhutan.intersections()
(List<StepIntersection>
): A list of StepIntersection objects that are passed along the segment, the very first belonging to the StepManeuver
location()
(Point): A Point describing the location of the turnbearingBefore()
(Double): The clockwise angle from true north to the direction of travel immediately before the maneuver.bearingAfter()
(Double): The clockwise angle from true north to the direction of travel immediately after the maneuver.type()
(String): An optional string indicating the direction change of the maneuver.modifier()
(String): A string indicating the type of maneuver. New identifiers might be introduced without API change. Types unknown to the client should be handled like the .turn. type, the existence of correct modifier values is guaranteed.
location()
(Point): point describing the location of the turn.bearings()
(List<Integer>
): A list of bearing values (e.g. [0,90,180,270]) thxat are available at the intersection. The bearings describe all available roads at the intersection.classes()
(List<String>
): Categorised types of road segments e.g. Motorwayentry()
(List<Boolean>
): A list of entry flags, corresponding in a 1:1 relationship to the bearings. A value of true indicates that the respective road could be entered on a valid route. false indicates that the turn onto the respective road would violate a restriction.in()
(Integer): index into bearings/entry array. Used to calculate the bearing just before the turn. Namely, the clockwise angle from true north to the direction of travel immediately before the maneuver/passing the intersection. Bearings are given relative to the intersection. To get the bearing in the direction of driving, the bearing has to be rotated by a value of 180. The value is not supplied for depart maneuvers.out()
(Integer): index into the bearings/entry array. Used to extract the bearing just after the turn. Namely, The clockwise angle from true north to the direction of travel immediately after the maneuver/passing the intersection. The value is not supplied for arrive maneuvers.lanes()
(List<IntersectionLanes>
Array of IntersectionLanes objects that denote the available turn lanes at the intersection. If no lane information is available for an intersection, the lanes property will not be present.):valid()
(Boolean): verifying lane info.indications()
(List<String>
): Indicating a sign of directions like Straight, Slight Left, Right, etc.
name()
(String): Name of the street the coordinate snapped to.location()
(Point): Point describing the snapped location of the waypoint.
motorway()
(Integer): If its value is greater than 0 means the route contains motorwaystunnel()
(Integer): If its value is greater than 0 means the route contains tunneltoll()
(Integer): If its value is greater than 0 means the route contains tollsferry()
(Integer): If its value is greater than 0 means the route contains ferryrestricted()
: If its value is greater than 0 means the route has restrictions.
Adding driving directions API would help to add predicted travel time & duration from a given origin point to a number of points. The Driving Distance Matrix API provides driving distance and estimated time to go from a start point to multiple destination points, based on recommended routes from MapmyIndia Maps and traffic flow conditions
Get driving time and distance between a center point and up to 10 destination points using MapmyIndia Maps Distance API.
MapmyIndiaDistanceMatrix mapmyIndiaDistanceMatrix = MapmyIndiaDistanceMatrix.builder()
.profile(DirectionsCriteria.PROFILE_DRIVING)
.resource(DirectionsCriteria.RESOURCE_DISTANCE)
.coordinate(Point.fromLngLat(80.502113, 8.916787))
.coordinate(Point.fromLngLat(28.5505073, 77.2689367))
.build();
MapmyIndiaDistanceMatrixManager.newInstance(mapmyIndiaDistanceMatrix).call(new OnResponseCallback<DistanceResponse>() {
@Override
public void onSuccess(DistanceResponse response) {
//Handle Response
}
@Override
public void onError(int code, String message) {
//Handle Error
}
});
val mapmyIndiaDistanceMatrix = MapmyIndiaDistanceMatrix.builder()
.profile(DirectionsCriteria.PROFILE_DRIVING)
.resource(DirectionsCriteria.RESOURCE_DISTANCE)
.coordinate(Point.fromLngLat(80.502113, 8.916787))
.coordinate(Point.fromLngLat(28.5505073, 77.2689367))
.build()
MapmyIndiaDistanceMatrixManager.newInstance(mapmyIndiaDistanceMatrix).call(object : Callback<DistanceResponse> {
override fun onSuccess(response: DistanceResponse) {
//handle response
}
override fun onError(code: Int, message: String) {
//handle Error
}
})
coordinates(List<Point>)
: A List full of {@link Point}s which define the points to perform the matrix.coordinate(Point)
: To pass signgle coordinate at a time- coordinate can also takes eLoc eg.,
coordinate("MMI000")
- coordinate can also takes eLoc eg.,
coordinateList(List<String>)
: To pass the full list of elocs
profile(String)
: Only supports DirectionsCriteria.PROFILE_DRIVING.resource(Strng)
: Below are the available value:
- DirectionsCriteria.RESOURCE_DISTANCE (Default): to calculate the route & duration without considering traffic conditions.
- DirectionsCriteria.RESOURCE_DISTANCE_ETA: to get the updated duration considering live traffic; Applicable for India only “region=ind” and “rtype=1” is not supported. This is different from distance_matrix_traffic; since this doesn't search for a route considering traffic, it only applies delays to the default route.
- DirectionsCriteria.RESOURCE_DISTANCE_TRAFFIC: to search for routes considering live traffic; Applicable for India only “region=ind” and “rtype=1” is not supported
sources(List<Integer>)
: To specify which of the coordinates supplied in the URL are to be treated as source position for many to many distance matrix calculation, indicate that coordinate pair's index. E.g. 0;1 means that 0th and 1st coordinate pairs are source points.destinations(List<integer>)
: To specify which of the coordinates supplied in the URL are to be treated as destination position for many to many distance matrix calculation, indicate that coordinate pair's index. E.g. 2;3 means that 2nd and 3rd coordinate pairs are destination points.
- 200: To denote a successful API call.
- 204: To denote the API was a success but no results were found.
- 400: Bad Request, User made an error while creating a valid request.
- 401: Unauthorized, Developer’s key is not allowed to send a request with restricted parameters.
- 403: Forbidden, Developer’s key has hit its daily/hourly limit.
- 500: Internal Server Error, the request caused an error in our systems.
- 503: Service Unavailable, during our maintenance break or server downtimes.
- 200: Success.
- 204: No matches were found for the provided query.
- 400: Something’s just not right with the request.
- 401: Access Denied.
- 403: Services for this key has been suspended due to daily/hourly transactions limit.
- 500: Something went wrong.
- 503: Maintenance Break.
responseCode
(Long): Response codes of the api.version
(String): Version of the Api.results
(DistanceResults): Array of results, each consisting of the following parameters
code
: if the request was successful, code is ok.durations
(List<Double[]>
): Duration in seconds for source to source (default 0), 1st, 2nd, 3rd secondary locations... from source.distances
(List<Double[]>
): Distance in meters for source to source (default 0), 1st, 2nd, 3rd secondary locations... from source.
For any queries and support, please contact:
Email us at [email protected]
Stack Overflow
Ask a question under the mapmyindia-api
Support
Need support? contact us!
Blog
Read about the latest updates & customer stories
© Copyright 2022. CE Info Systems Ltd. All Rights Reserved. | Terms & Conditions.