1.0.0 • Published 6 years ago
mapmyindia-restapi-cordova-ionic-beta v1.0.0
MapmyIndia REST APIs for Cordova/Ionic - Beta 1
For full documentation contact MapmyIndia here:
MapmyIndia: apisupport@mapmyindia.com.
You can get your api key to be used in this document here: https://www.mapmyindia.com/api/signup
Version History
Version | Last Updated | Author |
---|---|---|
0.0.9 | November 2018 | MapmyIndia API Team (AS) |
Technologies Used
Supported Platform
Supported Technologies
Installation
npm
> cordova plugin add mapmyindia-restapi-cordova-ionic-beta
git
> cordova plugin add https://github.com/mapmyindia/mapmyindia-restapi-cordova-ionic-beta.git
Browser Installation
IONIC | CORDOVA |
---|---|
ionic cordova platform add browser | cordova platform add browser |
Running in the browser
IONIC | CORDOVA |
---|---|
ionic cordova run browser | cordova run browser |
Only if you are running cordova project in browser not for ionicframework
replace your
<meta>
tag inindex.html
```js <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://* 'unsafe-inline'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'" /> ``` > MapmyIndia Plugin requires Cordova to run.
Declare mmi_rest var globally
```js > declare var mmi_rest; ``` > Inside `mmi_rest` function if you want to access this property you have to assign to a variable like > > `var thisObj = this` outside the `mmi_rest` function body if you are working with `IONIC V > 1`
API Usage
Features:
- Autosuggest
- Geocoding
Legacy
- Nearby
- Reverse Geocode
- Place detail
- Distance
Legacy
- Routing
Legacy
- Routing API
- Distance Matrix
- Atlas Geocode
Autosuggest
Parameters
client_id*
client_secret*
query*
successCallback*
errorCallback*
location
zoom
region
tokenizeAddress
pod
filter
Syntax
mmi_rest.atlas_auto(
{
client_id: 'clientId',
client_secret: 'clientSecret',
query: 'agr'
},SuccessCallback, Error Callback);
Example
mmi_rest.atlas_auto({client_id: 'clientId', client_secret: 'clientSecret',query: 'agr'},
function(result)
{
console.log(result);
},
function(error)
{
console.log(error);
});
Geocode
Parameters
key*
addr*
successCallback*
errorCallback*
Syntax
mmi_rest.geocode(key: 'YOUR API KEY', addr: 'address'}, Success Callback, Error Callback);
Example
mmi_rest.geocode({key: 'YOUR API KEY', addr: 'lucknow'},
function(result){
console.log(JSON.stringify(result));
},
function(err){
console.log(err);
});
Nearby
Parameters
key*
client_id*
client_secret*
keywords*
refLocation*
successCallback*
errorCallback*
Syntax
mmi_rest.atlas_nearby({client_id: 'clientId', client_secret: 'clientSecret', keywords: 'beer', refLocation: '28.631460,77.217423'}, SuccessCallback, ErrorCallback);
Example
mmi_rest.atlas_nearby({client_id: 'clientId',client_secret: 'clientSecret',keywords: 'beer',refLocation: '28.631460,77.217423'},
function(result)
{
console.log(JSON.stringify(result));
},
function(error)
{
console.log(error);
});
Reverse Geocode
Parameters
key*
lat*
lng*
successCallback*
errorCallback*
Syntax
mmi_rest.rev_geocode(key: 'YOUR API KEY', lat: '27.61234', lng: '77.61234'}, Success Callback, Error Callback);
Example
mmi_rest.rev_geocode({key: 'YOUR API KEY', lat: '27.61234', lng: '77.61234'},
function(result){
console.log(JSON.stringify(result));
},
function(err){
console.log(err);
});
Place Details / eLoc
Parameters
key*
placeId*
successCallback*
errorCallback*
Syntax
mmi_rest.place_detail({key: 'YOUR API KEY', placeId: 'MMI000'}, Success Callback, Error Callback);
Example
mmi_rest.place_detail({key: 'YOUR API KEY', placeId: 'MMI000'},
function(result)
{
console.log(JSON.stringify(result));
},
function(err)
{
console.log(err);
});
Driving Distance Matrix
Parameters
key*
lat*
lng*
points*
successCallback*
errorCallback*
Syntax
mmi_rest.distance({key: 'YOUR API KEY', lat: '27.61234', lng: '77.61234', points:'29,78|30,78|28,79'}, Success Callback, ErrorCallback);
Example
mmi_rest.distance({key: 'YOUR API KEY', lat: '27.61234', lng: '77.61234', points: '29,78|30,78|28,79'},
function(result)
{
console.log(JSON.stringify(result));
},
function(err)
{
console.log(err);
});
Routing (Deprecated)
Parameters
Note: "alternatives" and "advices" are optional parameters; send null
if they are empty.
key*
start*
destination*
successCallback*
errorCallback*
Syntax
mmi_rest.route({key: 'YOUR API KEY', start: '28.111,77.111', destination: '28.22,77.22', alternatives: null, advices: null}, SuccessCallback, ErrorCallback);
Example
mmi_rest.route({key: 'YOUR API KEY', start: '28.111,77.111', destination: '28.22,77.22', alternatives: null, advices: null},
function(result)
{
console.log(JSON.stringify(result));
},
function(err)
{
console.log(JSON.stringify(err));
});
Routing API
Parameters
key*
start*
destination*
successCallback*
errorCallback*
geometries
steps
exclude
rtype
region
bearings
alternatives
radiuses
overview
Syntax
mmi_rest.route_new({key: 'YOUR API KEY', start: '77.131123,28.552413', destination: '77.113091,28.544649'}, SuccessCallback, ErrorCallback);
Example
mmi_rest.route_new({key: 'YOUR API KEY', start: '77.131123,28.552413', destination: '77.113091,28.544649'},
function(result)
{
alert(JSON.stringify(result));
},
function(err)
{
alert(JSON.stringify(err));
});
Atlas Geocode
Parameters
client_id*
client_secret*
addr*
successCallback*
errorCallback*
itemCount
bias
podFilter
bound
scores
Syntax
mmi_rest.atlas_geocode({client_id: 'ID', client_secret: 'secret', addr: 'mapmyindia'}, Success Callback, Error Callback);
Example
mmi_rest.atlas_geocode({client_id: 'ID', client_secret: 'secret', addr: 'mapmyindia'},
function(result)
{
alert(JSON.stringify(result));
},
function(error)
{
alert(error);
})
Distance Matrix
Parameters
key*
source*
secondryLocations*
successCallback*
errorCallback*
rtype
region
Syntax
mmi_rest.distance_new({key: 'YOUR API KEY', source: '77.983936,28.255904', secondryLocations: '90.379249,23.497178'}, Success Callback, ErrorCallback);
Example
mmi_rest.distance_new({key: 'YOUR API KEY', source: '77.983936,28.255904', secondryLocations: '90.379249,23.497178'},
function(result)
{
alert(JSON.stringify(result));
},
function(err)
{
alert(err);
});
For any queries and support, please contact:
Email us at apisupport@mapmyindia.com
Ask a question under the mapmyindia-api
Support
Need support? contact us!
Blog
Read about the latest updates & customer stories
© Copyright 2019. CE Info Systems Pvt. Ltd. All Rights Reserved. | Terms & Conditions
Written with StackEdit by MapmyIndia.