### SnapToRoad API GET Request Example Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-snapToRoad-api/readme.md Example of how to construct a GET request for the SnapToRoad API, including the base URL, license key, and points. ```json https://apis.mapmyindia.com/advancedmaps/v1/{rest-api-key}/snapToRoad?pts=78.40573,17.37317;78.40958,17.37314;78.41845,17.37449;78.409992,17.37328;78.420460,17.377443;78.421350,17.380200×tamps=1527056019;1527056020;1527056021;1527056022;1527056023;1527056024 ``` -------------------------------- ### Example Route URL Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/readme.md This is an example URL for calculating an advanced driving route. It includes the base API endpoint, license key, resource, profile, and start/end positions. ```html https://apis.mapmyindia.com/advancedmaps/v1//route_adv/driving/77.131123,28.552413;17ZUL7? ``` -------------------------------- ### Aerial Distance API Example URL Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-aerial-distance-api/readme.md This is an example URL for the Aerial Distance API. Replace '' with your actual license key. The parameters 'x1', 'y1', 'x2', 'y2' define the start and end points, and 'unit' specifies the desired unit of distance. ```html https://apis.mapmyindia.com/advancedmaps/v1//distanceA?x1=34.506172&y1=76.108652 &x2=28.4586&y2=77.85698&unit=K ``` -------------------------------- ### Trip Optimization ETA Example URL Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-route-optimization-api/readme.md Example URL demonstrating trip optimization with ETA for driving. It includes parameters for routing profile, coordinates, region, and geometry options. The input coordinates are in longitude,latitude format. ```html https://apis.mapmyindia.com/advancedmaps/v1/REST_API_KEY/trip_optimization_eta/driving/77.235500,28.627136;77.107227,28.720863;77.120125,28.548559;77.312093,28.675954;77.293948,28.594097;77.268912,28.550820?region=ind&geometries=polyline&overview=full&steps=false&source=first&destination=last&roundtrip=true ``` -------------------------------- ### Sample Elevation API Request Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-elevation-api/readme.md An example of a GET request to the Elevation API, specifying two location coordinates. ```HTTP https://apis.mapmyindia.com/advancedmaps/v1//elevation?locations=9.538350,76.998825|8.930019,76.655587 ``` -------------------------------- ### Sample Route Optimization ETA Request Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-route-optimization-api/readme.md Example URL for requesting route optimization and ETA calculation. Replace REST-KEY-HERE with your actual API key. ```url https://apis.mapmyindia.com/advancedmaps/v1/REST-KEY-HERE/trip_optimization_eta/driving/77.235500,28.627136;77.107227,28.720863;77.120125,28.548559;77.312093,28.675954;77.293948,28.594097;77.268912,28.550820?region=ind&geometries=polyline&overview=full&steps=false&source=first&destination=last&roundtrip=true ``` -------------------------------- ### Nearby Search with Keywords and Location Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-near-by-api-example/Readme.md This example shows how to find nearby coffee and beer locations using keywords and a reference location. ```URL https://atlas.mapmyindia.com/api/places/nearby/json?keywords=coffee;beer&refLocation=28.631460,77.217423&filter=categoryCode:FODCOF ``` -------------------------------- ### SnapToRoad API POST Request Example Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-snapToRoad-api/readme.md Example of how to construct a POST request for the SnapToRoad API using curl. This method requires specifying the Content-Type and sending parameters via --data-urlencode. ```curl curl --location --request POST 'https://apis.mapmyindia.com/advancedmaps/v1/{rest-api-key}/snapToRoad' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'pts=78.40573,17.37317;78.40958,17.37314;78.41845,17.37449;78.409992,17.37328;78.420460,17.377443;78.421350,17.380200' \ --data-urlencode 'timestamps=1527056019;1527056020;1527056021;1527056022;1527056023;1527056024' \ --data-urlencode 'geometries=polyline' \ --data-urlencode 'radiuses=50;50;50;50;50;50' ``` -------------------------------- ### Sample Text Search API Input Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-textsearch-api/readme.md Example of a GET request URL for the text search API, specifying a query, region, and filter. ```html https://atlas.mapmyindia.com/api/places/textsearch/json?query=okhla phase 3®ion=ind&filter=pin:110020 ``` -------------------------------- ### Sample Snap To Road API Request URL Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-snapToRoad-api/readme.md This is an example URL for the Snap To Road API, demonstrating the required parameters like license key, points (pts), and timestamps. ```text https://apis.mapmyindia.com/advancedmaps/v1//snapToRoad?pts=78.40573,17.37317;78.40958,17.37314;78.41845,17.37449;78.409992,17.37328;78.420460,17.377443;78.421350,17.380200×tamps=1527056019;1527056020;1527056021;1527056022;1527056023;1527056024 ``` -------------------------------- ### Geocoding API Request Example Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-geocoding-rest-api-example/Readme.md This is an example URL for querying the MapmyIndia Geocoding API with a specific address. Ensure the address is properly encoded if it contains special characters. ```text https://atlas.mapmyindia.com/api/places/geocode?address=mapmyindia 237 okhla phase 3 ``` -------------------------------- ### Example Decoded Route Way-points Source: https://github.com/mappls-api/mapmyindia-rest-api/wiki/Decoding-Geometry---JavaScript This is an example of the output format returned by the decode function, representing a series of geographical coordinates for a route. ```json [[28.61415, 77.21218],[28.61468, 77.21221],[28.61526, 77.21225],[28.61548, 77.21226],[28.61592, 77.21229],[28.61631, 77.21232],[28.61662, 77.21234],[28.61664, 77.21223]] ``` -------------------------------- ### Reverse Geocoding API Sample Input Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-reverse-geocoding-rest-api-example/Readme.md An example of a complete input URL for the Reverse Geocoding API, including a sample license key, latitude, and longitude. ```URL https://apis.mapmyindia.com/advancedmaps/v1//rev_geocode?lat=26.5645&lng=85.9914 ``` -------------------------------- ### Sample Route Optimization ETA Response Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-route-optimization-api/readme.md Example JSON response from the Route Optimization API, detailing waypoint information, distances, and trip legs. ```json { "code": "Ok", "Server": "ETA-5100", "waypoints": [ { "waypoint_index": 0, "trips_index": 0, "hint": "A4rHgRuKx4FNAAAAHgAAAAAAAADUAAAA4dpOQRnTnEAAAAAA2oUNQk0AAAAeAAAAAAAAANQAAADIAAAAVYWaBLzQtAEshZoEwNC0AQAAnwumjcx_", "distance": 4.033839, "location": [ 77.235541, 28.627132 ], "name": "" }, { "waypoint_index": 4, "trips_index": 0, "hint": "2HQvgP___39BAAAAUwAAACwAAABTAAAAIFaKQt8Ij0GvATpCVxiuQkEAAABTAAAALAAAAFMAAADIAAAA-4-YBMQ-tgEbkJgE3z62AQEAjwimjcx_", "distance": 4.327578, "location": [ 77.107195, 28.720836 ], "name": "Bhagwan Mahavir Marg" }, { "waypoint_index": 3, "trips_index": 0, "hint": "_PvBgf___39rAAAAmAAAAJgAAAAAAAAAqYgPQt04b0FTMUtCAAAAAGsAAACYAAAAmAAAAAAAAADIAAAAiMKYBOydswF9wpgEz52zAQEA3wamjcx_", "distance": 3.389452, "location": [ 77.120136, 28.548588 ], "name": "IGI Road" }, { "waypoint_index": 5, "trips_index": 0, "hint": "SZMagP___38bAAAAIgAAAC4AAADVAAAAr0waQtPVFEGSm35CPIWUQxsAAAAiAAAALgAAANUAAADIAAAAWbCbBLSPtQFdsJsEco-1AQEArxCmjcx_", "distance": 7.324971, "location": [ 77.312089, 28.67602 ], "name": "Grand Trunk Road" }, { "waypoint_index": 1, "trips_index": 0, "hint": "xCLxgP___38zAAAAPAAAAJYAAAA0AAAAlp2NQocEPEGRJ05Dl3qPQjMAAAA8AAAAlgAAADQAAADIAAAAZmmbBKhPtAF8aZsEsU-0AQMAvwmmjcx_", "distance": 2.372279, "location": [ 77.293926, 28.594088 ], "name": "Noida Link Road" }, { "waypoint_index": 2, "trips_index": 0, "hint": "xtHMgSTSzIEdAAAALAAAANUAAABMAQAAxRYfQVATZUEjy41CmdLdQh0AAAAsAAAA1QAAAEwBAADIAAAAgwebBHunswGwB5sEpKazAQYAPxCmjcx_", "distance": 24.230611, "location": [ 77.268867, 28.551035 ], "name": "" } ], "trips": [ { "legs": [ { "steps": [], "weight": 816.1, "distance": 8749.1, "summary": "", "duration": 816.1 }, { "steps": [], "weight": 965.6, "distance": 10551.7, "summary": "", "duration": 965.6 }, { "steps": [], "weight": 1523, "distance": 19792.8, "summary": "", "duration": 1523 }, { "steps": [], "weight": 2115.6, "distance": 27357.4, "summary": "", "duration": 2115.6 }, { "steps": [], "weight": 2222, "distance": 24830, "summary": "", "duration": 2222 }, { "steps": [], "weight": 1388.7, "distance": 14970.8, "summary": "", "duration": 1388.7 } ], "weight_name": "routability", "geometry": } ] } ``` -------------------------------- ### Show Markers on Map Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/index.html Adds markers to the map for start and destination points. Supports custom icons for the start point and allows markers to be draggable. Updates input fields and triggers route recalculation on drag end. ```javascript function show_markers(marker_name, points) { var show_marker; var pos = new L.LatLng(points[0], points[1]); var title; var icon_marker=''; if (marker_name == 'start') { var title = "Start Point"; icon_marker = L.icon({iconUrl: 'https://maps.mapmyindia.com/images/3.png', iconRetinaUrl: 'https://maps.mapmyindia.com/images/3.png', iconSize: [15, 20], popupAnchor: [-3, -15]}); } else { var title = "Destination Point"; } /*****marker display, for more about marker, please refer our marker documentation*****/ if (icon_marker!='') show_marker = new L.marker(pos, { draggable: 'true',icon:icon_marker, title: title}).addTo(map); else show_marker = new L.marker(pos, { draggable: 'true', title: title}).addTo(map); show_marker.bindPopup(title, {closeButton: true, autopan: true, zoomAnimation: true}).openPopup(); start_end_markersList.push(show_marker); show_marker.on('dragend', function (event) { var marker = event.target; var position = marker.getLatLng(); document.getElementById(marker_name).value = position.lat + "," + position.lng; get_route_result(); }); } ``` -------------------------------- ### Sample Text Search API Response Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-textsearch-api/readme.md Example JSON response from the text search API, showing suggested locations and user-added locations. ```json { "suggestedLocations": [ { "type": "POI", "typeX": 7, "placeAddress": "Sikandra Road, Connaught Place, New Delhi, Delhi, 110001", "eLoc": "38FD1E", "placeName": "Lady Irwin College", "alternateName": "", "keywords": [ "COMCLG" ], "p": 3493, "distance": 0, "orderIndex": 1, "score": 19905.639213316852, "suggester": "placeName", "addressTokens": {}, "richInfo": {} } ], "userAddedLocations": [] } ``` -------------------------------- ### Sample Input cURL Request Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-auto-suggest-api-example/Readme.md This cURL command shows how to make a GET request to the MapmyIndia Auto Suggest API to search for locations. It includes parameters for the query and location, and an authorization header. ```js curl --location --request GET 'https://atlas.mapmyindia.com/api/places/search/json?bridge=&query=mapmyindia&location=28.627133913995547,77.23553525204144' \ --header 'Authorization: bearer 6xxxxxx4-9xxx-xxx7-xxxb-8dxxa7xxxdc' ``` -------------------------------- ### Sample Input cURL Request Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-address-standardization-api/readme.md This snippet shows a sample cURL command to make a GET request to the MapmyIndia places API for address standardization. It includes the API endpoint, address query, bias parameter, and authorization header. ```js curl --location --request GET 'https://atlas.mapmyindia.com/api/places/woodpecker?address=Shri Krishan Lal Nagpal Marg, Greater Kailash 1, E Block, Greater Kailash I, Greater Kailash, New Delhi, Delhi 110048&bias=1.5' \ --header 'Authorization: bearer 6xxxxxx4-9xxx-xxx7-xxxb-8dxxa7xxxdc' ``` -------------------------------- ### POI Along Route - Multiple Category Search Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-poi-along-the-route-api/readme.md This cURL example demonstrates how to search for POIs along a route for multiple categories. It includes parameters for geometries, path, category, buffer, page, and sort. ```APIDOC ## POST /api/places/along_route ### Description Searches for Points of Interest (POIs) along a specified route for multiple categories. ### Method POST ### Endpoint https://atlas.mapmyindia.com/api/places/along_route ### Parameters #### Form Parameters - **geometries** (string) - Required - Specifies the geometry format for the route (e.g., 'polyline5'). - **path** (string) - Required - The encoded path of the route. - **category** (string) - Required - A semicolon-separated string of category codes for the POI search. - **buffer** (integer) - Optional - The buffer distance in meters around the route to search for POIs. - **page** (integer) - Optional - The page number for paginated results. - **sort** (string) - Optional - Specifies the sorting order for the results. ### Request Example ```curl curl --location --request POST 'https://atlas.mapmyindia.com/api/places/along_route' \ --header 'Authorization: bearer 0XXXXXXf-dXX0-4XX0-8XXa-eXXXXXXXXXX6' \ --form 'geometries="polyline5"' \ --form 'path="k{{mDyhlvMD@J?jCJlCRL@|AFt@Af@CTCPCRIh@SnAy@nAw@lBmA|B}ApA_ArA}@Ng@BQDWFg@Oe@W_AGWEe@EgAAyBDcCFaCBsBAc@Cs@Eq@E[EYEWI_@I_@Oo@EUTKl@UrAm@RG^O~@UzCu@|Cu@|Cu@zCu@lBa@JCPAhACtCDtCBvCBtCBlCBnCDd@?t@@dC?T?fA@tB?tB@VCl@Qt@UPEf@AlDDz@H\\?xBK`AEtBCvBAlAB`DPdA^NDL@h@@fACxAE\\?~BA~BA~BAtBAL?nBC~@Af@g@HIJQFOBQ@WAUEWISOYOQQMQIOGQASAO@QDMFKJU\\_@f@@nC?b@@R?ZFvBDzB@JDlBFxBBbAD~AHhCHzDN^DFDFFFXPbAAT@L@VBH@z@NJDRLlAv@lAx@~AKnAOn@G`@IX?^BdAL|ANtCV~ANXBfBDfBBl@Bp@BrA@Pa@FKHMf@@`CHXDLBJFHJHRbD@`D@Z?h@@f@@h@@bAB^@jDDlBB~@BT@N?dDDV?x@Bt@@dCFdCFzB@nD?N?|BEzBEzBE`@AJ?lCOxCMfAClCGnCIlCIhDKfDIhDIzCK|AG|AEbBG`A@^Sz@e@f@Yr@c@pCgB~@o@~AeA`BcAhA[XQb@_@\\YZe@?QBMDMDIDEDEJEDCFAF?"' \ --form 'category="FODCOF;TRNPMP;HOTPRE"' \ --form 'buffer="300"' \ --form 'page="1"' \ --form 'sort=""' ``` ### Response #### Success Response (200) - **suggestedPOIs** (object array): An array of POI objects found along the route. - `distance` (integer): Distance of the POI from the route. - `place_id` (string): Unique identifier (eLoc) of the POI. - `poi` (string): Name of the POI. - `subSubLocality` (string): Sub-sublocality of the POI. - `subLocality` (string): Sublocality of the POI. - `locality` (string): Locality of the POI. - `city` (string): City of the POI. - `subDistrict` (string): Sub-district of the POI. - `district` (string): District of the POI. - `state` (string): State of the POI. - `poplrName` (string): Popular name of the POI. - `address` (string): Full address of the POI. - `tel` (string): Telephone number of the POI. - `email` (string): Email address of the POI. - `website` (string): Website of the POI. - `brand_code` (string): Brand code of the POI. - `category` (string): Category code of the POI (present only for multiple category searches). #### Response Example ```json { "suggestedPOIs": [ { "distance": 150, "place_id": "eLoc123", "poi": "Example Restaurant", "subSubLocality": "", "subLocality": "Main Street", "locality": "Downtown", "city": "Example City", "subDistrict": "", "district": "Example District", "state": "Example State", "poplrName": "", "address": "123 Main Street, Downtown, Example City", "tel": "+1234567890", "email": "info@examplerestaurant.com", "website": "http://www.examplerestaurant.com", "brand_code": "BRD002", "category": "RESTAURANT" } ] } ``` ### Error Handling - **200**: Success. - **204**: No matches were found for the provided query. - **400**: Invalid request format. - **401**: Access denied. Invalid API key or token. - **403**: Service suspended due to transaction limits. - **500**: Internal server error. - **503**: Service is temporarily unavailable due to maintenance. ``` -------------------------------- ### Sample Routing API Request URL Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/readme.md This is an example of a GET request URL for the MapmyIndia Routing API to calculate a driving route. It includes the license key, start and end points, and route type. ```text https://apis.mapmyindia.com/advancedmaps/v1//route_adv/driving/77.131123,28.552413;17ZUL7?steps=false&rtype=1 ``` -------------------------------- ### Get Route Result Function Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/index.html This JavaScript function retrieves route details from the MapmyIndia API based on user inputs for start, destination, and via points. It handles API call construction and displays markers on the map. ```javascript function get_route_result() { remove_start_end_markersList(); remove_advice_marker(); remove_polyList(); /* for (poly1 in polyList){ map.removeLayer(poly1); }*/ poly = []; pathArrdir = []; polyList = []; var via_arr = ''; var start_points = document.getElementById('start').value; /*get start points*/ var destination_points = document.getElementById('destination').value; /*get destination points*/ via_points = document.getElementById('via').value; /*get via points*/ if (via_points) { var v = via_points.split(';'); for (var i = 0; i < v.length; i++) { var v_ar = v[i].split(','); via_arr += ';' + v_ar[1] + ',' + v_ar[0]; } } var advices_o = document.getElementById('advices_o').value; /*get advices option*/ // var traffic = document.getElementById('traffic').value; /*get advices option*/ alternatives_o = document.getElementById('alternatives_o').value; /*get alternatives option*/ var eta = ""; try { eta = document.getElementById('eta').value; } catch (e) {} var rtype = document.getElementById('rtype').value; var rtype_payload = "&rtype=" + rtype; var start_points_array = start_points.split(','); var destination_points_array = destination_points.split(','); //alert(param_arr); var api_name = $("#api_name").val(); var api_call = api_name; var profile = $("#Profile").val(); api_call += "/" + profile + "/"; if ((profile == 'biking' || profile == 'trucking' || profile == 'walking') && api_name != 'route_adv') { map.removeLayer(leaflet_polyline); document.getElementById('info').innerHTML = "Routing with this profile is restricted to route_adv only."; return false; } var regiondv = document.getElementById('region_dv').style; var rtypedv = document.getElementById('rtype_dv').style; if (api_name == 'route_adv') { regiondv.visibility = 'visible'; var rgn = $('#region').val(); rtypedv.visibility = 'visible'; } else { regiondv.visibility = 'hidden'; var rgn = 'ind'; rtypedv.visibility = 'hidden'; rtype_payload = ""; } var route_api_url_with_param = route_api_url + api_call + start_points_array[1] + "," + start_points_array[0] + via_arr + ";" + destination_points_array[1] + "," + destination_points_array[0] + "?alternatives=" + alternatives_o + rtype_payload + "&geometries=polyline&overview=" + (eta == 1 ? "simplified" : "full") + "&exclude=" + $("#avoids").val() + "&steps=" + advices_o + "®ion=" + rgn; //alert(route_api_url_with_param); show_markers("start", start_points_array); /*show start points marker*/ show_markers("destination", destination_points_array); /*show destination points marker*/ mapmyindia_fit_markers_into_bound(start_points_array, destination_points_array); document.getElementById('direct_advices').style.display = "inline-block"; // document.getElementById('direct_advices').innerHTML = "loading.."; document.getElementById('alternatives_advices').innerHTML = ""; if (poly['direct'] in polyList) { polyList.pop(poly['direct']); map.removeLayer(poly['direct']); } if (poly['alternate'] in polyList) { polyList.pop(poly['alternate']); map.removeLayer(poly['alternate']); } getUrlResult(route_api_url_with_param); } ``` -------------------------------- ### Display Route Information and Advices Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/index.html This snippet shows how to display direct route information, including total time and distance, along with turn-by-turn advices. It dynamically generates HTML tables for presentation. ```javascript var pts = decode_path(way.pts).concat(decode_path(way1.pts)); var advices = way.advices.concat(way1.advices); direct_route_info=''+alternate_route1_text+alternate_route2_text+'
'+direct_route+'
'+total_time+'
'+length.toFixed(1)+' km
< Prev.Next >
'; document.getElementById('info').innerHTML = direct_route_info; advice_direct_route = ' '; var num_rec = 1; var distance; var go = ""; var num=0; advises.forEach(function (advice) { var icon = advice.icon_id; var meters = advice.meters; var distance_meters = meters - distance; distance = meters; var advice_meters = (distance_meters >= 1000 ? (distance_meters / 1000).toFixed(1) + " km " : distance_meters + " mts ") var text = advice.text; if (meters != 0) { go = "
Go " + advice_meters; advice_direct_route += go + ''; } var advice_pt = advice.pt; advice_direct_route += '
' + text; }); document.getElementById('direct_advices').innerHTML = advice_direct_route + "
"; draw_polyline("direct", pathArrdir); ``` -------------------------------- ### Display Alternative Route Advice Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/index.html Renders alternative route advice in an HTML table. It iterates through advice points, calculates distances, and creates clickable table rows to show route details. ```javascript var advice_alternative_route = 'Route ' + (route_no + 2) + ''; var num_rec = 1; var distance; var go = ""; advices.forEach(function (advice) { var icon = advice.icon_id; var meters = advice.meters; var distance_meters = meters - distance; distance = meters; var advice_meters = (distance_meters >= 1000 ? (distance_meters / 1000).toFixed(1) + " km " : distance_meters + " mts ") var text = advice.text; if (meters != 0) { go = "
Go " + advice_meters; advice_alternative_route += go + ''; } var advice_pt = advice.pt; advice_alternative_route += '
' + text; }) document.getElementById('alternatives_advices').innerHTML = advice_alternative_route + "
"; document.getElementById('direct_advices').style.display = 'none';/ /*****hide direct advices*****/ document.getElementById('alternatives_advices').style.display = 'inline-block';/ /*****hide direct advices*****/ / /*****display path*****/ ``` -------------------------------- ### Place Details with Admin, Address, and General Details Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-place-details-api-example/Readme.md This snippet shows a sample response when requesting place details with 'Admin Tokens, Address Tokens, General Details' subtemplate claim set. It includes basic information about the place. ```json { "type": "POI", "poi": "The Lalit New Delhi", "locality": "Connaught Place", "district": "New Delhi District", "subDistrict": "Connaught Place", "city": "New Delhi", "state": "Delhi", "pincode": "110001", "address": "15, Barakhamba Avenue, Connaught Place, New Delhi, Delhi, 110001", "name": "The Lalit New Delhi", "eloc": "3F45CB" } ``` -------------------------------- ### Sample Request for Hindi Suggestions Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-auto-suggest-api-example/Readme.md This snippet shows how to make a GET request to the MapmyIndia Auto Suggest API to get location suggestions for a Hindi query. Ensure you replace '6xxxxxx4-9xxx-xxx7-xxxb-8dxxa7xxxdc' with your actual API key. ```curl curl --location --request GET 'https://atlas.mapmyindia.com/api/places/search/json?bridge=&query=गीतांजलि salon&location=28.627133913995547,77.23553525204144' \ --header 'Authorization: bearer 6xxxxxx4-9xxx-xxx7-xxxb-8dxxa7xxxdc' ``` -------------------------------- ### Nearby Search with Keywords and Operators Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-near-by-api-example/Readme.md Demonstrates how to use the 'keywords' parameter with 'or' (;) and 'and' ($) operators to refine search results for nearby places. Spacing in the keywords parameter is ignored. ```html Search for coffee or tea AND seafood or alcohol ``` -------------------------------- ### Route ETA Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/readme.md Gets the updated duration of a route considering live traffic. Applicable for India only. ```APIDOC ## GET route_eta ### Description Gets the updated duration of a route considering live traffic. Applicable for India only. This resource balances between a preferred path and aggressive traffic congestion avoidance. ### Method GET ### Endpoint https://apis.mapmyindia.com/advancedmaps/v1/route_eta ### Parameters #### Query Parameters - **key** (string) - Required - Your assigned REST API license key. - **addr** (string) - Required - Comma-separated list of start and destination coordinates (latitude,longitude). - **profile** (string) - Optional - The routing profile to use (e.g., driving, biking, walking). - **region** (string) - Optional - Specifies the region for routing (e.g., 'ind'). ### Request Example ``` https://apis.mapmyindia.com/advancedmaps/v1/route_eta?key="assigned_REST_license_key"&addr="start_lat,start_lon|end_lat,end_lon"®ion=ind ``` ### Response #### Success Response (200) - **eta** (object) - Contains ETA details. - **duration** (number) - Estimated time of arrival. #### Response Example ```json { "eta": { "duration": 1100 } } ``` ``` -------------------------------- ### Show Route Details and Speak Advice Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/index.html Displays detailed route information by showing a popup for a specific advice point and pans the map to its location. It also includes speech synthesis to read out the advice text. ```javascript var advice_marker;var last_row_id=0; function show_route_details(route,advice_lat, advice_lng, advice_text,rowid) { if(rowid=="next"){if($("#" +route+"_"+(parseInt(last_row_id)+1)).length != 0) {$("#" +route+"_"+(parseInt(last_row_id)+1)).click();}return false;} if(rowid=="pre"){if($("#" +route+"_"+(parseInt(last_row_id)-1)).length != 0) {$("#" +route+"_"+(parseInt(last_row_id)-1)).click();}return false;} remove_advice_marker();last_row_id=rowid; var advice_pos = new L.LatLng(advice_lat, advice_lng); advice_marker = L.marker(advice_pos, {draggable: 'true', title: advice_text}).addTo(map); advice_marker.bindPopup(advice_text, {advice_text: true, autopan: true, zoomAnimation: true}).openPopup(); advicemarkersList.push(advice_marker); map.panTo(new L.LatLng(advice_lat,advice_lng)); /* map.fitBounds(advice_pos);*/ /***speak*/ var word=advice_text.replace(/(<(\[^>\]+)>)/ig,""); var u1 = new SpeechSynthesisUtterance(word); u1.lang = 'hi-IN';u1.pitch = 1;u1.rate = 2;u1.voiceURI = 'native';u1.volume = 1; speechSynthesis.speak(u1); } ``` -------------------------------- ### Accessing Route Advice Data Source: https://github.com/mappls-api/mapmyindia-rest-api/wiki/Parsing-Instructions---JavaScript This JSON snippet shows the structure of the first advice object within the first route. It details distance, icon class, coordinates (lat, lng), text instruction, and time. This format is useful for displaying step-by-step navigation. ```json routes[0][0] //First advice from first of the possible routes { distance: 32.7 icon_class: "leaflet-routing-icon-depart" lat: 28.611048 lng: 77.227426 text: "Head west on Akbar Road" time: 6.3 } ``` -------------------------------- ### Fit Markers to Bounds Utility Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-routing-api/index.html Adjusts the map view to fit the bounds defined by start and destination points. Assumes the map object and L.LatLngBounds are available. ```javascript function mapmyindia_fit_markers_into_bound(start_points_array, destination_points_array) { var bounds = new L.LatLngBounds([start_points_array[0], start_points_array[1]], [destination_points_array[0], destination_points_array[1]]); map.fitBounds(bounds); } ``` -------------------------------- ### Instruction Icons CSS Source: https://github.com/mappls-api/mapmyindia-rest-api/wiki/Instruction-Icons---CSS Defines the base styles for instruction icons and specific classes for different navigation maneuvers. Used to display turn-by-turn directions visually. ```css .leaflet-routing-icon { background-image: url('https://apis.mapmyindia.com/map_v3/osrm.directions.icons.color.svg'); -webkit-background-size: 455px 20px; background-size: 455px 20px; background-repeat: no-repeat; margin: 0; content: ''; display: inline-block; vertical-align: top; width: 20px; height: 20px; } .leaflet-routing-icon.lanes.invalid { filter: invert(50%);} .leaflet-routing-alt-minimized .leaflet-routing-icon { background-image: url('https://apis.mapmyindia.com/map_v3/osrm.directions.icons.color.svg'); } .leaflet-routing-icon-continue { background-position: 2px 0px; } .leaflet-routing-icon-sharp-right { background-position: -24px 0px; } .leaflet-routing-icon-turn-right { background-position: -50px 0px; } .leaflet-routing-icon-bear-right { background-position: -74px 0px; } .leaflet-routing-icon-u-turn { background-position: -101px 0px; } .leaflet-routing-icon-sharp-left { background-position: -127px 0px; } .leaflet-routing-icon-turn-left { background-position: -150px 0px; } .leaflet-routing-icon-bear-left { background-position: -175px 0px; } .leaflet-routing-icon-depart { background-position: -202px 0px; } .leaflet-routing-icon-enter-roundabout { background-position: -227px 0px; } .leaflet-routing-icon-arrive { background-position: -253px 0px; } .leaflet-routing-icon-via { background-position: -278px 0px; } .leaflet-routing-icon-fork { background-position: -305px 0px; } .leaflet-routing-icon-ramp-right { background-position: -331px 0px; } .leaflet-routing-icon-ramp-left { background-position: -352px 0px; } .leaflet-routing-icon-merge-left { background-position: -376px 0px; } .leaflet-routing-icon-merge-right { background-position: -403px 0px; } ``` -------------------------------- ### Auto Suggest API Request Source: https://github.com/mappls-api/mapmyindia-rest-api/blob/master/mapmyindia-maps-auto-suggest-api-example/Readme.md This snippet shows a sample GET request to the MapmyIndia Maps Auto Suggest API to find places based on a query and a specific location. ```APIDOC ## GET /api/places/search/json ### Description Retrieves a list of suggested locations based on a search query and a geographical location. ### Method GET ### Endpoint https://atlas.mapmyindia.com/api/places/search/json ### Parameters #### Query Parameters - **bridge** (string) - Optional - Used for internal bridging. - **query** (string) - Required - The search term for which to find suggestions. - **location** (string) - Required - The latitude and longitude coordinates (e.g., "28.627133913995547,77.23553525204144"). ### Request Example ``` curl --location --request GET 'https://atlas.mapmyindia.com/api/places/search/json?bridge=&query=गीतांजलि salon&location=28.627133913995547,77.23553525204144' --header 'Authorization: bearer 6xxxxxx4-9xxx-xxx7-xxxb-8dxxa7xxxdc' ``` ### Response #### Success Response (200) - **suggestedLocations** (array) - A list of suggested places. - **type** (string) - The type of the location (e.g., "POI"). - **placeAddress** (string) - The full address of the suggested location. - **eLoc** (string) - The eLoc identifier for the location. - **placeName** (string) - The name of the suggested place. - **alternateName** (string) - Any alternative name for the place. - **keywords** (array) - An array of keywords associated with the place. - **orderIndex** (integer) - The order in which the suggestion appears. - **suggester** (string) - The field used for suggestion (e.g., "placeName"). - **distance** (integer) - The distance from the specified location. - **userAddedLocations** (array) - A list of locations added by users (empty in this example). - **suggestedSearches** (array) - A list of suggested search terms (empty in this example). #### Response Example ```json { "suggestedLocations": [ { "type": "POI", "placeAddress": "D5, ग्राउण्ड फ्लोर, डिफेन्स कॉलोनी, नई दिल्ली, दिल्ली, 110024", "eLoc": "FWV1GA", "placeName": "गीतांजली सलोन", "alternateName": "", "keywords": [ "आरटीसीएसएलएन" ], "orderIndex": 1, "suggester": "placeName", "distance": 5592 }, { "type": "POI", "placeAddress": "S13, ग्राउण्ड फ्लोर, मेन मार्किट, ग्रीन पार्क, नई दिल्ली, दिल्ली, 110016", "eLoc": "GK3QFK", "placeName": "गीतांजली सलोन", "alternateName": "", "keywords": [ "आरटीसीएसएलएन" ], "orderIndex": 2, "suggester": "placeName", "distance": 8377 } ], "userAddedLocations": [], "suggestedSearches": [] } ``` ```