Skip to content

Mapbox integration#145

Open
NicholasS13 wants to merge 6 commits into
FoodIsLifeBGP:prealpha/mainfrom
NicholasS13:prealpha/main
Open

Mapbox integration#145
NicholasS13 wants to merge 6 commits into
FoodIsLifeBGP:prealpha/mainfrom
NicholasS13:prealpha/main

Conversation

@NicholasS13

@NicholasS13 NicholasS13 commented Jul 30, 2020

Copy link
Copy Markdown

Please check if the PR fulfills these requirements

  • The changes don't come from your master branch. (Source)

[Trello Card]

https://trello.com/c/nujUoXWA/235-method-for-distance-calculation

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

added getDriveDistance function using mapbox

What is the current behavior? (You can also link to an open issue here)

N/A

What is the new behavior? (if this is a feature change)

N/A -needs to be added to map and list for client

Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

no

Other information

Usage :
//need to import function
import getDriveDist from ".src/state/actions/mapbox";

//need to create these variables for each usage case(setDistance2,distance2...) in order for this to work
const [distance, setDistance] = React.useState("undefined");

//this is the actual function that does the calculation, you need to pass in the setDistance value created above
//longitude1/latitude1 represent user location and longitude2/latitude2 represents location that they would travel to
getDriveDist = (latitude1:, longitude1, latitude2,longitude2,setDistance)

//then to display drive distance print {distance}
{distance}

Discussion Questions

If you need help integrating this- DM me

Images (before/ after screenshots, interaction GIFs, ...)

N/A


TODO

none

@duskcloudxu duskcloudxu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and also check lint first because there is lint checking on this repo and if it did not pass then your PR cannot be merged. It should be supported by modern IDEs like vscode or IntelliJ series.

Comment thread src/routes/mapbox.tsx Outdated
link
)
.then(response => {
setDistance(response.data.routes[0].distance/1609);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why 1609 here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is to convert the value given from meters to miles

Comment thread src/routes/mapbox.tsx Outdated
@@ -0,0 +1,13 @@
import axios from "axios";

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be more of a utility function and should be put under src/state/actions?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok-will change that and check lint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants