Areas Alarms
This example demonstrates how to monitor geographic areas and receive notifications when entering or exiting defined zones during navigation simulation.
Overview
The example demonstrates the following features:
- Drawing circular geographic areas on the map using polygon markers
- Calculating routes and displaying them on the map
- Monitoring geographic areas with AlarmService
- Receiving boundary crossing notifications during navigation simulation
- Managing navigation lifecycle with start/stop controls
Code Implementation
Importing SDK Components
Drawing Geographic Areas
Calculating Routes
Monitoring Geographic Areas
Managing Navigation State
Live Demo
Key Features
- Geographic Area Visualization: Display circular areas on the map using polygon markers with custom colors
- Area Monitoring: Monitor when navigation crosses defined geographic boundaries
- Boundary Notifications: Receive callbacks when entering or exiting monitored areas
- Navigation Simulation: Simulate route navigation to test area alarm functionality
- State Management: Track navigation and routing states with TaskHandler references
Explanation of Key Components
- CircleGeographicArea: Defines a circular geographic zone with a center point and radius for monitoring
- AlarmService: Service for monitoring geographic areas and triggering notifications
- AlarmListener: Listener with
onBoundaryCrossedcallback that fires when boundaries are crossed - monitorArea(): Method to start monitoring a specific geographic area with an identifier
- MarkerCollection: Collection of polygon markers used to visualize the geographic area on the map
- generateCircleCoordinates(): Utility function that calculates polygon points to approximate a circle
- NavigationService.startSimulation(): Starts simulated navigation along a route for testing area alarms
- TaskHandler: Reference object used to cancel ongoing routing or navigation operations
Next Steps
- Route Alarms - Learn about proximity-based alarms on routes
- Navigate Route - Explore real-time route navigation
- Simulate Navigation - Understand navigation simulation basics