How perliedman/leaflet-routing-machine works
Leaflet Routing Machine is a Leaflet plugin for entering waypoints, requesting routes, and displaying route lines, alternatives, and turn-by-turn instructions. The main workflow runs from the map control through waypoint planning and a configurable routing backend, then presents the returned route on the map and in an itinerary. Geocoding and localization support waypoint entry and readable instructions. The excerpts show key component calls, but some routing and rendering details are incomplete; unverified links are omitted or marked dashed.
Main entry points: control.js Routing Control · geocoder-element.js Geocoder Element · index.js Plugin API · plan.js Waypoint Plan
Components 18
Control and Planning
- Routing Control
src/control.js - Waypoint Plan
src/plan.js - Plugin API
src/index.js
Waypoint Entry
- Geocoder Element
src/geocoder-element.js - Autocomplete
src/autocomplete.js
Routing Backends
- OSRM v5 Router
src/osrm-v1.js - Mapbox Router
src/mapbox.js
Route Presentation
- Route Line
src/line.js - Itinerary Control
src/itinerary.js - Instruction Formatter
src/formatter.js - Itinerary Builder
src/itinerary-builder.js - Error Control
src/error-control.js
Shared Models
- Waypoint
src/waypoint.js - Localization
src/localization.js
Other components
- Map User
- Configured Geocoder
- OSRM Service
- Mapbox Directions
Connections 18
- Map User → Routing Control: uses
README.md - Routing Control → Waypoint Plan: creates
src/control.js - Waypoint Plan → Waypoint: normalizes
src/plan.js - Waypoint Plan → Geocoder Element: creates
src/plan.js - Geocoder Element → Autocomplete: creates
src/geocoder-element.js - Geocoder Element → Localization: localizes fields
src/geocoder-element.js - Geocoder Element → Configured Geocoder: requests geocoding
- Routing Control → OSRM v5 Router: defaults to
src/control.js - OSRM v5 Router → OSRM Service: requests routes
README.md - Mapbox Router → Mapbox Directions: requests directions
README.md - Routing Control → Route Line: creates route lines
src/control.js - Routing Control → Itinerary Control: initializes
src/control.js - Itinerary Control → Instruction Formatter: formats instructions
src/itinerary.js - Itinerary Control → Itinerary Builder: builds rows
src/itinerary.js - Instruction Formatter → Localization: gets translations
src/formatter.js - Plugin API → Routing Control: exports
src/index.js - Plugin API → Mapbox Router: exports
src/index.js - Plugin API → Error Control: exports
src/index.js