public class

MapFragment

extends Fragment
java.lang.Object
   ↳ android.app.Fragment
     ↳ com.amazon.geo.mapsv2.MapFragment

Class Overview

Represents a Fragment for displaying a map. Use this class if your app targets android API 12 and above. Otherwise, use SupportMapFragment.

Because this class is Fragment, it encompasses the View of a map and manages its life cycle.

If useViewLifecycleInFragment(boolean) flag is true, the MapFragment is invalid when it is detached from the Activity, such as after calling the onDestroyView() method. The MapFragment is usable after it is re-attached and onCreateView(LayoutInflater, ViewGroup, Bundle) is called.

Typically you add a MapFragment in the layout XML. For example:

 <fragment android:id="@+id/mapfragment_container"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      class="com.amazon.geo.mapsv2.MapFragment" />
 

Summary

[Expand]
Inherited Constants
From interface android.content.ComponentCallbacks2
Public Constructors
MapFragment()
Public default constructor.
Public Methods
final AmazonMap getMap()
This method is deprecated. Use getMapAsync(OnMapReadyCallback) instead. The callback of that method provides an AmazonMap which is guaranteed to be non-null.
final void getMapAsync(OnMapReadyCallback callback)
Get an AmazonMap asynchronously with a callback after it is ready to be used.
static MapFragment newInstance(AmazonMapOptions options)
Creates a new MapFragment object with the specified map options.
static MapFragment newInstance()
Creates a new MapFragment object with default options.
void onActivityCreated(Bundle savedInstanceState)
void onAttach(Activity activity)
void onCreate(Bundle savedInstanceState)
View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
void onDestroy()
void onDestroyView()
void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)
void onLowMemory()
void onPause()
void onResume()
void onSaveInstanceState(Bundle outState)
void setArguments(Bundle outState)
[Expand]
Inherited Methods
From class android.app.Fragment
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.content.ComponentCallbacks2
From interface android.view.View.OnCreateContextMenuListener

Public Constructors

public MapFragment ()

Public default constructor. Use newInstance() or newInstance(AmazonMapOptions) to create a MapFragment dynamically.

Public Methods

public final AmazonMap getMap ()

This method is deprecated.
Use getMapAsync(OnMapReadyCallback) instead. The callback of that method provides an AmazonMap which is guaranteed to be non-null.

Gets the map object associated with this MapFragment.

This method returns null if the map is not yet initialized through onCreateView(LayoutInflater, ViewGroup, Bundle). Subsequent calls can return a valid AmazonMap object once the map is initialized.

This method also returns null if the Amazon Maps API library is not available on the device.

Returns
  • An AmazonMap object. Returns null if the map has not been initialized or if the Amazon Maps API library is not available on the device.

public final void getMapAsync (OnMapReadyCallback callback)

Get an AmazonMap asynchronously with a callback after it is ready to be used. The map provided to the callback is guaranteed to be non-null.

This method must be called from the main thread. The callback will be invoked on the main thread.

Parameters
callback The callback to invoke when the map is ready to use.

public static MapFragment newInstance (AmazonMapOptions options)

Creates a new MapFragment object with the specified map options.

Parameters
options An AmazonMapOptions object with the desired initial map options.
Returns
  • The new MapFragment} object.

public static MapFragment newInstance ()

Creates a new MapFragment object with default options.

Returns
  • The new MapFragment object.

public void onActivityCreated (Bundle savedInstanceState)

public void onAttach (Activity activity)

public void onCreate (Bundle savedInstanceState)

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

public void onDestroy ()

public void onDestroyView ()

public void onInflate (Activity activity, AttributeSet attrs, Bundle savedInstanceState)

public void onLowMemory ()

public void onPause ()

public void onResume ()

public void onSaveInstanceState (Bundle outState)

public void setArguments (Bundle outState)