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 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 resetRoadEventsStyles()

Resets all JSON style transformations applied to the road events layer.

void resetTrafficStyles()

Resets all JSON style transformations applied to the traffic layer.

boolean setRoadEventsStyle(@NonNull String style)

Applies JSON style transformations to the road events layer.

boolean setRoadEventsStyle(int id, @NonNull String style)

Applies JSON style transformations to the road events layer.

boolean setTrafficStyle(@NonNull String style)

Applies JSON style transformations to the traffic layer.

boolean setTrafficStyle(int id, @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.

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.

resetRoadEventsStyles

public void resetRoadEventsStyles ()

Resets all JSON style transformations applied to the road events layer.

resetTrafficStyles

public void resetTrafficStyles ()

Resets all JSON style transformations applied to the traffic layer.

setRoadEventsStyle

public boolean setRoadEventsStyle (@NonNull String style)

Applies JSON style transformations to the road events layer.

Same as setRoadEventsStyle(0, style). Set to empty string to clear previous styling. Returns true if the style was successfully parsed; false otherwise. If the return value is false, the current road events style remains unchanged.

setRoadEventsStyle

public boolean setRoadEventsStyle (int id, @NonNull String style)

Applies JSON style transformations to the road events layer.

Replaces previous styling with the specified ID (if such exists). Stylings are applied in an ascending order. Set to empty string to clear previous styling with the specified ID. Returns true if the style was successfully parsed; false otherwise. If the return value is false, the current road events style remains unchanged.

setTrafficStyle

public boolean setTrafficStyle (@NonNull String style)

Applies JSON style transformations to the traffic layer.

Same as setTrafficStyle(0, style). Set to empty string to clear previous styling. Returns true if the style was successfully parsed; false otherwise. If the return value is false, the current traffic style remains unchanged.

setTrafficStyle

public boolean setTrafficStyle (int id, @NonNull String style)

Applies JSON style transformations to the traffic layer.

Replaces previous styling with the specified ID (if such exists). Stylings are applied in an ascending order. Set to empty string to clear previous styling with the specified ID. 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.