getDistance Plugin for Mappls Web Maps
Easy To Integrate Distance Matrix APIs & Map SDKs For Web Applications
Powered with India's most comprehensive and robust mapping functionalities. Now Available for 200+ nations and territories accross the world.
Getting Accessβ
Before using the Plugin in the your solution, please ensure that the related access is enabled in the Mappls Console, in the same project you set up for the Maps SDK.
- Copy and paste the generated
access token
from your API keys available in the dashboard in the sample code for interactive map development.- This APIs follow OAuth2 based security.
Access Token
can be generated using Token Generation API.- To know more on how to create your access tokens, please use our authorization API URL. More details available here
- The
access token
is a valid by default for 24 hours from the time of generation. This can be configured by you in the API console.
- The sample codes are provided on our domain to help you understand the very basic functionality of Mappls Distance Method.
Introductionβ
This method, offered by Mappls web plugins , computes the routable distance and duration between a set of source/primary positions and a list of all supplied secondary positions using two mode of route calculation i.e. optimal OR shortest. The method also takes into account different modes of transport like 4 wheelers, two wheelers + more. Please note that maximum number of points are limited to 100 only including source and secondary positions.
The method offers the following basic functionalities:
- The method computes the distance and duration from origin to number of supplied destinations on maps.
- The ability to set the vehicle profile like driving, biking and trucking.
- Easily set the resource for traffic and ETA information.
- The method also has 'many to many' functionality in case of multiple origins and destinations.
- It allows to use origin and destinations in Mappls's digital address (semicolon separated) eLoc or WGS 84 geographical coordinates both.
- This method can only be used when
CORS
is enabled on your project. For details, please contact apisupport@mappls.com.
For detailed understanding, Letβs get started!
Live Demoβ
Visit the following link for visiting the live demo:
Implementationβ
Script URLβ
<script src="https://apis.mappls.com/advancedmaps/api/{access_token}/map_sdk_plugins"></script>
Methodβ
mappls.getDistance()
Propertiesβ
Mandatoryβ
coordinates
(string): Semicolon separated eloc or lat,long or both.callback
: Method to get response
Optionalβ
resource
(string): Default isdistance_matrix
and can be changed todistance_matrix_eta
ordistance_matrix_traffic
as per requirement.profile
(string): Defaultdriving
for four wheelers and can be changed tobiking
andtrucking
for two wheelers and heavy vehicles respectively.rtype
(boolean): type of route required for navigation, where values mean:0
optimal (default)1
shortest (it will calculate route by excluding access penalties like private roads, etc.)
region
(string): It is for the available countries. Default is India; for other countries (Sri Lanka, Nepal, Bangladesh & Bhutan) this parameter is mandatory. Possible values areind
(for India, default),lka
(for Sri Lanka) ,npl
(for Nepal) ,bgd
(for Bangladesh),mmr
(for Myanmar) andbtn
(for Bhutan).sources
(string): To specify which of the coordinates/eLoc supplied are to be treated as source position for 'many to many' distance matrix calculation. The input is indicative of that coordinate/eLoc's index. E.g. 0;1 means that 0th and 1st pairs are source points. Default value is 0. The indexes must be semi-colon separated. e.g: 0;1;2;...destinations
(string): To specify which of the coordinates/eLoc supplied in the method are to be treated as destination position for 'many to many' distance matrix calculation. The input is indicative of that coordinate/eLoc's index. E.g. 2;3 means that 0th and 1st pairs are destination points. Default value is all. The indexes must be comma separated. e.g: 3;4;5;...
Exampleβ
mappls.getDistance({
coordinates: "mmi000;123zrr",
callback: function(data) {
console.log(data);
}
});
Sample code Snippetβ
/*CALLING DISTANCE*/
mappls.getDistance({
coordinates: "518NSV;123ZRR;28.9797,77.6763"
}, function(data) {
resdiv.innerHTML = JSON.stringify(data).replace(/{/g, '<br>{<br>').replace(/}/g, '<br>}<br>').replace(/","/g, '",<br>"');
});
IMPORTANT Note: CORS must be enabled on your credentials before accessing this method. Please contact API support (below) for enabling the same on your credentials or go to API console to enable.