Class Info |
|---|
public class MapFragment Map component that extends the native Fragment component of Android and can be used to add a map to an app in the simplest way. It provides a view of a map to automatically process the necessary lifecycle functions, and can be loaded to the layout file of Activity for use. To automatically initialize the map system and view, call getMapAsync. The HuaweiMap object must be obtained using getMapAsync(OnMapReadyCallback callback). This class will automatically initialize the map system and view. Any object obtained from HuaweiMap will be associated with the view. Do not save objects (such as markers) out of the view's lifecycle. Otherwise, memory leaks will occur because the view cannot be released. |
Qualifier and Type | Method Name and Description |
|---|---|
void | getMapAsync(OnMapReadyCallback callback) Obtains a HuaweiMap object when the object is ready. |
static MapFragment | Creates a MapFragment object with default attributes. |
static MapFragment | newInstance(HuaweiMapOptions options) Creates a MapFragment object based on the specified options parameter. |
void | onActivityCreated(Bundle savedInstanceState) Lifecycle method inherited from Fragment. |
void | onAttach(Activity activity) Lifecycle method inherited from Fragment. |
void | onCreate(Bundle savedInstanceState) Lifecycle method inherited from Fragment. |
View | onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) Lifecycle method inherited from Fragment. |
void | Lifecycle method inherited from Fragment. |
void | Lifecycle method inherited from Fragment. |
void | onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) Lifecycle method inherited from Fragment. This method is called when Fragment is statically loaded in XML mode. |
void | Lifecycle method inherited from Fragment. This method is called when the memory is insufficient. |
void | onPause() Lifecycle method inherited from Fragment. |
void | onResume() Lifecycle method inherited from Fragment. |
void | onSaveInstanceState(Bundle outState) Lifecycle method inherited from Fragment and called when MapFragment is destroyed unexpectedly. It is used to save the status of a MapFragment object before it is destroyed. |
void | onStart() Lifecycle method inherited from Fragment. |
void | onStop() Lifecycle method inherited from Fragment. |
void | setArguments(Bundle args) Lifecycle method inherited from Fragment and called when data needs to be passed to MapFragment. |
Method |
|---|
public void getMapAsync(OnMapReadyCallback callback) Obtains a HuaweiMap object when the object is ready. |
Parameters
Name | Description |
|---|---|
callback | Callback to be executed when a HuaweiMap object is ready for use. |
Method |
|---|
public static MapFragment newInstance() Creates a MapFragment object with default attributes. |
Returns
Type | Description |
|---|---|
MapFragment | MapFragment object. |
Method |
|---|
public static MapFragment newInstance(HuaweiMapOptions options) Creates a MapFragment object based on the specified options parameter. |
Parameters
Name | Description |
|---|---|
options | Attributes required for creating a MapFragment object. |
Returns
Type | Description |
|---|---|
MapFragment | MapFragment object. |
Method |
|---|
public void onActivityCreated(Bundle savedInstanceState) Lifecycle method inherited from Fragment. |
Parameters
Name | Description |
|---|---|
savedInstanceState | Status to be saved for a MapFragment object. |
Method |
|---|
public void onAttach(Activity activity) Lifecycle method inherited from Fragment. |
Parameters
Name | Description |
|---|---|
activity | Activity object bound to MapFragment. |
Method |
|---|
public void onCreate(Bundle savedInstanceState) Lifecycle method inherited from Fragment. |
Parameters
Name | Description |
|---|---|
savedInstanceState | Status to be saved for a MapFragment object. |
Method |
|---|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) Lifecycle method inherited from Fragment. |
Parameters
Name | Description |
|---|---|
inflater | LayoutInflater object, which is used to search for controls in a layout. |
container | Layout container. |
savedInstanceState | Status to be saved for a MapFragment object. |
Returns
Type | Description |
|---|---|
View | View object. |
Method |
|---|
public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) Lifecycle method inherited from Fragment. This method is called when Fragment is statically loaded in XML mode. |
Parameters
Name | Description |
|---|---|
activity | Activity object bound to MapFragment. |
attrs | Attributes used to create a MapFragment object. |
savedInstanceState | Status to be saved for a MapFragment object. |
Method |
|---|
public void onLowMemory() Lifecycle method inherited from Fragment. This method is called when the memory is insufficient. |
Method |
|---|
public void onSaveInstanceState(Bundle outState) Lifecycle method inherited from Fragment and called when MapFragment is destroyed unexpectedly. It is used to save the status of a MapFragment object before it is destroyed. |
Parameters
Name | Description |
|---|---|
outState | Status to be saved for a MapFragment object. |