Public Transit
This example demonstrates how to calculate public transit routes, display route segments with transit types, and handle alternative route selection.
Overview
The example demonstrates the following features:
- Calculating routes using public transportation mode
- Converting routes to public transit routes (PTRoute)
- Extracting and displaying route segments with transit information
- Showing route details including departure/arrival times and walking distances
- Handling alternative routes with tap selection
- Displaying wheelchair accessibility information
Code Implementation
Importing SDK Components
Calculating Public Transit Routes
Converting Routes to Public Transit Format
Handling Route Selection
Canceling Route Calculation
Live Demo
Key Features
- Public Transport Routing: Calculate routes optimized for public transportation including buses, trains, and walking segments
- PTRoute Conversion: Convert standard routes to public transit format for detailed segment information
- Route Segments: Access individual transit segments with type, duration, and accessibility details
- Time Information: Retrieve departure and arrival times for transit segments
- Alternative Routes: Display and select from multiple route options
- Wheelchair Support: Check wheelchair accessibility for each transit segment
Explanation of Key Components
- RouteTransportMode.public: Route calculation mode optimized for public transportation networks
- PTRoute: Public transit route representation containing detailed segment information
- PTRouteSegment: Individual segment of a public transit route with transit type, times, and accessibility
- toPTRoute(): Method to convert a standard Route object to PTRoute format
- TransitType: Enumeration of transit types (walk, bus, train, etc.)
- departureTime/arrivalTime: Timestamp properties indicating when transit segments begin and end
- hasWheelchairSupport: Boolean property indicating wheelchair accessibility for transit segments
- publicTransportFare: Property containing fare information for the route
- registerTouchCallback(): Register callback for map touch events to enable route selection
Next Steps
- Calculate Route - Learn basic route calculation features
- Route Instructions - Display turn-by-turn navigation instructions
- Navigate Route - Explore route navigation capabilities