Interface Map

com.yandex.mapkit.map

public interface Map

The object that is used to interact with the map.

Nested Classes

Methods

void addCameraListener(@NonNull CameraListener cameraListener)

Adds camera listeners.

void addInertiaMoveListener(@NonNull InertiaMoveListener inertiaMoveListener)

Adds inertia move listeners.

void addInputListener(@NonNull InputListener inputListener)

Adds input listeners.

Layer addLayer(@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull TileProvider tileProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull Projection projection)

Adds a layer that displays tiles from the user-defined TileProvider.

Layer addLayer(@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull TileProvider tileProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull ResourceUrlProvider animatedImageUrlProvider, @NonNull Projection projection, @NonNull List< ZoomRange > zoomRanges)

Adds a layer that displays tiles from the user-defined TileProvider.

Layer addLayer(@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull UrlProvider tileUrlProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull Projection projection)

Adds a layer that uses the network to load tiles from URLs obtained through UrlProvider.

Layer addLayer(@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull UrlProvider tileUrlProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull ResourceUrlProvider modelUrlProvider, @NonNull GlyphUrlProvider glyphUrlProvider, @NonNull Projection projection, @NonNull List< ZoomRange > zoomRanges)

Adds a vector layer which uses the network to load tiles from URLs obtained through UrlProvider, images, models and glyphs obtained through their respective UrlProviders Sublayers will be added after corresponding sublayers of the map layer.

Layer addLayer(@NonNull String layerId, @NonNull String contentType, @NonNull TileFormat format, @NonNull LayerOptions layerOptions, @NonNull UrlProvider tileUrlProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull ResourceUrlProvider modelUrlProvider, @NonNull ResourceUrlProvider styleUrlProvider, @NonNull GlyphUrlProvider glyphUrlProvider, @NonNull Projection projection, @NonNull List< ZoomRange > zoomRanges)

Adds a vector layer which uses the network to load tiles from URLs obtained through UrlProvider, images, models, styles and glyphs obtained through their respective UrlProviders Sublayers will be added after corresponding sublayers of the map layer.

MapObjectCollection addMapObjectLayer(@NonNull String layerId)

Creates a new independent map object collection linked to the specified layer ID.

void addTapListener(@NonNull GeoObjectTapListener tapListener)

Adds a tap listener that is used to obtain brief geo object info.

CameraPosition cameraPosition(@NonNull BoundingBox boundingBox)

Calculates the camera position that projects the specified area into the view.

void deselectGeoObject()

Resets the currently selected geo object.

CameraPosition getCameraPosition()
IconSet getLayerIconSet()

The icon set provides an interface for adding custom icons to be used in layer customization.

Logo getLogo()

Yandex logo object.

MapObjectCollection getMapObjects()
MapType getMapType()

Sets the base map type.

float getMaxZoom()

Maximum available zoom level.

float getMinZoom()

Minimum available zoom level.

SublayerManager getSublayerManager()

Manages the collection of sublayers that define the drawing order.

VisibleRegion getVisibleRegion()
boolean isFastTapEnabled()

Removes the 300 ms delay in emitting a tap gesture.

boolean isModelsEnabled()

Enables/disables detailed 3D models on the map.

boolean isNightModeEnabled()

If enabled, night mode will reduce map brightness and improve contrast.

boolean isRotateGesturesEnabled()

Enable/disable rotation gestures, such as rotation with two fingers.

boolean isScrollGesturesEnabled()

Enable/disable scroll gestures, such as the pan gesture.

boolean isTiltGesturesEnabled()

Enable/disable tilt gestures, such as parallel pan with two fingers.

boolean isValid()

Tells if this Map is valid or no.

boolean isZoomGesturesEnabled()

Enable/disable zoom gestures, for example: - pinch - double tap (zoom in) - tap with two fingers (zoom out)

