public final class MapFragment extends Fragment implements OnMapReadyCallback
A Map component in an app. This fragment is the simplest way to place a map in an application. It's a wrapper around a view of a map to automatically handle the necessary life cycle needs. Being a fragment, this component can be added to an activity's layout or can dynamically be added using a FragmentManager.
To get a reference to the MapView, use getMapAsync(OnMapReadyCallback)
}
getMapAsync(OnMapReadyCallback)
Modifier and Type | Class and Description |
---|---|
static interface |
MapFragment.OnMapViewReadyCallback
Callback to be invoked when the map fragment has inflated its MapView.
|
Constructor and Description |
---|
MapFragment() |
Modifier and Type | Method and Description |
---|---|
void |
getMapAsync(OnMapReadyCallback onMapReadyCallback)
Sets a callback object which will be triggered when the MapboxMap instance is ready to be used.
|
static MapFragment |
newInstance()
Creates a default MapFragment instance
|
static MapFragment |
newInstance(MapboxMapOptions mapboxMapOptions)
Creates a MapFragment instance
|
void |
onAttach(Context context)
Called when the context attaches to this fragment.
|
View |
onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState)
Creates the fragment view hierarchy.
|
void |
onDestroyView()
Called when the fragment is view hiearchy is being destroyed.
|
void |
onInflate(Context context,
AttributeSet attrs,
Bundle savedInstanceState)
Called when this fragment is inflated, parses XML tag attributes.
|
void |
onLowMemory()
Called when the fragment receives onLowMemory call from the hosting Activity.
|
void |
onMapReady(MapboxMap mapboxMap)
Called when the style of the map has successfully loaded.
|
void |
onPause()
Called when the fragment is pausing.
|
void |
onResume()
Called when the fragment is ready to be interacted with.
|
void |
onSaveInstanceState(Bundle outState)
Called when the fragment state needs to be saved.
|
void |
onStart()
Called when the fragment is visible for the users.
|
void |
onStop()
Called when the fragment is no longer visible for the user.
|
void |
onViewCreated(View view,
Bundle savedInstanceState)
Called when the fragment view hierarchy is created.
|
public static MapFragment newInstance()
public static MapFragment newInstance(MapboxMapOptions mapboxMapOptions)
mapboxMapOptions
- The configuration options to be used.public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState)
context
- The context inflating this fragment.attrs
- The XML tag attributes.savedInstanceState
- The saved instance state for the map fragment.public void onAttach(Context context)
context
- the context attachingpublic View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
inflater
- Inflater used to inflate content.container
- The parent layout for the map fragment.savedInstanceState
- The saved instance state for the map fragment.public void onViewCreated(View view, Bundle savedInstanceState)
view
- The content view of the fragmentsavedInstanceState
- The saved instance state of the fragmentpublic void onMapReady(MapboxMap mapboxMap)
onMapReady
in interface OnMapReadyCallback
mapboxMap
- The public api controller of the mappublic void onStart()
public void onResume()
public void onPause()
public void onSaveInstanceState(Bundle outState)
outState
- The saved statepublic void onStop()
public void onLowMemory()
public void onDestroyView()
public void getMapAsync(OnMapReadyCallback onMapReadyCallback)
onMapReadyCallback
- The callback to be invoked.© 2015–2018 Mapbox. All rights reserved.