Class MapView

com.yandex.mapkit.mapview

java.lang.Object ⇽ MapView

public class MapView implements MapWindow

All Implemented Interfaces:
MapWindow

MapView can be customized by using the yandex:movable XML attribute.

If yandex:movable="true" then PlatformGLTextureView will be used for rendering and MapView can be used, for example, in a ListView. If yandex:movable="false" or is not set, PlatfromGLSurfaceView will be used for rendering and MapView should not be used in a ListView or a GridView. If yandex:movable="false" then this MapView can't overlap with any other MapView (either movable or not).

Constructors

MapView(Context context)
MapView(Context context, AttributeSet attrs)
MapView(Context context, AttributeSet attrs, int defStyle)
MapView(Context context)
MapView(Context context, AttributeSet attrs)
MapView(Context context, AttributeSet attrs, int defStyle)

Methods

void addSizeChangedListener( SizeChangedListener sizeChangedListener)

Add a SizeChangedListener.

double getFieldOfViewY()

Sets the vertical field of view, in degrees.

ScreenRect getFocusRect()

When using controls that overlay the map view, calculating the proper camera position can be tricky.

VisibleRegion getFocusRegion()
Map getMap()
PointOfView getPointOfView()

Sets the position of the point of view.

float getScaleFactor()

Sets the scale factor, which equals the number of pixels per device-independent point.

Bitmap getScreenshot()
ScreenPoint getZoomFocusPoint()

Defines the focus point of map zooming for double tap and multi tap gestures.

boolean isValid()

Tells if this MapWindow is valid or no.

void onMemoryWarning()

Should be called from ComponentCallbacks2.onTrimMemory.

void onStart()

Should be called from from corresponding method of activity or fragment containing this view.

void onStop()

Should be called from from corresponding method of activity or fragment containing this view.

void removeSizeChangedListener( SizeChangedListener sizeChangedListener)

Remove a SizeChangedListener.

Point screenToWorld( ScreenPoint screenPoint)

Transforms coordinates from screen space to world space.

void setFieldOfViewY(double fovY)
void setFocusRect( ScreenRect rect)
void setMaxFps(float fps)

Caps FPS.

void setNoninteractive(boolean is)
void setPointOfView( PointOfView pointOfView)
void setScaleFactor(float scaleFactor)
void setZoomFocusPoint( ScreenPoint zoomFocusPoint)
void startPerformanceMetricsCapture()
String stopPerformanceMetricsCapture()
ScreenPoint worldToScreen( Point worldPoint)

Transforms the position from world coordinates to screen coordinates.

void addSizeChangedListener( SizeChangedListener sizeChangedListener)

Add a SizeChangedListener.

double getFieldOfViewY()

Sets the vertical field of view, in degrees.

ScreenRect getFocusRect()

When using controls that overlay the map view, calculating the proper camera position can be tricky.

VisibleRegion getFocusRegion()
Map getMap()
PointOfView getPointOfView()

Sets the position of the point of view.

float getScaleFactor()

Sets the scale factor, which equals the number of pixels per device-independent point.

Bitmap getScreenshot()
ScreenPoint getZoomFocusPoint()

Defines the focus point of map zooming for double tap and multi tap gestures.

boolean isValid()

Tells if this MapWindow is valid or no.

void onMemoryWarning()

Should be called from ComponentCallbacks2.onTrimMemory.

void onStart()

Should be called from from corresponding method of activity or fragment containing this view.

void onStop()

Should be called from from corresponding method of activity or fragment containing this view.

void removeSizeChangedListener( SizeChangedListener sizeChangedListener)

Remove a SizeChangedListener.

Point screenToWorld( ScreenPoint screenPoint)

Transforms coordinates from screen space to world space.

void setFieldOfViewY(double fovY)
void setFocusRect( ScreenRect rect)
void setMaxFps(float fps)

Caps FPS.

void setNoninteractive(boolean is)
void setPointOfView( PointOfView pointOfView)
void setScaleFactor(float scaleFactor)
void setZoomFocusPoint( ScreenPoint zoomFocusPoint)
void startPerformanceMetricsCapture()
String stopPerformanceMetricsCapture()
ScreenPoint worldToScreen( Point worldPoint)

Transforms the position from world coordinates to screen coordinates.

Constructor Detail

MapView

public MapView (Context context)

MapView

