Repository navigation
v1.0.0 - Initial Release
We're excited to announce the first release of waypointjs, a framework-agnostic, map-agnostic TypeScript library for route planning.
Features
Core Functionality
- Waypoint Management - Add, remove, update, insert, and reorder waypoints with a simple API
- Route Calculation - Automatic route calculation when waypoints change
- Navigation Steps - Turn-by-turn instructions with maneuver types and distances
Architecture
- Map-agnostic - Works with any directions API (Google Maps, Mapbox, HERE, OpenRouteService, etc.)
- Framework-agnostic - Pure TypeScript with no React/Vue/Angular dependencies
- Zero runtime dependencies - Lightweight and conflict-free
- SOLID Architecture - Clean, testable, and extensible design
Dependency Injection
- Fully injectable components - Swap any component for testing or customization
- Default implementations - Ready to use out of the box
- Available interfaces:
IWaypointRepository- Waypoint CRUD operationsIHistoryManager- Undo/redo historyIRouteCalculator- Route calculationIGeoService- Geographic calculationsIEventBus- Event pub/sub
Event System
- Event-driven API - Subscribe to route changes, calculations, and errors
- Available events:
waypoint:added,waypoint:removed,waypoint:updated,waypoint:reorderedroute:calculating,route:calculated,route:error,route:clearedhistory:change,stats:updated
History Management
- Undo/Redo - Built-in history management with configurable depth
- Configurable - Set maximum history size via options
Geo Utilities
- Distance calculation - Haversine formula for accurate distance between coordinates
- Nearest point on route - Find the closest point on a route to any coordinate
- Off-route detection - Detect when a user has strayed from the route
- Remaining distance - Calculate distance remaining to destination
Configuration Options
maxHistorySize- Maximum undo/redo entries (default: 50)offRouteThreshold- Off-route detection threshold in meters (default: 50)autoRecalculate- Auto-recalculate route on waypoint changes (default: true)
Getting Started
npm install waypointjsimport { RoutePlanner } from 'waypointjs';
const planner = new RoutePlanner(yourDirectionsProvider);
planner.on('route:calculated', ({ route, stats }) => {
console.log(`Route: ${stats.distanceMeters}m`);
});
await planner.addWaypoint({ longitude: -122.4194, latitude: 37.7749 });
await planner.addWaypoint({ longitude: -122.4089, latitude: 37.7855 });Links
- Documentation: https://github.com/onamfc/waypointjs#readme
- Demo: https://waypointjs.com
- Issues: https://github.com/onamfc/waypointjs/issues