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 MMKRoadEventsEventTag 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 MMKRoadEventsLayer class.

Create

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

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

The factory method takes the MMKMapWindow object, which you can get by calling MMKMapView.mapWindow, and MMKRoadEventsLayerStyleProvider interface implementation.

MMKRoadEventsLayerStyleProvider

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

You can use a ready-made MMKRoadEventsLayerStyleProvider 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 MMKRoadEventsLayer.setRoadEventVisibleOnRouteWith(_:on:) to set event visibility on the route for the current route in guidance mode and in alternate overview mode.