Interface Layer

com.yandex.mapkit.layers

public interface Layer

Interface for working with the layer.

Methods

void activate(boolean on)

Shows or hides the layer on the map.

void clear()

Clears all cached tiles and starts new requests for tiles that are displayed.

void invalidate(@NonNull String version)

Invalidates the layer and reloads all tiles that have been modified in the new map version.

boolean isValid()

Tells if this Layer is valid or no.

void remove()

Removes the layer from the map.

void resetStyles()

Resets all JSON style transformations applied to the layer.

void setLayerLoadedListener(@Nullable LayerLoadedListener layerLoadedListener)

Sets layer loaded listener.

boolean setStyle(int id, @NonNull String style)

Applies JSON style transformation to the layer.

Method Detail

activate

public void activate (boolean on)

Shows or hides the layer on the map.

clear

public void clear ()

Clears all cached tiles and starts new requests for tiles that are displayed.

invalidate

public void invalidate (@NonNull String version)

Invalidates the layer and reloads all tiles that have been modified in the new map version.

To update a layer that does not have a version, leave this parameter empty. Can be called on any thread.

isValid

public boolean isValid ()

Tells if this Layer is valid or no.

Any other method (except for this one) called on an invalid Layer 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.

remove

public void remove ()

Removes the layer from the map.

resetStyles

public void resetStyles ()

Resets all JSON style transformations applied to the layer.

setLayerLoadedListener

public void setLayerLoadedListener (@Nullable LayerLoadedListener layerLoadedListener)

Sets layer loaded listener.

Remark:
Parameters:
layerLoadedListener

has optional type, it may be uninitialized.

setStyle

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

Applies JSON style transformation to the 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 and false otherwise. If the returned value is false, the current style remains unchanged.