GPX Routing Thumbnail Image
This example demonstrates how to import a GPX file, calculate a route from the path data, and capture a thumbnail image of the route displayed on the map.
Overview
The example demonstrates the following features:
- Loading and processing GPX file data
- Creating a Path object from GPX data
- Calculating a route from path waypoints
- Rendering the route on the map with waypoints
- Capturing a screenshot of the displayed route
- Displaying the captured thumbnail image
Code Implementation
Importing SDK Components
Loading GPX Data and Creating Path
Calculating Route from Path
Rendering Route on Map
Live Demo
Key Features
- GPX File Processing: Load and parse GPX files using the
Path.create()method withPathFileFormat.gpx - Route Calculation: Convert path data to landmarks and calculate a pedestrian route using
RoutingService - Route Rendering: Display routes with customizable render settings including waypoints visualization
- Map Centering: Automatically center the map on the route's geographic area with specified zoom level
- Screenshot Capture: Capture map snapshots using
map.captureImage()for thumbnail generation
Explanation of Key Components
- Path.create(): Creates a Path object from GPX file data, extracting waypoints and route information
- path.toLandmarkList(): Converts path waypoints into a list of landmarks for route calculation
- RoutingService.calculateRoute(): Computes an optimal route between waypoints with specified preferences
- RouteRenderSettings: Configures how routes are displayed on the map, including main route line and waypoint markers
- map.centerOnArea(): Centers the map viewport on a geographic area with optional zoom level
- map.captureImage(): Captures the current map view as a PNG image buffer for thumbnail creation
Next Steps
- GPX Route - Learn how to display GPX routes on the map
- Calculate Route - Explore basic route calculation features
- Route Instructions - Display turn-by-turn navigation instructions