public MapView (Context context, AttributeSet attrs)

MapView

public MapView (Context context, AttributeSet attrs, int defStyle)

Method Detail

addSizeChangedListener

public void addSizeChangedListener (SizeChangedListener sizeChangedListener)

Add a SizeChangedListener.

getFieldOfViewY

public double getFieldOfViewY ()

Sets the vertical field of view, in degrees.

Default: 30.

getFocusRect

public ScreenRect getFocusRect ()

When using controls that overlay the map view, calculating the proper camera position can be tricky.

This method simplifies the task by defining the area of interest (the focus rectangle) inside the view. This area serves as a reference for all subsequent camera movements.For example, when using a semi-transparent control that overlays the top half of the map view, define the focus rectangle as the lower half of the view to ensure that all camera movements will have the center of the lower half as their target.On iOS, if you change the focus rectangle in the viewDidLayoutSubviews callback, it's recommended to call MapView.layoutIfNeeded just before that action.Optional property, can be null.

getFocusRegion

public VisibleRegion getFocusRegion ()

Returns:

A region that corresponds to the current focusRect or the visible region if focusRect is not set. Region IS bounded by latitude limits [-90, 90] and IS NOT bounded by longitude limits [-180, 180]. If longitude exceeds its limits, we see the world's edge and another instance of the world beyond this edge.

getMap

public Map getMap ()

getPointOfView

public PointOfView getPointOfView ()

Sets the position of the point of view.

Cameras use perspective projection, which causes perspective deformations. Perspective projection has an axis, and points on this axis are not affected by perspective deformations. This axis is a line parallel to the view's direction, so its projection to the screen is a point - the "point of view". By default, this point is at the center of the screen, but some applications might want to set it to the center of focusRect. Use this flag to do so. Default: ScreenCenter

getScaleFactor

public float getScaleFactor ()

Sets the scale factor, which equals the number of pixels per device-independent point.

getScreenshot

public Bitmap getScreenshot ()

getZoomFocusPoint

public ScreenPoint getZoomFocusPoint ()

Defines the focus point of map zooming for double tap and multi tap gestures.

If the point is not set, the source point of the gesture will be used as the focus point. Default: none.Optional property, can be null.

isValid

public boolean isValid ()

Tells if this MapWindow is valid or no.

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

onMemoryWarning

public void onMemoryWarning ()

Should be called from ComponentCallbacks2.onTrimMemory.

Recommended levels are TRIM_MEMORY_RUNNING_LOW (foreground) and TRIM_MEMORY_COMPLETE(background).

onStart

public void onStart ()

Should be called from from corresponding method of activity or fragment containing this view.

onStop

public void onStop ()

Should be called from from corresponding method of activity or fragment containing this view.

removeSizeChangedListener

public void removeSizeChangedListener (SizeChangedListener sizeChangedListener)

Remove a SizeChangedListener.

screenToWorld

public Point screenToWorld (ScreenPoint screenPoint)

Transforms coordinates from screen space to world space.

Parameters:
screenPoint

The point in screen coordinates relative to the top left of the map. These coordinates are in physical pixels and not in device independent (virtual) pixels.

screenPoint

The point in screen coordinates relative to the top left of the map. These coordinates are in physical pixels and not in device independent (virtual) pixels.

Returns:

Latitude and longitude information.

setFieldOfViewY

public void setFieldOfViewY (double fovY)

setFocusRect

public void setFocusRect (ScreenRect rect)

setMaxFps

public void setMaxFps (float fps)

Caps FPS.

Valid range: (0, 60]. Default: 60.

setNoninteractive

public void setNoninteractive (boolean is)

setPointOfView

public void setPointOfView (PointOfView pointOfView)

setScaleFactor

public void setScaleFactor (float scaleFactor)

setZoomFocusPoint

public void setZoomFocusPoint (ScreenPoint zoomFocusPoint)

startPerformanceMetricsCapture

public void startPerformanceMetricsCapture ()

stopPerformanceMetricsCapture

public String stopPerformanceMetricsCapture ()

worldToScreen

public ScreenPoint worldToScreen (Point worldPoint)

Transforms the position from world coordinates to screen coordinates.

Parameters:
worldPoint

Latitude and longitude information.

worldPoint

Latitude and longitude information.

Returns:

The point in screen space corresponding to worldPoint; returns none if the point is behind the camera.