void move(@NonNull CameraPosition cameraPosition, @NonNull Animation animationType, @Nullable CameraCallback cameraCallback)

Changes camera position.

void move(@NonNull CameraPosition cameraPosition)

Immediately changes the camera position.

void removeCameraListener(@NonNull CameraListener cameraListener)

Removes camera listeners.

void removeInertiaMoveListener(@NonNull InertiaMoveListener inertiaMoveListener)

Removes inertia move listeners.

void removeInputListener(@NonNull InputListener inputListener)

Removes input listeners.

void removeTapListener(@NonNull GeoObjectTapListener tapListener)

Removes a tap listener that is used to obtain brief geo object info.

void resetMapStyles()

Resets all JSON style transformations applied to the map.

void selectGeoObject(@NonNull String objectId, @NonNull String layerId)

Selects a geo object with the specified objectId in the specified layerId.

void set2DMode(boolean enable)

Forces the map to be flat.

void setFastTapEnabled(boolean fastTapEnabled)
void setMapLoadedListener(@Nullable MapLoadedListener mapLoadedListener)

Sets a map loaded listener.

boolean setMapStyle(@NonNull String style)

Applies JSON style transformations to the map.

boolean setMapStyle(int id, @NonNull String style)

Applies JSON style transformations to the map.

void setMapType(@NonNull MapType mapType)
void setModelsEnabled(boolean modelsEnabled)
void setNightModeEnabled(boolean nightModeEnabled)
void setRotateGesturesEnabled(boolean rotateGesturesEnabled)
void setScrollGesturesEnabled(boolean scrollGesturesEnabled)
void setTiltFunction(@NonNull List< PointF > points)

Sets piecewise linear tilt depending on the zoom.

void setTiltGesturesEnabled(boolean tiltGesturesEnabled)
void setZoomGesturesEnabled(boolean zoomGesturesEnabled)
VisibleRegion visibleRegion(@NonNull CameraPosition cameraPosition)

Method Detail

addCameraListener

public void addCameraListener (@NonNull CameraListener cameraListener)

Adds camera listeners.

addInertiaMoveListener

public void addInertiaMoveListener (@NonNull InertiaMoveListener inertiaMoveListener)

Adds inertia move listeners.

addInputListener

public void addInputListener (@NonNull InputListener inputListener)

Adds input listeners.

addLayer

public Layer addLayer (@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull TileProvider tileProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull Projection projection)

Adds a layer that displays tiles from the user-defined TileProvider.

Sublayers will be added after corresponding sublayers of the map layer.

addLayer

public Layer addLayer (@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull TileProvider tileProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull ResourceUrlProvider animatedImageUrlProvider, @NonNull Projection projection, @NonNull List< ZoomRange > zoomRanges)

Adds a layer that displays tiles from the user-defined TileProvider.

Sublayers will be added after corresponding sublayers of the map layer.

addLayer

public Layer addLayer (@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull UrlProvider tileUrlProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull Projection projection)

Adds a layer that uses the network to load tiles from URLs obtained through UrlProvider.

Sublayers will be added after corresponding sublayers of the map layer.
Parameters:
layerId

The id of the layer.

contentType

Layer content type.

layerOptions

Layer options.

tileUrlProvider

Tile URL provider.

imageUrlProvider

Image URL provider.

projection

Projection.

addLayer

public Layer addLayer (@NonNull String layerId, @NonNull String contentType, @NonNull LayerOptions layerOptions, @NonNull UrlProvider tileUrlProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull ResourceUrlProvider modelUrlProvider, @NonNull GlyphUrlProvider glyphUrlProvider, @NonNull Projection projection, @NonNull List< ZoomRange > zoomRanges)

Adds a vector layer which uses the network to load tiles from URLs obtained through UrlProvider, images, models and glyphs obtained through their respective UrlProviders Sublayers will be added after corresponding sublayers of the map layer.

addLayer

