Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add avoid option to routing #135

Merged
merged 4 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Radar.initialize('prj_test_pk_...', { /* options */ });

Add the following script in your `html` file
```html
<script src="https://js.radar.com/v4.1.11/radar.min.js"></script>
<script src="https://js.radar.com/v4.1.12/radar.min.js"></script>
```

Then initialize the Radar SDK
Expand All @@ -73,8 +73,8 @@ To create a map, first initialize the Radar SDK with your publishable key. Then
```html
<html>
<head>
<link href="https://js.radar.com/v4.1.11/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.1.11/radar.min.js"></script>
<link href="https://js.radar.com/v4.1.12/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.1.12/radar.min.js"></script>
</head>

<body>
Expand All @@ -98,8 +98,8 @@ To create an autocomplete input, first initialize the Radar SDK with your publis
```html
<html>
<head>
<link href="https://js.radar.com/v4.1.11/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.1.11/radar.min.js"></script>
<link href="https://js.radar.com/v4.1.12/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.1.12/radar.min.js"></script>
</head>

<body>
Expand Down Expand Up @@ -130,8 +130,8 @@ To power [geofencing](https://radar.com/documentation/geofencing/overview) exper
```html
<html>
<head>
<link href="https://js.radar.com/v4.1.11/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.1.11/radar.min.js"></script>
<link href="https://js.radar.com/v4.1.12/radar.css" rel="stylesheet">
<script src="https://js.radar.com/v4.1.12/radar.min.js"></script>
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radar-sdk-js",
"version": "4.1.11",
"version": "4.1.12",
"description": "Web Javascript SDK for Radar, location infrastructure for mobile and web apps.",
"homepage": "https://radar.com",
"type": "module",
Expand Down
12 changes: 12 additions & 0 deletions src/api/routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RoutingAPI {
units,
geometry,
geometryPoints,
avoid,
} = params;

// use browser location if "near" not provided
Expand All @@ -40,6 +41,10 @@ class RoutingAPI {
modes = modes.join(',');
}

if (Array.isArray(avoid)) {
avoid = avoid.join(',');
}

const response: any = await Http.request({
method: 'GET',
path: 'route/distance',
Expand All @@ -50,6 +55,7 @@ class RoutingAPI {
units,
geometry,
geometryPoints,
avoid,
},
});

Expand All @@ -72,6 +78,7 @@ class RoutingAPI {
destinations,
mode,
units,
avoid,
} = params;

// use browser location if "near" not provided
Expand All @@ -91,6 +98,10 @@ class RoutingAPI {
destinations = destinations.map((location) => `${location.latitude},${location.longitude}`).join('|');
}

if (Array.isArray(avoid)) {
avoid = avoid.join(',');
}

const response: any = await Http.request({
method: 'GET',
path: 'route/matrix',
Expand All @@ -99,6 +110,7 @@ class RoutingAPI {
destinations,
mode,
units,
avoid,
},
});

Expand Down
7 changes: 7 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ export type RadarTravelMode =
| 'motorbike'
| 'truck';

export type RadarAvoidOption =
| 'tolls'
| 'highways'
| 'ferries';

export interface RadarTripOptions {
userId?: string;
externalId?: string;
Expand Down Expand Up @@ -367,6 +372,7 @@ export interface RadarDistanceParams {
units?: 'metric' | 'imperial';
geometry?: boolean;
geometryPoints?: boolean;
avoid?: RadarAvoidOption[] | string;
}


Expand Down Expand Up @@ -402,6 +408,7 @@ export interface RadarMatrixParams {
destinations: Location[] | string;
mode: RadarTravelMode;
units?: 'metric' | 'imperial';
avoid?: RadarAvoidOption[] | string;
}

export interface RadarMatrixRoute {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '4.1.11';
export default '4.1.12';
Loading