VigneshDevHub / CampX

"CampX: Discover and share the best campgrounds across Globe, where adventure meets community."
https://campx-f9sv.onrender.com
MIT License
10 stars 13 forks source link

[FEATURE] Provide an option to sort campgrounds based on current location of the user #18 #36

Open memyselfandglitch opened 18 hours ago

memyselfandglitch commented 18 hours ago

šŸ“‹ Description

When the user logs in and views all the campgrounds he will have a button in the /campgrounds route (which has all the campgrounds) to sort all of them from his current location. This will be handy as he/she won't have to look through the map to find the closest campgrounds.

šŸ”Ø Changes Made

Fixes #18

Created a route called /nearest that will be called along with query params of latitude and longitude on clicking the button using the geolocation API. Subsequent function called showNearestCampgrounds is in the controller directory of campgrounds that sorts the campgrounds based on latitudes and longitudes using turf package.

āœ… Checklist

Before submitting the PR, please make sure you have completed the following:

šŸ·ļø Types of Changes

What type of changes does your code introduce? (Check all that apply)

šŸ¤ Related Issues

šŸ“ø Screenshots (if applicable)

Screenshot 2024-10-01 at 00 39 59 Screenshot 2024-10-01 at 00 40 29 Screenshot 2024-10-01 at 00 40 40

Reminder:

Please ensure your pull request is made to the test branch, not main.

Thank you for contributing to VigneshDevHub! We look forward to reviewing your PR and getting it merged!