public Layer addLayer (@NonNull String layerId, @NonNull String contentType, @NonNull TileFormat format, @NonNull LayerOptions layerOptions, @NonNull UrlProvider tileUrlProvider, @NonNull ResourceUrlProvider imageUrlProvider, @NonNull ResourceUrlProvider modelUrlProvider, @NonNull ResourceUrlProvider styleUrlProvider, @NonNull GlyphUrlProvider glyphUrlProvider, @NonNull Projection projection, @NonNull List< ZoomRange > zoomRanges)

Adds a vector layer which uses the network to load tiles from URLs obtained through UrlProvider, images, models, styles and glyphs obtained through their respective UrlProviders Sublayers will be added after corresponding sublayers of the map layer.

addMapObjectLayer

public MapObjectCollection addMapObjectLayer (@NonNull String layerId)

Creates a new independent map object collection linked to the specified layer ID.

Sublayers will be added after corresponding sublayers of the topmost layer.

addTapListener

public void addTapListener (@NonNull GeoObjectTapListener tapListener)

Adds a tap listener that is used to obtain brief geo object info.

cameraPosition

public CameraPosition cameraPosition (@NonNull BoundingBox boundingBox)

Calculates the camera position that projects the specified area into the view.

deselectGeoObject

public void deselectGeoObject ()

Resets the currently selected geo object.

getCameraPosition

public CameraPosition getCameraPosition ()

Returns:

Current camera position. Target position must be within latitude [-90, 90] and longitude [-180, 180].

getLayerIconSet

public IconSet getLayerIconSet ()

The icon set provides an interface for adding custom icons to be used in layer customization.

Affects VectorMap and Hybrid map types.

getMapObjects

public MapObjectCollection getMapObjects ()

Returns:

List of map objects associated with the map.

getMapType

public MapType getMapType ()

Sets the base map type.

getMaxZoom

public float getMaxZoom ()

Maximum available zoom level.

getMinZoom

public float getMinZoom ()

Minimum available zoom level.

getSublayerManager

public SublayerManager getSublayerManager ()

Manages the collection of sublayers that define the drawing order.

getVisibleRegion

public VisibleRegion getVisibleRegion ()

Returns:

The map region that is currently visible. Region IS bounded by latitude limits [-90, 90] and IS NOT bounded by longitude limits [-180, 180]. If the longitude exceeds its limits, we see the world's edge and another instance of the world beyond this edge.

isFastTapEnabled

public boolean isFastTapEnabled ()

Removes the 300 ms delay in emitting a tap gesture.

However, a double-tap will emit a tap gesture along with a double-tap.

isModelsEnabled

public boolean isModelsEnabled ()

Enables/disables detailed 3D models on the map.

Enabled by default.

isNightModeEnabled

public boolean isNightModeEnabled ()

If enabled, night mode will reduce map brightness and improve contrast.

isRotateGesturesEnabled

public boolean isRotateGesturesEnabled ()

Enable/disable rotation gestures, such as rotation with two fingers.

isScrollGesturesEnabled

public boolean isScrollGesturesEnabled ()

Enable/disable scroll gestures, such as the pan gesture.

isTiltGesturesEnabled

public boolean isTiltGesturesEnabled ()

Enable/disable tilt gestures, such as parallel pan with two fingers.

isValid

public boolean isValid ()

Tells if this Map is valid or no.

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

isZoomGesturesEnabled

public boolean isZoomGesturesEnabled ()

Enable/disable zoom gestures, for example: - pinch - double tap (zoom in) - tap with two fingers (zoom out)

move

public void move (@NonNull CameraPosition cameraPosition, @NonNull Animation animationType, @Nullable CameraCallback cameraCallback)

Changes camera position.

Can cancel a previous unfinished movement.
Parameters:
animationType

Required. Defines animation parameters. Deferred teleportation can be achieved via Animation::Step with the necessary duration. Animation for more details.

cameraCallback

