This project is a modern web application built with React, TypeScript, and Vite. It visualizes and interacts with hexagonal grids on a map using the H3 geospatial indexing system and Leaflet for mapping. The application is styled with Tailwind CSS and leverages a modular, maintainable code structure.
- Interactive Map: Displays a map using Leaflet, allowing users to interact with hexagonal cells.
- Hexagonal Grid Overlay: Dynamically overlays H3 hexagons on the map, updating with zoom and pan.
- Cell Selection: Users can select hex cells; selection logic supports adjacency and parent/child relationships.
- Responsive UI: Uses Tailwind CSS for a modern, responsive design.
- Type Safety: Built with TypeScript for robust type checking.
- Fast Development: Powered by Vite for instant hot module reloads and fast builds.
logbytes-assesment/
├── public/ # Static assets
├── src/ # Source code
│ ├── App.tsx # Main app component
│ ├── App.css # App-level styles
│ ├── HexGrid.tsx # Hex grid overlay logic
│ ├── Map.tsx # Map container and logic
│ ├── main.tsx # App entry point
│ ├── index.css # Global styles (Tailwind)
│ └── assets/ # Static assets (e.g., logos)
├── index.html # HTML entry point
├── package.json # Project metadata and scripts
├── vite.config.ts # Vite configuration
├── tsconfig*.json # TypeScript configuration
└── ...
- Entry point. Mounts the React app to the DOM.
- Root component. Renders the
Mapcomponent.
- Sets up the Leaflet map and manages selected hex cells.
- Passes selection state and toggle logic to
HexGrid. - Uses
getH3Resolutionto map zoom levels to H3 resolutions.
- Computes visible H3 cells for the current map viewport and zoom.
- Handles selection logic:
- Selecting/deselecting cells
- Highlighting adjacent and parent/child cells
- Renders hexagons as Leaflet polygons with interactive styles.
- Map Initialization: The app loads a Leaflet map centered at a default location.
- Hex Grid Overlay: As the user pans/zooms,
HexGridrecalculates which H3 cells are visible and overlays them. - Selection Logic: Clicking a hex toggles its selection. Adjacency and parent/child relationships are visually indicated.
- Styling: Tailwind CSS and custom styles provide a clean, modern look.
pnpm dev— Start development serverpnpm build— Build for productionpnpm preview— Preview production buildpnpm lint— Run ESLint
- React & ReactDOM — UI framework
- Leaflet & react-leaflet — Map rendering
- h3-js — Hexagonal grid geospatial indexing
- Tailwind CSS — Utility-first CSS framework
- Vite — Build tool
- TypeScript — Type safety
- Install dependencies:
pnpm install - Start dev server:
pnpm dev - Open http://localhost:5173 in your browser
- Map Center/Zoom: Change defaults in
src/Map.tsx. - Grid Logic: Adjust H3 resolution mapping in
getH3Resolution. - Styling: Edit
src/App.cssorsrc/index.css.