Skip to content

add 'avoid' option #211

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ declare module "react-native-maps-directions" {
* Array of waypoints to use between origin and destination.
*/
waypoints?: MapViewDirectionsWaypoints[];
/**
* Avoid type of ways
*/
avoid: string;
/**
* The destination location to start routing to.
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-maps-directions",
"version": "1.9.0",
"version": "1.9.1",
"description": "Directions Component for react-native-maps",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/MapViewDirections.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class MapViewDirections extends Component {
mode = 'DRIVING',
language = 'en',
optimizeWaypoints,
avoid,
splitWaypoints,
directionsServiceBaseUrl = 'https://maps.googleapis.com/maps/api/directions/json',
region,
Expand Down Expand Up @@ -174,7 +175,7 @@ class MapViewDirections extends Component {
}

return (
this.fetchRoute(directionsServiceBaseUrl, origin, waypoints, destination, apikey, mode, language, region, precision, timePrecisionString, channel)
this.fetchRoute(directionsServiceBaseUrl, origin, waypoints, avoid, destination, apikey, mode, language, region, precision, timePrecisionString, channel)
.then(result => {
return result;
})
Expand Down Expand Up @@ -227,12 +228,12 @@ class MapViewDirections extends Component {
});
}

fetchRoute(directionsServiceBaseUrl, origin, waypoints, destination, apikey, mode, language, region, precision, timePrecision, channel) {
fetchRoute(directionsServiceBaseUrl, origin, waypoints, avoid, destination, apikey, mode, language, region, precision, timePrecision, channel) {

// Define the URL to call. Only add default parameters to the URL if it's a string.
let url = directionsServiceBaseUrl;
if (typeof (directionsServiceBaseUrl) === 'string') {
url += `?origin=${origin}&waypoints=${waypoints}&destination=${destination}&key=${apikey}&mode=${mode.toLowerCase()}&language=${language}&region=${region}`;
url += `?origin=${origin}&waypoints=${waypoints}&destination=${destination}&key=${apikey}&mode=${mode.toLowerCase()}&language=${language}&region=${region}&avoid=${avoid}`;
if(timePrecision){
url+=`&departure_time=${timePrecision}`;
}
Expand Down