A function that takes the bool argument marking the camera action complete. Invoked when: 1) A camera action is cancelled (for example, as a result of a subsequent request for camera movement), passing false as an argument. 2) A camera action finished successfully, passing true as an argument.

Remark:
Parameters:
cameraCallback

has optional type, it may be uninitialized.

move

public void move (@NonNull CameraPosition cameraPosition)

Immediately changes the camera position.

Can cancel a previous unfinished movement.

removeCameraListener

public void removeCameraListener (@NonNull CameraListener cameraListener)

Removes camera listeners.

removeInertiaMoveListener

public void removeInertiaMoveListener (@NonNull InertiaMoveListener inertiaMoveListener)

Removes inertia move listeners.

removeInputListener

public void removeInputListener (@NonNull InputListener inputListener)

Removes input listeners.

removeTapListener

public void removeTapListener (@NonNull GeoObjectTapListener tapListener)

Removes a tap listener that is used to obtain brief geo object info.

resetMapStyles

public void resetMapStyles ()

Resets all JSON style transformations applied to the map.

selectGeoObject

public void selectGeoObject (@NonNull String objectId, @NonNull String layerId)

Selects a geo object with the specified objectId in the specified layerId.

If the object is not currently on the screen, it is selected anyway, but the user will not actually see that. You need to move the camera in addition to this call to be sure that the selected object is visible for the user. Both objectId and layerId can be extracted from the geo object's metadata container by using geo_object_selection_metadata when the user taps on a geo object.

set2DMode

public void set2DMode (boolean enable)

Forces the map to be flat.

true - All loaded tiles start showing the "flatten out" animation; all new tiles do not start 3D animation. false - All tiles start showing the "rise up" animation.

setFastTapEnabled

public void setFastTapEnabled (boolean fastTapEnabled)

setMapLoadedListener

public void setMapLoadedListener (@Nullable MapLoadedListener mapLoadedListener)

Sets a map loaded listener.

Remark:
Parameters:
mapLoadedListener

has optional type, it may be uninitialized.

setMapStyle

public boolean setMapStyle (@NonNull String style)

Applies JSON style transformations to the map.

Same as setMapStyle(0, style). Affects VectorMap and Hybrid map types. Set to empty string to clear previous styling. Returns true if the style was successfully parsed, and false otherwise. If the returned value is false, the current map style remains unchanged.

setMapStyle

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

Applies JSON style transformations to the map.

Replaces previous styling with the specified ID (if such exists). Stylings are applied in an ascending order. Affects VectorMap and Hybrid map types. 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 map style remains unchanged.

setMapType

public void setMapType (@NonNull MapType mapType)

setModelsEnabled

public void setModelsEnabled (boolean modelsEnabled)

setNightModeEnabled

public void setNightModeEnabled (boolean nightModeEnabled)

setRotateGesturesEnabled

public void setRotateGesturesEnabled (boolean rotateGesturesEnabled)

setScrollGesturesEnabled

public void setScrollGesturesEnabled (boolean scrollGesturesEnabled)

setTiltFunction

public void setTiltFunction (@NonNull List< PointF > points)

Sets piecewise linear tilt depending on the zoom.

'points' must be sorted by x; x coordinates must be unique. If zoom < minZoom(points) or zoom > maxZoom(points), it is set within the defined bounds before applying the function. If points is null or points.empty() it erases the previously set function. If points.size() == 1, tilt is constant and equals point.y.

setTiltGesturesEnabled

public void setTiltGesturesEnabled (boolean tiltGesturesEnabled)

setZoomGesturesEnabled

public void setZoomGesturesEnabled (boolean zoomGesturesEnabled)

visibleRegion

public VisibleRegion visibleRegion (@NonNull CameraPosition cameraPosition)

Returns:

The map region that is visible from the given camera position. Region IS bounded by latitude limits [-90, 90] and IS NOT bounded by longitude limits [-180, 180]. If the longitude exceeds its limits, we see the world's edge and another instance of the world beyond this edge.