A React application that helps users find nearby cafes on a map.
The app displays:
- User’s current location (via browser geolocation API).
- A list of cafes from
cafe.json. - A Leaflet map with markers for each cafe.
- A sidebar with cafe names — clicking a name pans/flies the map to the corresponding cafe marker.
- Geolocation support → shows your current location on the map.
- Cafe markers → loads cafes from a static
cafe.jsonfile. - Sidebar navigation → click a cafe from the list to fly to its marker.
- Clone the repository
git clone https://github.com/your-username/nearby-cafes.git cd nearby-cafes - Install dependencies
npm install
- Start the development server
npm run dev
- Start the development server
http://localhost:5173 (default Vite port)
src/
├── components/
│ ├── CafeMarkers.jsx # Map + sidebar + cafes
│ ├── FlyToCafe.jsx # Smooth fly-to logic
│ └── CafeList.jsx # List of cafes
├── cafes.json # Static cafe data
├── App.jsx
└── main.jsx
Currently, no formal test cases are implemented. You can test manually by:
-
Verifying geolocation works in your browser.
-
Clicking cafes in the sidebar → map should fly to the correct marker.
-
Clicking cafe markers → popups display cafe names.
-
Cafe data is stored locally in cafe.json. (Can be swapped with an API later.)
-
Geolocation requires browser permission. If denied, app defaults to India center.
-
Map library: React-Leaflet chosen for simplicity and strong ecosystem support.