public class

MapView

extends FrameLayout
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.google.android.gms.maps.MapView

Class Overview

A View which displays a map (with data obtained from the Google Maps service). When focused, it will capture keypresses and touch gestures to move the map.

Users of this class must forward all the life cycle methods from the Activity or Fragment containing this view to the corresponding ones in this class. In particular, you must forward on the following methods:

A GoogleMap can only be acquired using getMap() when the underlying maps system is loaded and the underlying view in the fragment exists. The MapView automatically initializes the maps system and the view; however you cannot be guaranteed when it will be ready because this depends on the availability of the Google Play services APK. If a GoogleMap is not available, getMap() will return null.

For a simpler method of displaying a Map use MapFragment (or SupportMapFragment if you are looking to target earlier platforms.

Note: You are advised not to add children to this view.

Summary

[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
MapView(Context context)
MapView(Context context, AttributeSet attrs)
MapView(Context context, AttributeSet attrs, int defStyle)
MapView(Context context, GoogleMapOptions options)
Public Methods
GoogleMap getMap()
Gets the underlying GoogleMap that is tied to this view.
final void onCreate(Bundle savedInstanceState)
final void onDestroy()
final void onLowMemory()
final void onPause()
final void onResume()
final void onSaveInstanceState(Bundle outState)
[Expand]
Inherited Methods
From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public MapView (Context context)

public MapView (Context context, AttributeSet attrs)

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

public MapView (Context context, GoogleMapOptions options)

Public Methods

public GoogleMap getMap ()

Gets the underlying GoogleMap that is tied to this view.

Returns
  • the GoogleMap. Null if the view of the map is not yet ready. This can happen when Google Play services is not available. If Google Play services becomes available afterwards, calling this method again will initialize and return the GoogleMap.

public final void onCreate (Bundle savedInstanceState)

public final void onDestroy ()

public final void onLowMemory ()

public final void onPause ()

public final void onResume ()

public final void onSaveInstanceState (Bundle outState)