Interface TrafficLayer

com.yandex.mapkit.traffic

public interface TrafficLayer

A layer with traffic information.

Methods

void addTrafficListener(@NonNull TrafficListener trafficListener)

Adds a traffic listener.

boolean isRoadEventVisible(@NonNull EventType type)
boolean isTrafficVisible()

Checks if traffic is visible.

boolean isValid()

Tells if this TrafficLayer is valid or no.

void removeTrafficListener(@NonNull TrafficListener trafficListener)

Removes a traffic listener.

void setRoadEventVisible(@NonNull EventType type, boolean on)
boolean setTrafficStyle(@NonNull String style)

Applies JSON style transformations to the traffic layer.

void setTrafficVisible(boolean on)

Sets traffic visibility.

Method Detail

addTrafficListener

public void addTrafficListener (@NonNull TrafficListener trafficListener)

Adds a traffic listener.

isRoadEventVisible

public boolean isRoadEventVisible (@NonNull EventType type)

Attention.

This feature is not available in the free MapKit version.

Checks if road events are visible.

isTrafficVisible

public boolean isTrafficVisible ()

Checks if traffic is visible.

isValid

public boolean isValid ()

Tells if this TrafficLayer is valid or no.

Any other method (except for this one) called on an invalid TrafficLayer will throw java.lang.RuntimeException. An instance becomes invalid only on UI thread, and only when its implementation depends on objects already destroyed by now. Please refer to general docs about the interface for details on its invalidation.

removeTrafficListener

public void removeTrafficListener (@NonNull TrafficListener trafficListener)

Removes a traffic listener.

setRoadEventVisible

public void setRoadEventVisible (@NonNull EventType type, boolean on)

Attention.

This feature is not available in the free MapKit version.

Sets road events visibility.

setTrafficStyle

public boolean setTrafficStyle (@NonNull String style)

Applies JSON style transformations to the traffic layer.

Set to empty string to clear any previous custom styling. Returns true if the style was successfully parsed; false otherwise. If the return value is false, the current traffic style remains unchanged.

setTrafficVisible

public void setTrafficVisible (boolean on)

Sets traffic visibility.