mapnests-browser-sdk 1.1.1 β 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -1
- package/dist/build_url.js +4 -1
- package/dist/client.d.ts +3 -0
- package/dist/client.js +7 -0
- package/dist/main.js +3 -0
- package/dist/modules/snap_to_road.d.ts +13 -0
- package/dist/modules/snap_to_road.js +2 -0
- package/dist/secure_request.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -35,7 +35,8 @@ A secure and efficient TS SDK for the **Mapnests Platform**, enabling powerful g
|
|
|
35
35
|
- [Search By Radius](#search-by-radius)
|
|
36
36
|
- [Multi Stop Point](#multi-stop-point)
|
|
37
37
|
- [Geocode Search](#geocode-search)
|
|
38
|
-
- [Detailed Search By PlaceId
|
|
38
|
+
- [Detailed Search By PlaceId](#detailed-search-by-placeId)
|
|
39
|
+
- [Snap to Road](#snap-to-road)
|
|
39
40
|
|
|
40
41
|
- [License](#license)
|
|
41
42
|
- [Contact](#contact)
|
|
@@ -706,6 +707,45 @@ console.log(detailsByPlaceId);
|
|
|
706
707
|
```
|
|
707
708
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
708
709
|
|
|
710
|
+
### Snap to Road
|
|
711
|
+
|
|
712
|
+
<a name="snap-to-road"></a>
|
|
713
|
+
|
|
714
|
+
> Returns the nearest roadβs latitude and longitude for the given input coordinates.
|
|
715
|
+
|
|
716
|
+
**Example Input:**
|
|
717
|
+
|
|
718
|
+
```ts
|
|
719
|
+
const snapToRoad = await client.snapToRoad({
|
|
720
|
+
mode: "walking",
|
|
721
|
+
latitude: 23.8103,
|
|
722
|
+
longitude: 90.4125
|
|
723
|
+
});
|
|
724
|
+
console.log(snapToRoad);
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
**Example Output:**
|
|
728
|
+
|
|
729
|
+
```json
|
|
730
|
+
{
|
|
731
|
+
"data": {
|
|
732
|
+
"waypoints": [
|
|
733
|
+
{
|
|
734
|
+
"address": "Lane 11 East",
|
|
735
|
+
"location": [
|
|
736
|
+
90.412496,
|
|
737
|
+
23.810403
|
|
738
|
+
],
|
|
739
|
+
"distance_meters": 11.41511481
|
|
740
|
+
}
|
|
741
|
+
]
|
|
742
|
+
},
|
|
743
|
+
"message": "Success",
|
|
744
|
+
"status": true
|
|
745
|
+
}
|
|
746
|
+
```
|
|
747
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
748
|
+
|
|
709
749
|
---
|
|
710
750
|
|
|
711
751
|
## License
|
package/dist/build_url.js
CHANGED
|
@@ -17,7 +17,7 @@ function buildURLFromJSON(label, baseUrl, jsonStr) {
|
|
|
17
17
|
const toLon = data.DestLon;
|
|
18
18
|
const mode = encodeURIComponent(data.Mode);
|
|
19
19
|
const path = label === 'distanceMatrixDetails' ? 'distancematrixdetails' : 'distancematrix';
|
|
20
|
-
const apiVersion = label === 'distanceMatrixDetails' ? '
|
|
20
|
+
const apiVersion = label === 'distanceMatrixDetails' ? 'v2' : 'v3';
|
|
21
21
|
return `${baseUrl}/routemap/api/${apiVersion}/routes/${path}?fromLat=${fromLat}&fromLong=${fromLon}&toLat=${toLat}&toLong=${toLon}&mode=${mode}`;
|
|
22
22
|
}
|
|
23
23
|
case 'pairwiseRouteSummary': {
|
|
@@ -66,6 +66,9 @@ function buildURLFromJSON(label, baseUrl, jsonStr) {
|
|
|
66
66
|
const page = data.Page ? `&page=${data.Page}` : '';
|
|
67
67
|
return `${baseUrl}/geomap/api/v2/search/radius?q=${query}&lat=${lat}&lon=${lon}&radius=${radius}&activeLocations=${activeLocations}${limit}${page}`;
|
|
68
68
|
}
|
|
69
|
+
case 'snapToRoad': {
|
|
70
|
+
return `${exports.BASE_URL}/routemap/api/v1/nearest/road`;
|
|
71
|
+
}
|
|
69
72
|
default:
|
|
70
73
|
throw new Error(`unsupported label: ${label}`);
|
|
71
74
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ReverseRequest, ReverseResponse } from "./modules/reverse";
|
|
|
10
10
|
import { SearchRequest, SearchResponse } from "./modules/search";
|
|
11
11
|
import { SearchBboxRequest } from "./modules/search_bbox";
|
|
12
12
|
import { SearchByRadiusRequest, SearchByRadiusResponse } from "./modules/search_by_radius";
|
|
13
|
+
import { SnapToRoadRequest, SnapToRoadResponse } from "./modules/snap_to_road";
|
|
13
14
|
export interface IClient {
|
|
14
15
|
distanceMatrix(request: DistanceMatrixRequest): Promise<DistanceMatrixResponse>;
|
|
15
16
|
pairwiseRouteSummary(request: PairwiseRouteSummaryRequest): Promise<PairwiseRouteSummaryResponse>;
|
|
@@ -22,6 +23,7 @@ export interface IClient {
|
|
|
22
23
|
multiStopPoint(request: MultiStopPointsRequest): Promise<MultiStopPointsResponse>;
|
|
23
24
|
autocomplete(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
24
25
|
searchByRadius(request: SearchByRadiusRequest): Promise<SearchByRadiusResponse>;
|
|
26
|
+
snapToRoad(request: SnapToRoadRequest): Promise<SnapToRoadResponse>;
|
|
25
27
|
searchWithBbox(request: SearchBboxRequest): Promise<string>;
|
|
26
28
|
}
|
|
27
29
|
export declare class Client implements IClient {
|
|
@@ -42,4 +44,5 @@ export declare class Client implements IClient {
|
|
|
42
44
|
geocode(request: GeocodeRequest): Promise<GeocodeResponse>;
|
|
43
45
|
multiStopPoint(request: MultiStopPointsRequest): Promise<MultiStopPointsResponse>;
|
|
44
46
|
details(request: DetailsRequest): Promise<DetailsResponse>;
|
|
47
|
+
snapToRoad(request: SnapToRoadRequest): Promise<SnapToRoadResponse>;
|
|
45
48
|
}
|
package/dist/client.js
CHANGED
|
@@ -99,5 +99,12 @@ class Client {
|
|
|
99
99
|
console.log("π Details Search by Place ID response:", response);
|
|
100
100
|
return response;
|
|
101
101
|
}
|
|
102
|
+
async snapToRoad(request) {
|
|
103
|
+
console.log("π Snap to Road request:", request);
|
|
104
|
+
const response = await this.makeRequest("snapToRoad", request);
|
|
105
|
+
console.log("π Snap to Road response:");
|
|
106
|
+
console.dir(response, { depth: null, colors: true });
|
|
107
|
+
return response;
|
|
108
|
+
}
|
|
102
109
|
}
|
|
103
110
|
exports.Client = Client;
|
package/dist/main.js
CHANGED
|
@@ -136,6 +136,9 @@ const index_1 = require("./index");
|
|
|
136
136
|
// β
SearchByRadiusRequest Example
|
|
137
137
|
const searchByRadiusRes = await cl.searchByRadius({ Query: "uttara", Lat: 23.7272064, Lon: 90.3861125, Radius: 5000, Limit: 1 });
|
|
138
138
|
console.log("============================> Search By Radius:", JSON.stringify(searchByRadiusRes, null, 2));
|
|
139
|
+
// β
Snap to Road Example
|
|
140
|
+
const snapToRoadRes = await cl.snapToRoad({ mode: "walking", latitude: 23.8103, longitude: 90.4125 });
|
|
141
|
+
console.log("============================> Snap to Road:", JSON.stringify(snapToRoadRes, null, 2));
|
|
139
142
|
}
|
|
140
143
|
catch (err) {
|
|
141
144
|
console.error("π₯ Error:", err);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PlaceDetail } from "./details_by_place_id";
|
|
2
|
+
import { Mode } from "./distance_matrix";
|
|
3
|
+
export interface SnapToRoadRequest {
|
|
4
|
+
mode: Mode;
|
|
5
|
+
latitude: number;
|
|
6
|
+
longitude: number;
|
|
7
|
+
numberOfNearestRoad?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SnapToRoadResponse {
|
|
10
|
+
data: PlaceDetail[];
|
|
11
|
+
message: string;
|
|
12
|
+
status: boolean;
|
|
13
|
+
}
|
package/dist/secure_request.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapnests-browser-sdk",
|
|
3
3
|
"description": "TypeScript SDK for Mapnests API integration (Distance Matrix, Distance Matrix Details, Pairwise Route Summary, Multi Source Route Summary, Search, Reverse, Autocomplete, Autocomplete Without Zone, Multi Stop Points, Details By Place ID, Search By Radius, Geocode)",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|