mapnests-browser-sdk 1.0.7 → 1.0.8
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 +389 -24
- package/dist/build_url.js +46 -3
- package/dist/client.d.ts +26 -5
- package/dist/client.js +58 -3
- package/dist/index.d.ts +9 -4
- package/dist/index.js +9 -4
- package/dist/main.js +36 -5
- package/dist/modules/autocomplete.d.ts +17 -0
- package/dist/modules/autocomplete.js +2 -0
- package/dist/modules/details_by_place_id.d.ts +30 -0
- package/dist/modules/details_by_place_id.js +2 -0
- package/dist/modules/geocode.d.ts +21 -0
- package/dist/modules/geocode.js +2 -0
- package/dist/modules/multi_stop_points.d.ts +24 -0
- package/dist/modules/multi_stop_points.js +2 -0
- package/dist/modules/reverse.d.ts +16 -21
- package/dist/modules/search.d.ts +35 -7
- package/dist/modules/search_bbox.d.ts +10 -0
- package/dist/modules/search_bbox.js +2 -0
- package/dist/modules/search_by_radius.d.ts +16 -0
- package/dist/modules/search_by_radius.js +2 -0
- package/dist/request.d.ts +2 -1
- package/dist/request.js +3 -2
- package/dist/secure_req.d.ts +1 -1
- package/dist/secure_req.js +2 -2
- package/dist/secure_request.d.ts +1 -1
- package/dist/secure_request.js +9 -3
- package/dist/validate_query_length.d.ts +1 -0
- package/dist/validate_query_length.js +9 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -29,8 +29,14 @@ A secure and efficient TS SDK for the **Mapnests Platform**, enabling powerful g
|
|
|
29
29
|
- [Pairwise Route Summary](#pairwise-route-summary)
|
|
30
30
|
- [Multi Source Route Summary](#multi-source-route-summary)
|
|
31
31
|
- [Distance Matrix Details](#distance-matrix-details)
|
|
32
|
-
- [Search
|
|
33
|
-
- [Reverse
|
|
32
|
+
- [Search](#search)
|
|
33
|
+
- [Reverse](#reverse)
|
|
34
|
+
- [Autocomplete](#autocomplete)
|
|
35
|
+
- [Autocomplete Without Zone](#autocomplete-without-zone)
|
|
36
|
+
- [Search By Radius](#search-by-radius)
|
|
37
|
+
- [Multi Stop Point](#multi-stop-point)
|
|
38
|
+
- [Detailed Geolocation Information ](#detailed-geolocation-information)
|
|
39
|
+
- [Geocode Search](#geocode-search)
|
|
34
40
|
|
|
35
41
|
- [License](#license)
|
|
36
42
|
- [Contact](#contact)
|
|
@@ -63,6 +69,9 @@ import { Client, Mode } from "mapnests-browser-sdk"";
|
|
|
63
69
|
(async function () {
|
|
64
70
|
const client = new Client("YOUR_API_KEY", "your.package.name");
|
|
65
71
|
|
|
72
|
+
// With optional timeout (in milliseconds)
|
|
73
|
+
const clientWithTimeout = new Client("YOUR_API_KEY", "your.package.name", 30000); // 30 seconds
|
|
74
|
+
|
|
66
75
|
const result = await client.search({ Query: "Dhaka" });
|
|
67
76
|
console.log("Search result:", result);
|
|
68
77
|
})();
|
|
@@ -289,9 +298,9 @@ console.log(details);
|
|
|
289
298
|
|
|
290
299
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
291
300
|
|
|
292
|
-
### Search
|
|
301
|
+
### Search
|
|
293
302
|
|
|
294
|
-
> Finds places, streets, and landmarks
|
|
303
|
+
> Finds places, streets, and landmarks using text-based queries. The search can also be refined by providing latitude and longitude with radius support.
|
|
295
304
|
|
|
296
305
|
**Example Input:**
|
|
297
306
|
|
|
@@ -301,29 +310,61 @@ const searchRes = await client.search({
|
|
|
301
310
|
});
|
|
302
311
|
console.log(searchRes);
|
|
303
312
|
```
|
|
313
|
+
*To get only Zone Data provide ActiveLocations*
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
const searchRes = await client.search({
|
|
317
|
+
Query: "Bashundhara Residential Area, Dhaka",
|
|
318
|
+
ActiveLocations: true
|
|
319
|
+
});
|
|
320
|
+
console.log(searchRes);
|
|
321
|
+
```
|
|
322
|
+
|
|
304
323
|
|
|
305
324
|
**Example Output:**
|
|
306
325
|
|
|
307
326
|
```json
|
|
308
327
|
{
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
328
|
+
"data": {
|
|
329
|
+
"items": [
|
|
330
|
+
{
|
|
331
|
+
"placeId": "61aa7fe80c299c0a67966c8f2fbc9093626e38093c62cea2dc07b561f30f9d8c",
|
|
332
|
+
"lat": 23.8074008,
|
|
333
|
+
"lon": 90.3682003,
|
|
334
|
+
"types": [ "amenity", "bus_station", "amenity" ],
|
|
335
|
+
"address": "Bangladesh",
|
|
336
|
+
"name": "Mirpur-10",
|
|
337
|
+
"houseNumber": "",
|
|
338
|
+
"houseName": "",
|
|
339
|
+
"street": "",
|
|
340
|
+
"phone": "",
|
|
341
|
+
"website": "",
|
|
342
|
+
"country": "Bangladesh",
|
|
343
|
+
"city": "",
|
|
344
|
+
"thana": "",
|
|
345
|
+
"division": "",
|
|
346
|
+
"district": "",
|
|
347
|
+
"postalCode": "1216",
|
|
348
|
+
"plusCode": "",
|
|
349
|
+
"sublocality": "",
|
|
350
|
+
"localArea": ""
|
|
351
|
+
}
|
|
316
352
|
],
|
|
317
|
-
"
|
|
318
|
-
"
|
|
353
|
+
"itemsPerPage": 1,
|
|
354
|
+
"pageNumber": 1,
|
|
355
|
+
"totalItems": 27,
|
|
356
|
+
"totalPages": 27
|
|
357
|
+
},
|
|
358
|
+
"message": "Success",
|
|
359
|
+
"status": true
|
|
319
360
|
}
|
|
320
361
|
```
|
|
321
362
|
|
|
322
363
|
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
323
364
|
|
|
324
|
-
### Reverse
|
|
365
|
+
### Reverse
|
|
325
366
|
|
|
326
|
-
>
|
|
367
|
+
> Reverse geocodes coordinates to return detailed location information for a given latitude and longitude.
|
|
327
368
|
|
|
328
369
|
**Example Input:**
|
|
329
370
|
|
|
@@ -336,16 +377,340 @@ console.log(revRes);
|
|
|
336
377
|
|
|
337
378
|
```json
|
|
338
379
|
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
380
|
+
"data": {
|
|
381
|
+
"placeId": "a4d8c105e24fbc3d91bb0486e1701fa20b9b56329df0fc5c47f7df003e3cc579",
|
|
382
|
+
"lat": 23.7952951,
|
|
383
|
+
"lon": 90.41680379038863,
|
|
384
|
+
"category": "",
|
|
385
|
+
"type": "yes",
|
|
386
|
+
"class": "building",
|
|
387
|
+
"name": "Concord Ik Tower",
|
|
388
|
+
"address": "Concord Ik Tower, House#2, Road 94, Gulshan North Avenue, Gulshan 2, Gulshan, Dhaka-1212",
|
|
389
|
+
"country": "Bangladesh",
|
|
390
|
+
"city": "Gulshan 2, Dhaka",
|
|
391
|
+
"thana": "Gulshan",
|
|
392
|
+
"district": "Dhaka",
|
|
393
|
+
"division": "",
|
|
394
|
+
"postalCode": "1212",
|
|
395
|
+
"website": "",
|
|
396
|
+
"houseNumber": "2",
|
|
397
|
+
"houseName": "",
|
|
398
|
+
"subLocality": "",
|
|
399
|
+
"localArea": "",
|
|
400
|
+
"types": [
|
|
401
|
+
"building",
|
|
402
|
+
"yes",
|
|
403
|
+
"building"
|
|
404
|
+
]
|
|
405
|
+
},
|
|
406
|
+
"message": "Success",
|
|
407
|
+
"status": true
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
413
|
+
|
|
414
|
+
### Autocomplete
|
|
415
|
+
|
|
416
|
+
> Auto Complete suggests relevant places, streets, and landmarks as you type a partial search query.
|
|
417
|
+
|
|
418
|
+
**Example Input:**
|
|
419
|
+
|
|
420
|
+
```ts
|
|
421
|
+
const autoCompleteRes = await client.autocomplete({ Query: "Gulshan Road"});
|
|
422
|
+
console.log(autoCompleteRes);
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Example Output:**
|
|
426
|
+
|
|
427
|
+
```json
|
|
428
|
+
{
|
|
429
|
+
"data": [
|
|
430
|
+
{
|
|
431
|
+
"placeId": "4e7820118661ce107f308dff7648bf0a9d2847b78b720b08c9d39fe3662c4a8c",
|
|
432
|
+
"name": "Gulshan",
|
|
433
|
+
"address": "Gulshan, House#76, Palolika, Road-24, Gulshan-1, Gulshan, Dhaka-1212",
|
|
434
|
+
"types": [
|
|
435
|
+
"landuse",
|
|
436
|
+
"residential",
|
|
437
|
+
"landuse"
|
|
438
|
+
]
|
|
439
|
+
}
|
|
440
|
+
],
|
|
441
|
+
"message": "Success",
|
|
442
|
+
"status": true
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
```
|
|
446
|
+
|
|
447
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
448
|
+
|
|
449
|
+
### Autocomplete Without Zone
|
|
450
|
+
|
|
451
|
+
> Auto Complete suggests relevant places, streets, and landmarks as you type a partial search query.
|
|
452
|
+
|
|
453
|
+
**Example Input:**
|
|
454
|
+
|
|
455
|
+
```ts
|
|
456
|
+
const autocompleteResWithoutZone = await client.autocompleteWithoutZone({ Query: "Uttara"});
|
|
457
|
+
console.log( JSON.stringify(autocompleteResWithoutZone,));
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
**Example Output:**
|
|
461
|
+
|
|
462
|
+
```json
|
|
463
|
+
{
|
|
464
|
+
"data": [
|
|
465
|
+
{
|
|
466
|
+
"placeId": "7d7e8fd275bfd9be9853ada14417d104e824d1c11600599bd326fb858429d83c",
|
|
467
|
+
"name": "Uttara",
|
|
468
|
+
"address": "Uttara, House#21, Road 17, Sector 11, Uttara, Dhaka-1230",
|
|
469
|
+
"types": [
|
|
470
|
+
"amenity",
|
|
471
|
+
"restaurant",
|
|
472
|
+
"amenity"
|
|
473
|
+
]
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Search By Radius
|
|
479
|
+
|
|
480
|
+
> Finds places, streets, and landmarks using text-based queries. All searches are restricted to results within the specified radius, which requires latitude, longitude, and radius parameters.
|
|
481
|
+
|
|
482
|
+
**Example Input:**
|
|
483
|
+
|
|
484
|
+
```ts
|
|
485
|
+
const searchByRadiusRes = await cl.searchByRadius({
|
|
486
|
+
Query: "uttara", Lat: 23.7272064, Lon: 90.3861125, Radius: 5000
|
|
487
|
+
});
|
|
488
|
+
console.log(searchByRadiusRes);
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
**Example Output:**
|
|
492
|
+
|
|
493
|
+
```json
|
|
494
|
+
{
|
|
495
|
+
"data": {
|
|
496
|
+
"items": [
|
|
497
|
+
{
|
|
498
|
+
"placeId": "f6e5bf556e2163d89f65d634b6456d28736a6a72dc1c1df933a8b13d0597956a",
|
|
499
|
+
"lat": 23.714221,
|
|
500
|
+
"lon": 90.4059638,
|
|
501
|
+
"types": [ "amenity", "bank", "amenity" ],
|
|
502
|
+
"address": "Uttara Bank",
|
|
503
|
+
"name": "Uttara Bank",
|
|
504
|
+
"houseNumber": "",
|
|
505
|
+
"houseName": "",
|
|
506
|
+
"street": "Nawab Yousuf Sarak",
|
|
507
|
+
"phone": "",
|
|
508
|
+
"website": "",
|
|
509
|
+
"country": "Bangladesh",
|
|
510
|
+
"city": "",
|
|
511
|
+
"thana": "",
|
|
512
|
+
"division": "",
|
|
513
|
+
"district": "",
|
|
514
|
+
"postalCode": "1100",
|
|
515
|
+
"plusCode": "",
|
|
516
|
+
"sublocality": "",
|
|
517
|
+
"localArea": ""
|
|
518
|
+
}
|
|
519
|
+
],
|
|
520
|
+
"itemsPerPage": 1,
|
|
521
|
+
"pageNumber": 1,
|
|
522
|
+
"totalItems": 12,
|
|
523
|
+
"totalPages": 12
|
|
524
|
+
},
|
|
525
|
+
"message": "Success",
|
|
526
|
+
"status": true
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
532
|
+
|
|
533
|
+
### Multi Stop Point
|
|
534
|
+
|
|
535
|
+
> Calculates distance, ETA, and route geometry for a journey starting from a single source and passing through multiple stop points in sequence. It returns both total and per-segment results, processes routes concurrently for efficiency, and supports multiple stops.
|
|
536
|
+
|
|
537
|
+
**Example Input:**
|
|
538
|
+
|
|
539
|
+
```ts
|
|
540
|
+
const multiStopRes = await client.multiStopPoint({
|
|
541
|
+
Src: { lat: 23.8103, lon: 90.4125 },
|
|
542
|
+
StopPoints: [
|
|
543
|
+
{ id: 1, lat: 23.8113, lon: 90.4135 },
|
|
544
|
+
{ id: 2, lat: 23.8123, lon: 90.4145 },
|
|
545
|
+
{ id: 3, lat: 23.8133, lon: 90.4155 },
|
|
546
|
+
],
|
|
547
|
+
Mode: Mode.Car,
|
|
548
|
+
});
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
**Example Output:**
|
|
552
|
+
|
|
553
|
+
```json
|
|
554
|
+
{
|
|
555
|
+
"data": {
|
|
556
|
+
"distanceInMeters": 1357.7999725341797,
|
|
557
|
+
"etaInSeconds": 252.10000228881836,
|
|
558
|
+
"routeSummaries": [
|
|
559
|
+
{
|
|
560
|
+
"id": 1,
|
|
561
|
+
"source": {
|
|
562
|
+
"lat": 23.8103,
|
|
563
|
+
"lon": 90.4125
|
|
564
|
+
},
|
|
565
|
+
"stopPoint": {
|
|
566
|
+
"lat": 23.8113,
|
|
567
|
+
"lon": 90.4135
|
|
568
|
+
},
|
|
569
|
+
"distanceInMeters": 213.3,
|
|
570
|
+
"etaInSeconds": 47.3,
|
|
571
|
+
"geometry": "_nipCcuyfPCkB}DJCgB"
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
"id": 2,
|
|
575
|
+
"source": {
|
|
576
|
+
"lat": 23.8113,
|
|
577
|
+
"lon": 90.4135
|
|
578
|
+
},
|
|
579
|
+
"stopPoint": {
|
|
580
|
+
"lat": 23.8123,
|
|
581
|
+
"lon": 90.4145
|
|
582
|
+
},
|
|
583
|
+
"distanceInMeters": 191.4,
|
|
584
|
+
"etaInSeconds": 44.5,
|
|
585
|
+
"geometry": "etipCk{yfPEaDQc@}CD"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"id": 3,
|
|
589
|
+
"source": {
|
|
590
|
+
"lat": 23.8123,
|
|
591
|
+
"lon": 90.4145
|
|
592
|
+
},
|
|
593
|
+
"stopPoint": {
|
|
594
|
+
"lat": 23.8133,
|
|
595
|
+
"lon": 90.4155
|
|
596
|
+
},
|
|
597
|
+
"distanceInMeters": 953.1,
|
|
598
|
+
"etaInSeconds": 160.3,
|
|
599
|
+
"geometry": "{yipCkazfPmBDG}CqO`@UKYo@CWT_E`FS@p@jAPpDMBbC"
|
|
600
|
+
}
|
|
601
|
+
]
|
|
602
|
+
},
|
|
603
|
+
"message": "Success",
|
|
604
|
+
"status": true
|
|
605
|
+
}
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
609
|
+
|
|
610
|
+
### Detailed Geolocation Information
|
|
611
|
+
|
|
612
|
+
> Provide detailed geolocation information for a place using its unique place_id, including address, coordinates, administrative regions, contact details, and metadata.
|
|
613
|
+
|
|
614
|
+
**Example Input:**
|
|
615
|
+
|
|
616
|
+
```ts
|
|
617
|
+
const detailsRes = await client.details({ PlaceId: "a97641e310481507f5bfdbeed6f0e946358b252bb3f82103ed7f5e59b04d422e" });
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
**Example Output:**
|
|
621
|
+
|
|
622
|
+
```json
|
|
623
|
+
{
|
|
624
|
+
"data": {
|
|
625
|
+
"placeId": "a97641e310481507f5bfdbeed6f0e946358b252bb3f82103ed7f5e59b04d422e",
|
|
626
|
+
"lat": 23.8696386,
|
|
627
|
+
"lon": 90.3995743,
|
|
628
|
+
"types": [
|
|
629
|
+
"shop",
|
|
630
|
+
"travel_agency",
|
|
631
|
+
"shop"
|
|
632
|
+
],
|
|
633
|
+
"address": "Uttara",
|
|
634
|
+
"name": "Nogor Travel Agency",
|
|
635
|
+
"houseNumber": "9",
|
|
636
|
+
"houseName": "",
|
|
637
|
+
"street": "Road 7",
|
|
638
|
+
"phone": "",
|
|
639
|
+
"website": "",
|
|
640
|
+
"country": "Bangladesh",
|
|
641
|
+
"city": "Uttara, Dhaka",
|
|
642
|
+
"thana": "Uttara West",
|
|
643
|
+
"division": "",
|
|
644
|
+
"district": "Dhaka",
|
|
645
|
+
"postalCode": "1230",
|
|
646
|
+
"plusCode": "",
|
|
647
|
+
"sublocality": "",
|
|
648
|
+
"localArea": ""
|
|
649
|
+
},
|
|
650
|
+
"message": "Success",
|
|
651
|
+
"status": true
|
|
652
|
+
}
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
<p align="right">(<a href="#readme-top">back to top</a>)</p>
|
|
656
|
+
|
|
657
|
+
### Geocode Search
|
|
658
|
+
|
|
659
|
+
> Search for details about places, streets, and landmarks using a text query.
|
|
660
|
+
|
|
661
|
+
**Example Input:**
|
|
662
|
+
|
|
663
|
+
```ts
|
|
664
|
+
const geocodeRes = await client.geocode({ Query: "Mirpur" });
|
|
665
|
+
```
|
|
666
|
+
|
|
667
|
+
**Example Output:**
|
|
668
|
+
|
|
669
|
+
```json
|
|
670
|
+
{
|
|
671
|
+
"data": [
|
|
672
|
+
{
|
|
673
|
+
"place_id": 373373,
|
|
674
|
+
"lat": "23.9363038",
|
|
675
|
+
"lon": "88.997764",
|
|
676
|
+
"category": "boundary",
|
|
677
|
+
"type": "administrative",
|
|
678
|
+
"place_rank": 12,
|
|
679
|
+
"importance": 0.24000999999999997,
|
|
680
|
+
"addresstype": "town",
|
|
681
|
+
"name": "Mirpur",
|
|
682
|
+
"display_name": "Mirpur, Kushtia District, Khulna Division, Bangladesh",
|
|
683
|
+
"address": ""
|
|
346
684
|
},
|
|
347
|
-
|
|
348
|
-
|
|
685
|
+
{
|
|
686
|
+
"place_id": 399534,
|
|
687
|
+
"lat": "23.1460109",
|
|
688
|
+
"lon": "90.7556272",
|
|
689
|
+
"category": "place",
|
|
690
|
+
"type": "village",
|
|
691
|
+
"place_rank": 19,
|
|
692
|
+
"importance": 0.14667666666666662,
|
|
693
|
+
"addresstype": "village",
|
|
694
|
+
"name": "Mirpur",
|
|
695
|
+
"display_name": "Mirpur, Faridganj Upazila, Chandpur District, Chattogram Division, Bangladesh",
|
|
696
|
+
"address": ""
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
"place_id": 479355,
|
|
700
|
+
"lat": "23.817758949999998",
|
|
701
|
+
"lon": "90.37244789599441",
|
|
702
|
+
"category": "place",
|
|
703
|
+
"type": "suburb",
|
|
704
|
+
"place_rank": 19,
|
|
705
|
+
"importance": 0.14667666666666662,
|
|
706
|
+
"addresstype": "suburb",
|
|
707
|
+
"name": "Mirpur",
|
|
708
|
+
"display_name": "Mirpur, Dhaka, Dhaka Metropolitan, Dhaka District, Dhaka Division, 1216, Bangladesh",
|
|
709
|
+
"address": ""
|
|
710
|
+
}
|
|
711
|
+
],
|
|
712
|
+
"message": "Success",
|
|
713
|
+
"status": true
|
|
349
714
|
}
|
|
350
715
|
```
|
|
351
716
|
|
package/dist/build_url.js
CHANGED
|
@@ -7,7 +7,7 @@ function buildURLFromJSON(label, baseUrl, jsonStr) {
|
|
|
7
7
|
const data = JSON.parse(jsonStr);
|
|
8
8
|
switch (label) {
|
|
9
9
|
case 'reverse': {
|
|
10
|
-
return `${baseUrl}/geomap/api/
|
|
10
|
+
return `${baseUrl}/geomap/api/v2/reverse?lat=${data.Lat}&lon=${data.Lon}`;
|
|
11
11
|
}
|
|
12
12
|
case 'distanceMatrix':
|
|
13
13
|
case 'distanceMatrixDetails': {
|
|
@@ -17,7 +17,8 @@ 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
|
-
|
|
20
|
+
const apiVersion = label === 'distanceMatrixDetails' ? 'v1' : 'v3';
|
|
21
|
+
return `${baseUrl}/routemap/api/${apiVersion}/routes/${path}?fromLat=${fromLat}&fromLong=${fromLon}&toLat=${toLat}&toLong=${toLon}&mode=${mode}`;
|
|
21
22
|
}
|
|
22
23
|
case 'pairwiseRouteSummary': {
|
|
23
24
|
return `${baseUrl}/routemap/api/v1/routes/pairwise-summary`;
|
|
@@ -27,7 +28,49 @@ function buildURLFromJSON(label, baseUrl, jsonStr) {
|
|
|
27
28
|
}
|
|
28
29
|
case 'search': {
|
|
29
30
|
const query = encodeURIComponent(data.Query);
|
|
30
|
-
|
|
31
|
+
const lat = data.Lat ? `&lat=${data.Lat}` : '';
|
|
32
|
+
const lon = data.Lon ? `&lon=${data.Lon}` : '';
|
|
33
|
+
const radius = data.Radius ? `&radius=${data.Radius}` : '';
|
|
34
|
+
const activeLocations = !!data.ActiveLocations;
|
|
35
|
+
const limit = data.Limit ? `&limit=${data.Limit}` : '';
|
|
36
|
+
const page = data.Page ? `&page=${data.Page}` : '';
|
|
37
|
+
return `${baseUrl}/geomap/api/v2/search?q=${query}&activeLocations=${activeLocations}${limit}${lat}${lon}${radius}${page}`;
|
|
38
|
+
}
|
|
39
|
+
case 'detailsByPlaceId': {
|
|
40
|
+
const placeId = encodeURIComponent(data.PlaceId);
|
|
41
|
+
return `${baseUrl}/geomap/api/v1/details/${placeId}`;
|
|
42
|
+
}
|
|
43
|
+
case 'geocode': {
|
|
44
|
+
const query = encodeURIComponent(data.Query);
|
|
45
|
+
const limit = data.Limit ? `&limit=${data.Limit}` : '';
|
|
46
|
+
return `${baseUrl}/geomap/api/v2/geocode?q=${query}${limit}`;
|
|
47
|
+
}
|
|
48
|
+
case 'multiStopPoints': {
|
|
49
|
+
return `${baseUrl}/routemap/api/v1/routes/multi-stoppoints`;
|
|
50
|
+
}
|
|
51
|
+
case 'autocomplete': {
|
|
52
|
+
const query = encodeURIComponent(data.Query);
|
|
53
|
+
const limit = data.Limit ? `&limit=${data.Limit}` : '';
|
|
54
|
+
const lat = data.Lat ? `&lat=${data.Lat}` : '';
|
|
55
|
+
const lon = data.Lon ? `&lon=${data.Lon}` : '';
|
|
56
|
+
return `${baseUrl}/geomap/api/v1/autocomplete?q=${query}${limit}${lat}${lon}`;
|
|
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}`;
|
|
64
|
+
}
|
|
65
|
+
case 'searchByRadius': {
|
|
66
|
+
const query = encodeURIComponent(data.Query);
|
|
67
|
+
const lat = data.Lat;
|
|
68
|
+
const lon = data.Lon;
|
|
69
|
+
const radius = data.Radius;
|
|
70
|
+
const activeLocations = !!data.ActiveLocations;
|
|
71
|
+
const limit = data.Limit ? `&limit=${data.Limit}` : '';
|
|
72
|
+
const page = data.Page ? `&page=${data.Page}` : '';
|
|
73
|
+
return `${baseUrl}/geomap/api/v2/search/radius?q=${query}&lat=${lat}&lon=${lon}&radius=${radius}&activeLocations=${activeLocations}${limit}${page}`;
|
|
31
74
|
}
|
|
32
75
|
default:
|
|
33
76
|
throw new Error(`unsupported label: ${label}`);
|
package/dist/client.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AutocompleteRequest, AutocompleteResponse } from "./modules/autocomplete";
|
|
2
|
+
import { DetailsRequest, DetailsResponse } from "./modules/details_by_place_id";
|
|
3
3
|
import { DistanceMatrixRequest, DistanceMatrixResponse } from "./modules/distance_matrix";
|
|
4
|
-
import { PairwiseRouteSummaryRequest, PairwiseRouteSummaryResponse } from "./modules/pairwise_route_summary";
|
|
5
4
|
import { DistanceMatrixDetailsRequest, DistanceMatrixDetailsResponse } from "./modules/distance_matrix_details";
|
|
5
|
+
import { GeocodeRequest, GeocodeResponse } from "./modules/geocode";
|
|
6
6
|
import { MultiSourceRouteSummaryRequest, MultiSourceRouteSummaryResponse } from "./modules/multi_source_route_summary";
|
|
7
|
+
import { MultiStopPointsRequest, MultiStopPointsResponse } from "./modules/multi_stop_points";
|
|
8
|
+
import { PairwiseRouteSummaryRequest, PairwiseRouteSummaryResponse } from "./modules/pairwise_route_summary";
|
|
9
|
+
import { ReverseRequest, ReverseResponse } from "./modules/reverse";
|
|
10
|
+
import { SearchRequest, SearchResponse } from "./modules/search";
|
|
11
|
+
import { SearchByRadiusRequest, SearchByRadiusResponse } from "./modules/search_by_radius";
|
|
12
|
+
import { SearchBboxRequest } from "./modules/search_bbox";
|
|
7
13
|
export interface IClient {
|
|
8
14
|
distanceMatrix(request: DistanceMatrixRequest): Promise<DistanceMatrixResponse>;
|
|
9
15
|
pairwiseRouteSummary(request: PairwiseRouteSummaryRequest): Promise<PairwiseRouteSummaryResponse>;
|
|
@@ -11,16 +17,31 @@ export interface IClient {
|
|
|
11
17
|
distanceMatrixDetails(request: DistanceMatrixDetailsRequest): Promise<DistanceMatrixDetailsResponse>;
|
|
12
18
|
reverse(request: ReverseRequest): Promise<ReverseResponse>;
|
|
13
19
|
search(request: SearchRequest): Promise<SearchResponse>;
|
|
20
|
+
details(request: DetailsRequest): Promise<DetailsResponse>;
|
|
21
|
+
geocode(request: GeocodeRequest): Promise<GeocodeResponse>;
|
|
22
|
+
multiStopPoint(request: MultiStopPointsRequest): Promise<MultiStopPointsResponse>;
|
|
23
|
+
autocomplete(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
24
|
+
autocompleteWithoutZone(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
25
|
+
searchByRadius(request: SearchByRadiusRequest): Promise<SearchByRadiusResponse>;
|
|
26
|
+
searchWithBbox(request: SearchBboxRequest): Promise<string>;
|
|
14
27
|
}
|
|
15
28
|
export declare class Client implements IClient {
|
|
16
29
|
private apiKey;
|
|
17
30
|
private packageName;
|
|
18
|
-
|
|
31
|
+
private timeOutMs?;
|
|
32
|
+
constructor(apiKey: string, packageName: string, timeOutMs?: number | undefined);
|
|
19
33
|
private makeRequest;
|
|
20
34
|
distanceMatrix(request: DistanceMatrixRequest): Promise<DistanceMatrixResponse>;
|
|
21
35
|
pairwiseRouteSummary(request: PairwiseRouteSummaryRequest): Promise<PairwiseRouteSummaryResponse>;
|
|
22
36
|
multiSourceRouteSummary(request: MultiSourceRouteSummaryRequest): Promise<MultiSourceRouteSummaryResponse>;
|
|
23
37
|
distanceMatrixDetails(request: DistanceMatrixDetailsRequest): Promise<DistanceMatrixDetailsResponse>;
|
|
24
38
|
reverse(request: ReverseRequest): Promise<ReverseResponse>;
|
|
25
|
-
search(request: SearchRequest): Promise<
|
|
39
|
+
search(request: SearchRequest): Promise<any>;
|
|
40
|
+
autocomplete(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
41
|
+
autocompleteWithoutZone(request: AutocompleteRequest): Promise<AutocompleteResponse>;
|
|
42
|
+
searchWithBbox(request: SearchBboxRequest): Promise<string>;
|
|
43
|
+
searchByRadius(request: SearchByRadiusRequest): Promise<SearchByRadiusResponse>;
|
|
44
|
+
geocode(request: GeocodeRequest): Promise<GeocodeResponse>;
|
|
45
|
+
multiStopPoint(request: MultiStopPointsRequest): Promise<MultiStopPointsResponse>;
|
|
46
|
+
details(request: DetailsRequest): Promise<DetailsResponse>;
|
|
26
47
|
}
|
package/dist/client.js
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Client = void 0;
|
|
4
4
|
const secure_req_1 = require("./secure_req");
|
|
5
|
+
const validate_query_length_1 = require("./validate_query_length");
|
|
6
|
+
const underMaintenanceMessage = "This method is currently under maintenance. Please try again later.";
|
|
5
7
|
class Client {
|
|
6
|
-
constructor(apiKey, packageName) {
|
|
8
|
+
constructor(apiKey, packageName, timeOutMs) {
|
|
7
9
|
this.apiKey = apiKey;
|
|
8
10
|
this.packageName = packageName;
|
|
11
|
+
this.timeOutMs = timeOutMs;
|
|
9
12
|
}
|
|
10
13
|
async makeRequest(label, request) {
|
|
11
|
-
const { statusCode, response, errorMessage } = await (0, secure_req_1.callSecureRequest)(label, this.apiKey, this.packageName, request);
|
|
14
|
+
const { statusCode, response, errorMessage } = await (0, secure_req_1.callSecureRequest)(label, this.apiKey, this.packageName, request, this.timeOutMs);
|
|
12
15
|
if (errorMessage) {
|
|
13
16
|
throw new Error(`[${label}] native error: ${errorMessage}`);
|
|
14
17
|
}
|
|
@@ -45,8 +48,60 @@ class Client {
|
|
|
45
48
|
}
|
|
46
49
|
async search(request) {
|
|
47
50
|
console.log("📍 Search request:", request);
|
|
51
|
+
(0, validate_query_length_1.validateQueryLength)(request.Query);
|
|
48
52
|
const response = await this.makeRequest("search", request);
|
|
49
|
-
console.log("📍 Search response:"
|
|
53
|
+
console.log("📍 Search response:");
|
|
54
|
+
console.dir(response, { depth: null, colors: true });
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
async autocomplete(request) {
|
|
58
|
+
console.log("📍 Autocomplete request:", request);
|
|
59
|
+
(0, validate_query_length_1.validateQueryLength)(request.Query);
|
|
60
|
+
const response = await this.makeRequest("autocomplete", request);
|
|
61
|
+
console.log("📍 Autocomplete response:");
|
|
62
|
+
console.dir(response, { depth: null, colors: true });
|
|
63
|
+
return response;
|
|
64
|
+
}
|
|
65
|
+
async autocompleteWithoutZone(request) {
|
|
66
|
+
console.log("📍 Autocomplete Without Zone request:", request);
|
|
67
|
+
(0, validate_query_length_1.validateQueryLength)(request.Query);
|
|
68
|
+
const response = await this.makeRequest("autocompleteWithoutZone", request);
|
|
69
|
+
console.log("📍 Autocomplete Without Zone response:");
|
|
70
|
+
console.dir(response, { depth: null, colors: true });
|
|
71
|
+
return response;
|
|
72
|
+
}
|
|
73
|
+
//Under Maintenance
|
|
74
|
+
async searchWithBbox(request) {
|
|
75
|
+
console.log("📍 Search Bbox request:", request);
|
|
76
|
+
// validateQueryLength(request.Query);
|
|
77
|
+
console.log("📍 Search Bbox response:", underMaintenanceMessage);
|
|
78
|
+
return underMaintenanceMessage;
|
|
79
|
+
}
|
|
80
|
+
// Under Maintenance
|
|
81
|
+
async searchByRadius(request) {
|
|
82
|
+
(0, validate_query_length_1.validateQueryLength)(request.Query);
|
|
83
|
+
console.log("📍 Search by Radius request:", request);
|
|
84
|
+
const response = await this.makeRequest("searchByRadius", request);
|
|
85
|
+
console.log("📍 Search By Radius response:");
|
|
86
|
+
console.dir(response, { depth: null, colors: true });
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
async geocode(request) {
|
|
90
|
+
console.log("📍 Geocode search request", request);
|
|
91
|
+
const response = await this.makeRequest("geocode", request);
|
|
92
|
+
console.log("📍 Geocode response:", response);
|
|
93
|
+
return response;
|
|
94
|
+
}
|
|
95
|
+
async multiStopPoint(request) {
|
|
96
|
+
console.log("📍 Multi stop point search request", request);
|
|
97
|
+
const response = await this.makeRequest("multiStopPoints", request);
|
|
98
|
+
console.log("📍 Multi stop point response:", response);
|
|
99
|
+
return response;
|
|
100
|
+
}
|
|
101
|
+
async details(request) {
|
|
102
|
+
console.log("📍 Details Search by Place ID request:", request);
|
|
103
|
+
const response = await this.makeRequest("detailsByPlaceId", request);
|
|
104
|
+
console.log("📍 Details Search by Place ID response:", response);
|
|
50
105
|
return response;
|
|
51
106
|
}
|
|
52
107
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
export * from "./fetch_remote_time";
|
|
2
|
+
export * from "./modules/autocomplete";
|
|
3
|
+
export * from "./modules/details_by_place_id";
|
|
1
4
|
export * from "./modules/distance_matrix";
|
|
2
|
-
export * from "./modules/pairwise_route_summary";
|
|
3
5
|
export * from "./modules/distance_matrix_details";
|
|
4
|
-
export * from "./modules/
|
|
5
|
-
export * from "./modules/search";
|
|
6
|
+
export * from "./modules/geocode";
|
|
6
7
|
export * from "./modules/multi_source_route_summary";
|
|
8
|
+
export * from "./modules/multi_stop_points";
|
|
7
9
|
export * from "./modules/pairwise_route_summary";
|
|
8
|
-
export * from "./
|
|
10
|
+
export * from "./modules/reverse";
|
|
11
|
+
export * from "./modules/search";
|
|
12
|
+
export * from "./modules/search_by_radius";
|
|
13
|
+
export * from "./modules/search_bbox";
|
|
9
14
|
export { Client } from "./client";
|
package/dist/index.js
CHANGED
|
@@ -15,13 +15,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Client = void 0;
|
|
18
|
+
__exportStar(require("./fetch_remote_time"), exports);
|
|
19
|
+
__exportStar(require("./modules/autocomplete"), exports);
|
|
20
|
+
__exportStar(require("./modules/details_by_place_id"), exports);
|
|
18
21
|
__exportStar(require("./modules/distance_matrix"), exports);
|
|
19
|
-
__exportStar(require("./modules/pairwise_route_summary"), exports);
|
|
20
22
|
__exportStar(require("./modules/distance_matrix_details"), exports);
|
|
21
|
-
__exportStar(require("./modules/
|
|
22
|
-
__exportStar(require("./modules/search"), exports);
|
|
23
|
+
__exportStar(require("./modules/geocode"), exports);
|
|
23
24
|
__exportStar(require("./modules/multi_source_route_summary"), exports);
|
|
25
|
+
__exportStar(require("./modules/multi_stop_points"), exports);
|
|
24
26
|
__exportStar(require("./modules/pairwise_route_summary"), exports);
|
|
25
|
-
__exportStar(require("./
|
|
27
|
+
__exportStar(require("./modules/reverse"), exports);
|
|
28
|
+
__exportStar(require("./modules/search"), exports);
|
|
29
|
+
__exportStar(require("./modules/search_by_radius"), exports);
|
|
30
|
+
__exportStar(require("./modules/search_bbox"), exports);
|
|
26
31
|
var client_1 = require("./client");
|
|
27
32
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
package/dist/main.js
CHANGED
|
@@ -4,6 +4,7 @@ const index_1 = require("./index");
|
|
|
4
4
|
(async function () {
|
|
5
5
|
try {
|
|
6
6
|
const cl = new index_1.Client("", "");
|
|
7
|
+
// ✅ DistanceMatrixRequest Example
|
|
7
8
|
const res = await cl.distanceMatrix({
|
|
8
9
|
OriginLat: 23.8103,
|
|
9
10
|
OriginLon: 90.4125,
|
|
@@ -12,6 +13,7 @@ const index_1 = require("./index");
|
|
|
12
13
|
Mode: index_1.Mode.Walking,
|
|
13
14
|
});
|
|
14
15
|
console.log("============================> DistanceMatrix:", res);
|
|
16
|
+
// ✅ DistanceMatrixDetailsRequest Example
|
|
15
17
|
const deRes = await cl.distanceMatrixDetails({
|
|
16
18
|
OriginLat: 23.8103,
|
|
17
19
|
OriginLon: 90.4125,
|
|
@@ -20,13 +22,15 @@ const index_1 = require("./index");
|
|
|
20
22
|
Mode: index_1.Mode.Walking,
|
|
21
23
|
});
|
|
22
24
|
console.log("============================> DistanceMatrixDetails:", deRes);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// ✅ SearchRequest Example
|
|
26
|
+
const searchRes = await cl.search({ Query: "mirpur 10", ActiveLocations: true, Limit: 1 });
|
|
27
|
+
console.log("============================> Search:", JSON.stringify(searchRes, null, 2));
|
|
28
|
+
// ✅ ReverseRequest Example
|
|
25
29
|
const revRes = await cl.reverse({
|
|
26
|
-
Lat: 23.
|
|
27
|
-
Lon: 90.
|
|
30
|
+
Lat: 23.795295,
|
|
31
|
+
Lon: 90.416803,
|
|
28
32
|
});
|
|
29
|
-
console.log("============================> Reverse Geocode:", revRes);
|
|
33
|
+
console.log("============================> Reverse Geocode:", JSON.stringify(revRes, null, 2));
|
|
30
34
|
// ✅ PairwiseRouteSummaryRequest Example
|
|
31
35
|
const pairwiseRes = await cl.pairwiseRouteSummary({
|
|
32
36
|
pairs: [
|
|
@@ -109,6 +113,33 @@ const index_1 = require("./index");
|
|
|
109
113
|
},
|
|
110
114
|
});
|
|
111
115
|
console.log("============================> MultiSourceRouteSummary:", multiSourceRes);
|
|
116
|
+
// ✅ MultiStopPointRequest Example
|
|
117
|
+
const multiStopRes = await cl.multiStopPoint({
|
|
118
|
+
Src: { lat: 23.8103, lon: 90.4125 },
|
|
119
|
+
StopPoints: [
|
|
120
|
+
{ id: 1, lat: 23.8113, lon: 90.4135 },
|
|
121
|
+
{ id: 2, lat: 23.8123, lon: 90.4145 },
|
|
122
|
+
{ id: 3, lat: 23.8133, lon: 90.4155 },
|
|
123
|
+
],
|
|
124
|
+
Mode: index_1.Mode.Car,
|
|
125
|
+
});
|
|
126
|
+
console.log("============================> MultiStopPoint:", JSON.stringify(multiStopRes, null, 2));
|
|
127
|
+
// ✅ Details By PlaceId Example
|
|
128
|
+
const detailsRes = await cl.details({ PlaceId: "" });
|
|
129
|
+
console.log("============================> Details by Place ID:", detailsRes);
|
|
130
|
+
// ✅ AutocompleteRequest Example
|
|
131
|
+
const autoCompleteRes = await cl.autocomplete({ Query: "Gulshan Road", limit: 1 });
|
|
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
|
+
// ✅ SearchBboxRequest Example
|
|
138
|
+
const searchBboxRes = await cl.searchWithBbox({ Query: "uttara", TopLeftLat: 23.799012278864893, TopLeftLon: 90.43487817491183, BottomRightLat: 23.798243503885544, BottomRightLon: 90.43537003653393 });
|
|
139
|
+
console.log("============================> Search With Boundary box:", searchBboxRes);
|
|
140
|
+
// ✅ SearchByRadiusRequest Example
|
|
141
|
+
const searchByRadiusRes = await cl.searchByRadius({ Query: "uttara", Lat: 23.7272064, Lon: 90.3861125, Radius: 5000, Limit: 1 });
|
|
142
|
+
console.log("============================> Search By Radius:", JSON.stringify(searchByRadiusRes, null, 2));
|
|
112
143
|
}
|
|
113
144
|
catch (err) {
|
|
114
145
|
console.error("🔥 Error:", err);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface AutocompleteRequest {
|
|
2
|
+
Query: string;
|
|
3
|
+
Lat?: number;
|
|
4
|
+
Lon?: number;
|
|
5
|
+
Limit?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface AutocompleteResponse {
|
|
8
|
+
data: AutocompleteData[];
|
|
9
|
+
message: string;
|
|
10
|
+
status: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface AutocompleteData {
|
|
13
|
+
place_id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
address: string;
|
|
16
|
+
types: string[];
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface DetailsRequest {
|
|
2
|
+
PlaceId: string;
|
|
3
|
+
}
|
|
4
|
+
export interface PlaceDetail {
|
|
5
|
+
placeId: string;
|
|
6
|
+
lat: number;
|
|
7
|
+
lon: number;
|
|
8
|
+
types: string[];
|
|
9
|
+
address: string;
|
|
10
|
+
name: string;
|
|
11
|
+
houseNumber: string;
|
|
12
|
+
houseName: string;
|
|
13
|
+
street: string;
|
|
14
|
+
phone: string;
|
|
15
|
+
website: string;
|
|
16
|
+
country: string;
|
|
17
|
+
city: string;
|
|
18
|
+
thana: string;
|
|
19
|
+
division: string;
|
|
20
|
+
district: string;
|
|
21
|
+
postalCode: string;
|
|
22
|
+
plusCode: string;
|
|
23
|
+
sublocality: string;
|
|
24
|
+
localArea: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DetailsResponse {
|
|
27
|
+
data: PlaceDetail;
|
|
28
|
+
message: string;
|
|
29
|
+
status: boolean;
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface GeocodeRequest {
|
|
2
|
+
Query: string;
|
|
3
|
+
Limit?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface PlaceItem {
|
|
6
|
+
place_id: number;
|
|
7
|
+
lat: string;
|
|
8
|
+
lon: string;
|
|
9
|
+
category: string;
|
|
10
|
+
type: string;
|
|
11
|
+
place_rank: number;
|
|
12
|
+
importance: number;
|
|
13
|
+
addresstype: string;
|
|
14
|
+
name: string;
|
|
15
|
+
display_name: string;
|
|
16
|
+
}
|
|
17
|
+
export interface GeocodeResponse {
|
|
18
|
+
data: PlaceItem[];
|
|
19
|
+
message: string;
|
|
20
|
+
status: boolean;
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Mode } from "./distance_matrix";
|
|
2
|
+
import { Coordinate, RouteSummary } from "./pairwise_route_summary";
|
|
3
|
+
export interface MultiStopPointsRequest {
|
|
4
|
+
Src: Coordinate;
|
|
5
|
+
StopPoints: StopPoint[];
|
|
6
|
+
Mode: Mode;
|
|
7
|
+
}
|
|
8
|
+
export interface StopPoint extends Coordinate {
|
|
9
|
+
id: number;
|
|
10
|
+
}
|
|
11
|
+
export interface MultiStopPointsRouteSummary extends RouteSummary {
|
|
12
|
+
source: Coordinate;
|
|
13
|
+
stopPoint: Coordinate;
|
|
14
|
+
}
|
|
15
|
+
export interface MultiStopPointsRouteData {
|
|
16
|
+
distanceInMeters: number;
|
|
17
|
+
etaInSeconds: number;
|
|
18
|
+
routeSummaries: MultiStopPointsRouteSummary[];
|
|
19
|
+
}
|
|
20
|
+
export interface MultiStopPointsResponse {
|
|
21
|
+
data: MultiStopPointsRouteData;
|
|
22
|
+
message: string;
|
|
23
|
+
status: boolean;
|
|
24
|
+
}
|
|
@@ -8,29 +8,24 @@ export interface ReverseResponse {
|
|
|
8
8
|
status: boolean;
|
|
9
9
|
}
|
|
10
10
|
export interface ReverseData {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
addresstype: string;
|
|
15
|
-
lon: string;
|
|
16
|
-
lat: string;
|
|
11
|
+
placeId: string;
|
|
12
|
+
lat: number;
|
|
13
|
+
lon: number;
|
|
17
14
|
category: string;
|
|
18
15
|
type: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
address:
|
|
22
|
-
}
|
|
23
|
-
export interface Address {
|
|
16
|
+
class: string;
|
|
17
|
+
name: string;
|
|
18
|
+
address: string;
|
|
24
19
|
country: string;
|
|
25
|
-
countryCode: string;
|
|
26
20
|
city: string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
thana: string;
|
|
22
|
+
district: string;
|
|
23
|
+
division: string;
|
|
24
|
+
postalCode: string;
|
|
25
|
+
website: string;
|
|
26
|
+
houseNumber: string;
|
|
27
|
+
houseName: string;
|
|
28
|
+
subLocality: string;
|
|
29
|
+
localArea: string;
|
|
30
|
+
types: string[];
|
|
36
31
|
}
|
package/dist/modules/search.d.ts
CHANGED
|
@@ -1,16 +1,44 @@
|
|
|
1
1
|
export interface SearchRequest {
|
|
2
2
|
Query: string;
|
|
3
|
+
Lat?: number;
|
|
4
|
+
Lon?: number;
|
|
5
|
+
Radius?: number;
|
|
6
|
+
ActiveLocations?: boolean;
|
|
7
|
+
Page?: number;
|
|
8
|
+
Limit?: number;
|
|
9
|
+
AcceptLanguage?: string;
|
|
3
10
|
}
|
|
4
11
|
export interface SearchResponse {
|
|
5
|
-
data: SearchData
|
|
12
|
+
data: SearchData;
|
|
6
13
|
message: string;
|
|
7
14
|
status: boolean;
|
|
8
15
|
}
|
|
9
16
|
export interface SearchData {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
items: SearchItem[];
|
|
18
|
+
itemsPerPage: number;
|
|
19
|
+
pageNumber: number;
|
|
20
|
+
totalItems: number;
|
|
21
|
+
totalPages: number;
|
|
22
|
+
}
|
|
23
|
+
export interface SearchItem {
|
|
24
|
+
placeId: string;
|
|
25
|
+
lat: number;
|
|
26
|
+
lon: number;
|
|
27
|
+
types: string[];
|
|
28
|
+
address: string;
|
|
29
|
+
name: string;
|
|
30
|
+
houseNumber: string;
|
|
31
|
+
houseName: string;
|
|
32
|
+
street: string;
|
|
33
|
+
phone: string;
|
|
34
|
+
website: string;
|
|
35
|
+
country: string;
|
|
36
|
+
city: string;
|
|
37
|
+
thana: string;
|
|
38
|
+
division: string;
|
|
39
|
+
district: string;
|
|
40
|
+
postalCode: string;
|
|
41
|
+
plusCode: string;
|
|
42
|
+
sublocality: string;
|
|
43
|
+
localArea: string;
|
|
16
44
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { SearchData } from "./search";
|
|
2
|
+
export interface SearchByRadiusRequest {
|
|
3
|
+
Query: string;
|
|
4
|
+
Lat: number;
|
|
5
|
+
Lon: number;
|
|
6
|
+
Radius: number;
|
|
7
|
+
AcceptLanguage?: string;
|
|
8
|
+
Page?: number;
|
|
9
|
+
Limit?: number;
|
|
10
|
+
ActiveLocations?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface SearchByRadiusResponse {
|
|
13
|
+
data: SearchData;
|
|
14
|
+
message: string;
|
|
15
|
+
status: boolean;
|
|
16
|
+
}
|
package/dist/request.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare class Client {
|
|
2
2
|
private apiKey;
|
|
3
3
|
private packageName;
|
|
4
|
-
|
|
4
|
+
private timeOutMs?;
|
|
5
|
+
constructor(apiKey: string, packageName: string, timeOutMs?: number | undefined);
|
|
5
6
|
request(label: string, request: object): Promise<Uint8Array>;
|
|
6
7
|
}
|
package/dist/request.js
CHANGED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Client = void 0;
|
|
4
4
|
const secure_req_1 = require("./secure_req");
|
|
5
5
|
class Client {
|
|
6
|
-
constructor(apiKey, packageName) {
|
|
6
|
+
constructor(apiKey, packageName, timeOutMs) {
|
|
7
7
|
this.apiKey = apiKey;
|
|
8
8
|
this.packageName = packageName;
|
|
9
|
+
this.timeOutMs = timeOutMs;
|
|
9
10
|
}
|
|
10
11
|
async request(label, request) {
|
|
11
|
-
const { statusCode, response, errorMessage } = await (0, secure_req_1.callSecureRequest)(label, this.apiKey, this.packageName, request);
|
|
12
|
+
const { statusCode, response, errorMessage } = await (0, secure_req_1.callSecureRequest)(label, this.apiKey, this.packageName, request, this.timeOutMs);
|
|
12
13
|
if (errorMessage) {
|
|
13
14
|
throw new Error(`[${label}] native error: ${errorMessage}`);
|
|
14
15
|
}
|
package/dist/secure_req.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function callSecureRequest(label: string, apiKey: string, origin: string, request: object): Promise<{
|
|
1
|
+
export declare function callSecureRequest(label: string, apiKey: string, origin: string, request: object, timeOutMs?: number): Promise<{
|
|
2
2
|
statusCode: number;
|
|
3
3
|
response: string;
|
|
4
4
|
errorMessage?: string;
|
package/dist/secure_req.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.callSecureRequest = callSecureRequest;
|
|
4
4
|
const secure_request_1 = require("./secure_request");
|
|
5
|
-
async function callSecureRequest(label, apiKey, origin, request) {
|
|
5
|
+
async function callSecureRequest(label, apiKey, origin, request, timeOutMs) {
|
|
6
6
|
try {
|
|
7
7
|
const jsonRequest = JSON.stringify(request);
|
|
8
|
-
const result = await (0, secure_request_1.performSecureRequest)(label, apiKey, origin, jsonRequest);
|
|
8
|
+
const result = await (0, secure_request_1.performSecureRequest)(label, apiKey, origin, jsonRequest, timeOutMs);
|
|
9
9
|
if (!result.success) {
|
|
10
10
|
return {
|
|
11
11
|
statusCode: result.statusCode,
|
package/dist/secure_request.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export interface SecureResult {
|
|
|
4
4
|
response: string;
|
|
5
5
|
errorMessage?: string;
|
|
6
6
|
}
|
|
7
|
-
export declare function performSecureRequest(label: string, apiKey: string, origin: string, jsonRequest: string): Promise<SecureResult>;
|
|
7
|
+
export declare function performSecureRequest(label: string, apiKey: string, origin: string, jsonRequest: string, timeOutMs?: number): Promise<SecureResult>;
|
package/dist/secure_request.js
CHANGED
|
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.performSecureRequest = performSecureRequest;
|
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const generate_token_1 = require("./generate_token");
|
|
9
8
|
const build_url_1 = require("./build_url");
|
|
9
|
+
const generate_token_1 = require("./generate_token");
|
|
10
10
|
const BASE_URL = 'https://engine.mapnests.com';
|
|
11
11
|
const HTTP_METHOD_MAP = {
|
|
12
12
|
reverse: 'GET',
|
|
@@ -15,8 +15,14 @@ const HTTP_METHOD_MAP = {
|
|
|
15
15
|
distanceMatrixDetails: 'GET',
|
|
16
16
|
pairwiseRouteSummary: 'POST',
|
|
17
17
|
multiSourceSummary: 'POST',
|
|
18
|
+
multiStopPoints: 'POST',
|
|
19
|
+
geocode: 'GET',
|
|
20
|
+
detailsByPlaceId: 'GET',
|
|
21
|
+
autocomplete: 'GET',
|
|
22
|
+
autocompleteWithoutZone: 'GET',
|
|
23
|
+
searchByRadius: 'GET',
|
|
18
24
|
};
|
|
19
|
-
async function performSecureRequest(label, apiKey, origin, jsonRequest) {
|
|
25
|
+
async function performSecureRequest(label, apiKey, origin, jsonRequest, timeOutMs) {
|
|
20
26
|
let urlStr;
|
|
21
27
|
try {
|
|
22
28
|
urlStr = (0, build_url_1.buildURLFromJSON)(label, BASE_URL, jsonRequest);
|
|
@@ -34,7 +40,7 @@ async function performSecureRequest(label, apiKey, origin, jsonRequest) {
|
|
|
34
40
|
};
|
|
35
41
|
const axiosConfig = {
|
|
36
42
|
headers,
|
|
37
|
-
timeout: 30000,
|
|
43
|
+
timeout: timeOutMs || 30000,
|
|
38
44
|
};
|
|
39
45
|
try {
|
|
40
46
|
const response = method === 'POST'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateQueryLength: (query: string) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateQueryLength = void 0;
|
|
4
|
+
const validateQueryLength = (query) => {
|
|
5
|
+
if (query.length < 3) {
|
|
6
|
+
throw new Error(`Please provide a query parameter with more than 2 characters.`);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
exports.validateQueryLength = validateQueryLength;
|
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, Geocode, Reverse Geocode)",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.8",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
@@ -46,4 +46,4 @@
|
|
|
46
46
|
"type": "git",
|
|
47
47
|
"url": "git@vcs.technonext.com:mapnests/map-libraries/tn-map-js-library.git"
|
|
48
48
|
}
|
|
49
|
-
}
|
|
49
|
+
}
|