java.lang.Object | ||
↳ | android.app.Fragment | |
↳ | com.google.android.gms.maps.MapFragment |
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 file simply with the XML below.
<fragment
class="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
A GoogleMap
can only be acquired using getMap()
when the underlying maps
system is loaded and the underlying view in the fragment exists. This class
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
.
A view can be removed when the MapFragment's onDestroyView()
method is called and the
useViewLifecycleInFragment(boolean)
option is set. When this happens
the MapFragment is no longer valid until the view is recreated again later when MapFragment's
onCreateView(LayoutInflater, ViewGroup, Bundle)
method is called.
Any objects obtained from the GoogleMap
is associated with the view. It's important to
not hold on to objects (e.g. Marker
) beyond the view's life. Otherwise it will cause a
memory leak as the view cannot be released.
Use this class only if you are targeting API 12 and above. Otherwise, use SupportMapFragment.
For more information, read the Google Maps Android API v2 developer guide.
[Expand]
Inherited Constants | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From interface
android.content.ComponentCallbacks2
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a map fragment.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the underlying GoogleMap that is tied to the view wrapped by this fragment.
| |||||||||||
Creates a map fragment, using default options.
| |||||||||||
Creates a map fragment with the given options.
| |||||||||||
Parse attributes during inflation from a view hierarchy into the arguments we handle.
| |||||||||||
[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
|
Creates a map fragment. This constructor is public only for use by an inflater. Use
newInstance()
to create a MapFragment programmatically.
Gets the underlying GoogleMap that is tied to the view wrapped by this fragment.
onCreateView(LayoutInflater, ViewGroup, Bundle)
yet. This can also happen if
Google Play services is not available. If Google Play services becomes available
afterwards and the fragment have gone through
onCreateView(LayoutInflater, ViewGroup, Bundle)
, calling this method again
will initialize and return the GoogleMap.
Creates a map fragment with the given options.
Parse attributes during inflation from a view hierarchy into the arguments we handle.