This project demonstrates the use of the Leaflet library with React to display moving markers (trucks) on a map with routes. Routes can either be randomly generated.
-
Clone the repository:
git clone https://github.com/JohnImril/leaflet-route.git cd leaflet-route
-
Install dependencies:
npm install
- Start the project:
npm start
public/
- contains static filessrc/
components/
ForestryMap.tsx
- main map componentMovingIcon.tsx
- component for displaying a moving marker
images/
- contains images, such as truck iconstypes/
- contains TypeScript typesutils.ts
- utilities for generating routesApp.tsx
- main application componentindex.tsx
- application entry point
The generateRoutes
function generates routes radiating out from a starting point. Each route has random changes in direction and speed to create realistic movement.
The MapComponent
displays the map with markers and routes. Markers move along the routes, and hovering over a route line changes its opacity.
This project is licensed under the terms of the MIT License.