mapnests-browser-sdk 1.1.0 → 1.1.1
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 +19 -29
- package/dist/build_url.js +3 -9
- package/dist/client.d.ts +0 -2
- package/dist/client.js +0 -8
- package/dist/main.js +5 -9
- package/dist/modules/autocomplete.d.ts +1 -0
- package/dist/modules/pairwise_route_summary.d.ts +8 -1
- package/dist/secure_request.js +0 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,6 @@ A secure and efficient TS SDK for the **Mapnests Platform**, enabling powerful g
|
|
|
32
32
|
- [Search](#search)
|
|
33
33
|
- [Reverse](#reverse)
|
|
34
34
|
- [Autocomplete](#autocomplete)
|
|
35
|
-
- [Autocomplete Without Zone](#autocomplete-without-zone)
|
|
36
35
|
- [Search By Radius](#search-by-radius)
|
|
37
36
|
- [Multi Stop Point](#multi-stop-point)
|
|
38
37
|
- [Geocode Search](#geocode-search)
|
|
@@ -416,8 +415,27 @@ console.log(revRes);
|
|
|
416
415
|
**Example Input:**
|
|
417
416
|
|
|
418
417
|
```ts
|
|
418
|
+
//Without optional value
|
|
419
419
|
const autoCompleteRes = await client.autocomplete({ Query: "Gulshan Road"});
|
|
420
420
|
console.log(autoCompleteRes);
|
|
421
|
+
|
|
422
|
+
// Optional parameter: ActiveZone.
|
|
423
|
+
// If ActiveZone is set to true, the search results will be returned within the zone. (By Default ActiveZone is true)
|
|
424
|
+
// If ActiveZone is set to false, the search results will be not consider any zone data.
|
|
425
|
+
const autoCompleteRes = await client.autocomplete({ Query: "Gulshan Road", ActiveZone: true });
|
|
426
|
+
console.log(autoCompleteRes);
|
|
427
|
+
|
|
428
|
+
// Optional parameters: Latitude, Longitude, and Radius.
|
|
429
|
+
// If provided, the search results will be returned within a specified radius,
|
|
430
|
+
// using the given latitude and longitude as the center point.
|
|
431
|
+
const autoCompleteRes = await client.autocomplete({ Query: "Gulshan Road", Lat: 23.7806, Lon: 90.3984, Radius: 5000 });
|
|
432
|
+
console.log(autoCompleteRes);
|
|
433
|
+
|
|
434
|
+
// Optional parameter: Limit.
|
|
435
|
+
// If provided, the search results will be returned within a specified limit.
|
|
436
|
+
const autoCompleteRes = await client.autocomplete({ Query: "Gulshan Road", Limit: 1 });
|
|
437
|
+
console.log(autoCompleteRes);
|
|
438
|
+
|
|
421
439
|
```
|
|
422
440
|
|
|
423
441
|
**Example Output:**
|
|
@@ -444,34 +462,6 @@ console.log(autoCompleteRes);
|
|
|
444
462
|
|
|
445
463
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
446
464
|
|
|
447
|
-
### Autocomplete Without Zone
|
|
448
|
-
|
|
449
|
-
> Auto Complete suggests relevant places, streets, and landmarks as you type a partial search query.
|
|
450
|
-
|
|
451
|
-
**Example Input:**
|
|
452
|
-
|
|
453
|
-
```ts
|
|
454
|
-
const autocompleteResWithoutZone = await client.autocompleteWithoutZone({ Query: "Uttara"});
|
|
455
|
-
console.log( JSON.stringify(autocompleteResWithoutZone,));
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
**Example Output:**
|
|
459
|
-
|
|
460
|
-
```json
|
|
461
|
-
{
|
|
462
|
-
"data": [
|
|
463
|
-
{
|
|
464
|
-
"placeId": "7d7e8fd275bfd9be9853ada14417d104e824d1c11600599bd326fb858429d83c",
|
|
465
|
-
"name": "Uttara",
|
|
466
|
-
"address": "Uttara, House#21, Road 17, Sector 11, Uttara, Dhaka-1230",
|
|
467
|
-
"types": [
|
|
468
|
-
"amenity",
|
|
469
|
-
"restaurant",
|
|
470
|
-
"amenity"
|
|
471
|
-
]
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
```
|
|
475
465
|
|
|
476
466
|
### Search By Radius
|
|
477
467
|
|
package/dist/build_url.js
CHANGED
|
@@ -21,7 +21,7 @@ function buildURLFromJSON(label, baseUrl, jsonStr) {
|
|
|
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': {
|
|
24
|
-
return `${baseUrl}/routemap/api/
|
|
24
|
+
return `${baseUrl}/routemap/api/v2/routes/pairwise-summary`;
|
|
25
25
|
}
|
|
26
26
|
case 'multiSourceSummary': {
|
|
27
27
|
return `${baseUrl}/routemap/api/v1/routes/multi-source-summary`;
|
|
@@ -53,14 +53,8 @@ function buildURLFromJSON(label, baseUrl, jsonStr) {
|
|
|
53
53
|
const limit = data.Limit ? `&limit=${data.Limit}` : '';
|
|
54
54
|
const lat = data.Lat ? `&lat=${data.Lat}` : '';
|
|
55
55
|
const lon = data.Lon ? `&lon=${data.Lon}` : '';
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
case 'autocompleteWithoutZone': {
|
|
59
|
-
const query = encodeURIComponent(data.Query);
|
|
60
|
-
const limit = data.Limit ? `&limit=${data.Limit}` : '';
|
|
61
|
-
const lat = data.Lat ? `&lat=${data.Lat}` : '';
|
|
62
|
-
const lon = data.Lon ? `&lon=${data.Lon}` : '';
|
|
63
|
-
return `${baseUrl}/geomap/api/v1/autocomplete/all?q=${query}${limit}${lat}${lon}`;
|
|
56
|
+
const zoneActiveOnly = data.ZoneActiveOnly != undefined ? `&zoneActiveOnly=${data.ZoneActiveOnly}` : "";
|
|
57
|
+
return `${baseUrl}/geomap/api/v2/autocomplete?q=${query}${zoneActiveOnly}${limit}${lat}${lon}`;
|
|
64
58
|
}
|
|
65
59
|
case 'searchByRadius': {
|
|
66
60
|
const query = encodeURIComponent(data.Query);
|
package/dist/client.d.ts
CHANGED
|
@@ -21,7 +21,6 @@ export interface IClient {
|
|
|
21
21
|
geocode(request: GeocodeRequest): Promise<GeocodeResponse>;
|
|
22
22
|
multiStopPoint(request: MultiStopPointsRequest): Promise<MultiStopPointsResponse>;
|
|
23
23
|
autocomplete(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
24
|
-
autocompleteWithoutZone(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
25
24
|
searchByRadius(request: SearchByRadiusRequest): Promise<SearchByRadiusResponse>;
|
|
26
25
|
searchWithBbox(request: SearchBboxRequest): Promise<string>;
|
|
27
26
|
}
|
|
@@ -38,7 +37,6 @@ export declare class Client implements IClient {
|
|
|
38
37
|
reverse(request: ReverseRequest): Promise<ReverseResponse>;
|
|
39
38
|
search(request: SearchRequest): Promise<SearchResponse>;
|
|
40
39
|
autocomplete(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
41
|
-
autocompleteWithoutZone(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
42
40
|
searchWithBbox(request: SearchBboxRequest): Promise<string>;
|
|
43
41
|
searchByRadius(request: SearchByRadiusRequest): Promise<SearchByRadiusResponse>;
|
|
44
42
|
geocode(request: GeocodeRequest): Promise<GeocodeResponse>;
|
package/dist/client.js
CHANGED
|
@@ -64,14 +64,6 @@ class Client {
|
|
|
64
64
|
console.dir(response, { depth: null, colors: true });
|
|
65
65
|
return response;
|
|
66
66
|
}
|
|
67
|
-
async autocompleteWithoutZone(request) {
|
|
68
|
-
console.log("📍 Autocomplete Without Zone request:", request);
|
|
69
|
-
request.Query = (0, validate_query_length_1.validateAndNormalizeQuery)(request.Query);
|
|
70
|
-
const response = await this.makeRequest("autocompleteWithoutZone", request);
|
|
71
|
-
console.log("📍 Autocomplete Without Zone response:");
|
|
72
|
-
console.dir(response, { depth: null, colors: true });
|
|
73
|
-
return response;
|
|
74
|
-
}
|
|
75
67
|
//Under Maintenance
|
|
76
68
|
async searchWithBbox(request) {
|
|
77
69
|
console.log("📍 Search Bbox request:", request);
|
package/dist/main.js
CHANGED
|
@@ -72,7 +72,7 @@ const index_1 = require("./index");
|
|
|
72
72
|
},
|
|
73
73
|
],
|
|
74
74
|
});
|
|
75
|
-
console.log("============================> PairwiseRouteSummary:", pairwiseRes);
|
|
75
|
+
console.log("============================> PairwiseRouteSummary:", JSON.stringify(pairwiseRes));
|
|
76
76
|
// ✅ MultiSourceRouteSummaryRequest Example
|
|
77
77
|
const multiSourceRes = await cl.multiSourceRouteSummary({
|
|
78
78
|
sources: [
|
|
@@ -124,16 +124,12 @@ const index_1 = require("./index");
|
|
|
124
124
|
Mode: index_1.Mode.Car,
|
|
125
125
|
});
|
|
126
126
|
console.log("============================> MultiStopPoint:", JSON.stringify(multiStopRes, null, 2));
|
|
127
|
-
// ✅ Details By PlaceId Example
|
|
128
|
-
const detailsRes = await cl.details({ PlaceId: "4355aad6b8eb0b4f0ee3fa972ff9ac3fdc2d7f86f634d81f79dcf396f21826a0" });
|
|
129
|
-
console.log("============================> Details by Place ID:", detailsRes);
|
|
127
|
+
// // ✅ Details By PlaceId Example
|
|
128
|
+
// const detailsRes = await cl.details({ PlaceId: "4355aad6b8eb0b4f0ee3fa972ff9ac3fdc2d7f86f634d81f79dcf396f21826a0" });
|
|
129
|
+
// console.log("============================> Details by Place ID:", detailsRes);
|
|
130
130
|
// ✅ AutocompleteRequest Example
|
|
131
|
-
const autoCompleteRes = await cl.autocomplete({ Query: "
|
|
131
|
+
const autoCompleteRes = await cl.autocomplete({ Query: "Mirpur", Limit: 1, ZoneActiveOnly: true });
|
|
132
132
|
console.log("============================> Autocomplete:", JSON.stringify(autoCompleteRes, null, 2));
|
|
133
|
-
console.dir(autoCompleteRes, { depth: null, color: true });
|
|
134
|
-
// ✅ AutocompleteWithoutZoneRequest Example
|
|
135
|
-
const autocompleteResWithoutZone = await cl.autocompleteWithoutZone({ Query: "Uttara", limit: 2 });
|
|
136
|
-
console.log("============================> Autocomplete Without Zone:", JSON.stringify(autocompleteResWithoutZone, null, 2));
|
|
137
133
|
// ✅ SearchBboxRequest Example
|
|
138
134
|
const searchBboxRes = await cl.searchWithBbox({ Query: "uttara", TopLeftLat: 23.799012278864893, TopLeftLon: 90.43487817491183, BottomRightLat: 23.798243503885544, BottomRightLon: 90.43537003653393 });
|
|
139
135
|
console.log("============================> Search With Boundary box:", searchBboxRes);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Mode } from './distance_matrix';
|
|
2
|
+
import { Leg } from './distance_matrix_details';
|
|
2
3
|
export interface Coordinate {
|
|
3
4
|
lat: number;
|
|
4
5
|
lon: number;
|
|
@@ -12,15 +13,21 @@ export interface PairwiseRoute {
|
|
|
12
13
|
export interface PairwiseRouteSummaryRequest {
|
|
13
14
|
pairs: PairwiseRoute[];
|
|
14
15
|
}
|
|
16
|
+
export interface LegWithAnnotation extends Leg {
|
|
17
|
+
annotation: Record<string, unknown>;
|
|
18
|
+
}
|
|
15
19
|
export interface RouteSummary {
|
|
16
20
|
id: number;
|
|
17
21
|
distanceInMeters?: number;
|
|
18
22
|
etaInSeconds?: number;
|
|
19
23
|
geometry?: string;
|
|
24
|
+
legs?: LegWithAnnotation[];
|
|
20
25
|
error?: string;
|
|
21
26
|
}
|
|
22
27
|
export interface PairwiseRouteSummaryResponse {
|
|
23
28
|
status: boolean;
|
|
24
29
|
message: string;
|
|
25
|
-
data:
|
|
30
|
+
data: {
|
|
31
|
+
routeSummaries: RouteSummary[];
|
|
32
|
+
};
|
|
26
33
|
}
|
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.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|