Road event layer

Road events are information about traffic situations. They include accidents, restrictions, road work, and speed cameras. You can find a complete list of available road events in the YMKRoadEventsEventTag enum.

The road event layer can display road events along the route as icons. To render road events, add a map layer where they'll be displayed.

In NaviKit SDK, the road event layer is the YMKRoadEventsLayer class.

Create

To create a road event layer, use the YMKMapKit.createRoadEventsLayer(with:styleProvider:) method.

YMKMapKit.sharedInstance().createRoadEventsLayer(
    with: mapWindow,
    styleProvider: styleProvider
)

The factory method takes the YMKMapWindow object, which you can get by calling YMKMapView.mapWindow, and YMKRoadEventsLayerStyleProvider interface implementation.

YMKRoadEventsLayerStyleProvider

To customize how road events are displayed, use the YMKRoadEventsLayerStyleProvider interface.

You can use a ready-made YMKRoadEventsLayerStyleProvider implementation that provides road event icon styles and resources in the signature style of API Maps. To learn how to enable the dependency, follow the link.

Road event display

Use YMKRoadEventsLayer.setRoadEventVisibleOnRouteWith(_:on:) to set event visibility on the route for the current route in guidance mode and in alternate overview mode.