Define Persistent Roadblock
This example demonstrates how to define a persistent roadblock on a road by tapping the map, and how to center the camera on it. Once the map is loaded, the user should zoom in and tap a road; the tapped section is blocked for one minute and marked with red roadblock polylines (on one or both sides of the road, depending on the road type). Tapping a different road section moves the roadblock there. The map is fully 3D and interactive, supporting pan, pinch-zoom, rotate and tilt.
Tracking the Current Roadblock
A single nullable field holds the roadblock currently placed by the user, so it can be removed before a new one is added.
Handling Map Taps
Once the default map view is created, an onTouch handler is installed. Each tap sets cursorScreenPosition so the map can be hit-tested at that point. If the tap lands on an existing roadblock (cursorSelectionTrafficEvents with isRoadblock), it is ignored; otherwise, if it lands on a street (cursorSelectionStreets), the first street's coordinates are used to place a new roadblock.
Adding the Roadblock
addPersistentRoadblock defines a roadblock that starts now and expires one minute later. If a previous roadblock exists, it is removed first via its reference point, then the new one is added with Traffic.addPersistentRoadblock for the car transport mode. When the resulting roadblock has a valid reference point, the camera is animated to its bounding box with centerOnRectArea - framed inside the free space left by the toolbar and system bars - and the on-screen hint is hidden.

