Range Finder
This example demonstrates how to calculate and display reachable areas (range) from a selected landmark based on time or distance constraints using the Maps SDK for TypeScript.
Live Demo
Overview
The example demonstrates the following features:
- Selecting landmarks on the map by tapping
- Configuring range parameters (time-based ranges)
- Setting transport modes and route preferences
- Calculating and visualizing reachable areas
- Displaying range boundaries on the map
Code Implementation
Initialize GemKit and Setup
Register Landmark Selection Callback
Create Range Configuration Panel
Calculate and Display Range
Range Data Structure
Utility Functions
Key Features
- Interactive Landmark Selection: Tap on the map to select a starting point for range calculation
- Configurable Range Values: Adjust time-based ranges from 1 minute to 3 hours
- Multiple Transport Modes: Support for car, lorry, pedestrian, bicycle, public transit, and shared vehicles
- Route Preferences: Avoid motorways, toll roads, ferries, and unpaved roads
- Visual Representation: Display reachable areas as colored route boundaries on the map
- Multiple Ranges: Calculate and display multiple ranges from the same landmark
Range Calculation
Ranges are calculated using the routeRanges property in RoutePreferences:
const routePreferences = new RoutePreferences({
transportMode: 0, // Car
routeRanges: [3600], // 1 hour range in seconds
});
The SDK calculates all roads/paths reachable within the specified time from the selected landmark, considering:
- Selected transport mode capabilities
- Road restrictions and preferences
- Traffic conditions (if enabled)
- Route avoidance settings
Transport Modes
Available transport modes for range calculation:
- Car (0): Standard vehicle routing
- Lorry (1): Heavy vehicle with restrictions
- Pedestrian (2): Walking paths and sidewalks
- Bicycle (3): Bike paths and bike-friendly roads
- Public Transit (4): Bus, train, and transit routes
- Shared Vehicles (5): Car-sharing and ride-sharing routes
Route Preferences
Customize range calculation with various avoidance options:
- Avoid Motorways: Exclude highways from the range
- Avoid Toll Roads: Skip toll roads in calculations
- Avoid Ferries: Don't include ferry routes
- Avoid Unpaved Roads: Stick to paved surfaces only
Use Cases
Range finder is useful for:
- Delivery Planning: Determine delivery coverage areas
- Service Areas: Define service zones based on travel time
- Real Estate: Show areas within commute time of a location
- Emergency Services: Calculate response time coverage
- Electric Vehicles: Show reachable areas on current charge
- Tourism: Find attractions within a certain travel time
Workflow
- Select Landmark: Tap on the map to choose a starting point
- Configure Range: Adjust the time range slider (1 min to 3 hours)
- Set Transport Mode: Choose the appropriate transport type
- Set Preferences: Enable/disable route avoidance options
- Calculate: Click "Calculate Range" to compute the reachable area
- View Results: The range boundary is displayed on the map
- Multiple Ranges: Repeat to compare different scenarios
Next Steps
- Calculate Route - Basic route calculation
- Route Preferences - Learn about routing options