Class MapFragment
- All Implemented Interfaces:
android.content.ComponentCallbacks,android.view.View.OnCreateContextMenuListener,androidx.activity.result.ActivityResultCaller,androidx.lifecycle.HasDefaultViewModelProviderFactory,androidx.lifecycle.LifecycleOwner,androidx.lifecycle.ViewModelStoreOwner,androidx.savedstate.SavedStateRegistryOwner,OrientationDetector.Listener,MapView.DirectionsEventListener,MapView.MapClickEventListener,MapView.MapEventListener,MapView.MarkerEventListener
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class androidx.fragment.app.Fragment
androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState -
Field Summary
Fields inherited from class androidx.fragment.app.Fragment
mPreviousWho -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEnd directions to the given placemark.Gets a copy of the currentDirectionsOptions, defaulting to theMapViewoptions if none are set on this fragment or the default ones if aMapViewwas not initialized yet.Gets a copy of the currentMapOptions, defaulting to theMapViewoptions if none are set on this fragment or the default ones if aMapViewwas not initialized yet.Gets our ownedMapViewif created, otherwise null.markerForPlacemark(Placemark placemark) This method is an opportunity to supply your ownMarkerinstance for a given Placemark.markerForSelectedMarker(Marker markerToSelect) voidonActivityResult(int requestCode, int resultCode, android.content.Intent data) booleanonCalloutClick(Marker marker) Called when the callout is tapped.voidonCreate(android.os.Bundle savedInstanceState) android.view.ViewonCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState) voidbooleanonDirectionsClick(Marker marker) Called when the directions action of the marker callout view is tapped.booleanCalled when the user exits directions.booleanCalled when there has been an error getting directions.voidCalled when the directions need to reroute.booleanCalled when the directions are calculated.booleanCalled when the user clicks the Location button.voidonLocationUpdated(MeridianLocation location) Called when the Location has updated for this map.booleanonLongPress(float x, float y) Called when the user long presses on the map.booleanCalled when the user clicks on the map, but not on a control or Marker.voidCalled when there has been an error retrieving the map from the internet or parsing the map that was retrieved.voidCalled after loading of the map image is complete.voidCalled when initial loading of a map starts, this is called before any web request or graphics related loading happens.voidCalled after the map and Placemarks have been loaded and rendered.voidonMapTransformChange(android.graphics.Matrix transform) Called when screen to map transform for this map changes.booleanonMarkerDeselect(Marker marker) Called when a user taps somewhere on the map deselecting a marker.booleanonMarkerSelect(Marker marker) Called when a user taps a Marker on the map.voidvoidonOrientationUpdated(MeridianOrientation orientation) Called when orientation of the device has been updated.voidbooleanCalled when the user clicks the Overview button.voidonPause()voidCalled after loading Placemarks.voidonResume()booleanonRouteStepIndexChange(int index) Called when the route step has been updated.voidonSaveInstanceState(android.os.Bundle outState) protected voidonSourceResult(DirectionsDestination destination, DirectionsSource source) This event takes place right before directions are retrieved from the server and provide an opportunity to change the source and destination, or just be notified of the event.voidonStop()voidCalled when the accessibility option has been toggled by the user.voidSet the DirectionsEventListener for this MapFragment.voidsetDirectionsOptions(DirectionsOptions options) Set current directions options.voidSet the MapClickEventListener for this MapFragment.voidsetMapEventListener(MapView.MapEventListener listener) Set the MapEventListener for this MapFragment.voidsetMapOptions(MapOptions options) Set current map options.voidSet the MarkerEventListener for this MapFragment.voidstartDirections(DirectionsDestination destination) Start directions to the given placemark.Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getDefaultViewModelCreationExtras, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onStart, onViewCreated, onViewStateRestored, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
-
Constructor Details
-
MapFragment
public MapFragment()
-
-
Method Details
-
getMapOptions
Gets a copy of the currentMapOptions, defaulting to theMapViewoptions if none are set on this fragment or the default ones if aMapViewwas not initialized yet.Changing the properties of the returned
MapOptionswill have no effect. To change theMapOptionsfor this MapFragment, call setMapOptions. -
setMapOptions
Set current map options.These will be applied to our owned
MapViewinstance either immediately if it exists, or automatically when created. -
getDirectionsOptions
Gets a copy of the currentDirectionsOptions, defaulting to theMapViewoptions if none are set on this fragment or the default ones if aMapViewwas not initialized yet.Changing the properties of the returned
DirectionsOptionswill have no effect. To change theDirectionsOptionsfor this MapFragment, call setDirectionsOptions. -
setDirectionsOptions
Set current directions options.These will be applied to our owned
MapViewinstance either immediately if it exists, or automatically when created. -
getMapView
Gets our ownedMapViewif created, otherwise null.You may call methods and set properties on the returned view.
-
setMarkerEventListener
Set the MarkerEventListener for this MapFragment. -
setDirectionsEventListener
Set the DirectionsEventListener for this MapFragment. -
setMapEventListener
Set the MapEventListener for this MapFragment. -
setMapClickEventListener
Set the MapClickEventListener for this MapFragment. -
onCreate
public void onCreate(android.os.Bundle savedInstanceState) - Overrides:
onCreatein classandroidx.fragment.app.Fragment
-
onSaveInstanceState
public void onSaveInstanceState(@NonNull android.os.Bundle outState) - Overrides:
onSaveInstanceStatein classandroidx.fragment.app.Fragment
-
onCreateView
public android.view.View onCreateView(@NonNull android.view.LayoutInflater inflater, @Nullable android.view.ViewGroup container, @Nullable android.os.Bundle savedInstanceState) - Overrides:
onCreateViewin classandroidx.fragment.app.Fragment
-
onResume
public void onResume()- Overrides:
onResumein classandroidx.fragment.app.Fragment
-
onPause
public void onPause()- Overrides:
onPausein classandroidx.fragment.app.Fragment
-
onStop
public void onStop()- Overrides:
onStopin classandroidx.fragment.app.Fragment
-
onDestroy
public void onDestroy()- Overrides:
onDestroyin classandroidx.fragment.app.Fragment
-
startDirections
Start directions to the given placemark. -
endDirections
public void endDirections()End directions to the given placemark. -
onActivityResult
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data) - Overrides:
onActivityResultin classandroidx.fragment.app.Fragment
-
onSourceResult
This event takes place right before directions are retrieved from the server and provide an opportunity to change the source and destination, or just be notified of the event.Make sure to call super or the directions request will be canceled.
-
onMarkerSelect
Description copied from interface:MapView.MarkerEventListenerCalled when a user taps a Marker on the map.- Specified by:
onMarkerSelectin interfaceMapView.MarkerEventListener- Parameters:
marker- An instance of the marker that was tapped.- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onMarkerDeselect
Description copied from interface:MapView.MarkerEventListenerCalled when a user taps somewhere on the map deselecting a marker.- Specified by:
onMarkerDeselectin interfaceMapView.MarkerEventListener- Parameters:
marker- An instance of the marker that was previously selected.- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
markerForPlacemark
Description copied from interface:MapView.MarkerEventListenerThis method is an opportunity to supply your ownMarkerinstance for a given Placemark.You can use this to completely customize the look of Placemarks on the map. The default implementation returns null.
- Specified by:
markerForPlacemarkin interfaceMapView.MarkerEventListener- Parameters:
placemark- The Placemark that is requesting aMarkerfor displaying on the map.- Returns:
- A new instance of a
Markersubclass or null to request that MapView create a defaultMarker.
-
markerForSelectedMarker
Description copied from interface:MapView.MarkerEventListenerThis method is an opportunity to supply your own selectedMarkerinstance for a selectedMarker.You can use this to completely customize the look of selected Placemarks on the map. The default implementation returns null.
- Specified by:
markerForSelectedMarkerin interfaceMapView.MarkerEventListener- Parameters:
markerToSelect- The Marker that is being selected.- Returns:
- A new instance of a
Markersubclass or null to request that MapView create a defaultMarker.
-
onCalloutClick
Description copied from interface:MapView.MarkerEventListenerCalled when the callout is tapped.The callout is the screen footer which lists the marker name and has a directions button.
- Specified by:
onCalloutClickin interfaceMapView.MarkerEventListener- Parameters:
marker- An instance of the marker that was active when the callout was tapped.- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onMapLoadStart
public void onMapLoadStart()Description copied from interface:MapView.MapEventListenerCalled when initial loading of a map starts, this is called before any web request or graphics related loading happens.- Specified by:
onMapLoadStartin interfaceMapView.MapEventListener
-
onMapLoadFinish
public void onMapLoadFinish()Description copied from interface:MapView.MapEventListenerCalled after loading of the map image is complete.It has not been rendered at this point.
- Specified by:
onMapLoadFinishin interfaceMapView.MapEventListener
-
onPlacemarksLoadFinish
public void onPlacemarksLoadFinish()Description copied from interface:MapView.MapEventListenerCalled after loading Placemarks.This is a good place to add your own markers and edit data in the loaded Placemarks before they are rendered to the screen.
- Specified by:
onPlacemarksLoadFinishin interfaceMapView.MapEventListener
-
onMapRenderFinish
public void onMapRenderFinish()Description copied from interface:MapView.MapEventListenerCalled after the map and Placemarks have been loaded and rendered.Changing any markers should be avoided.
- Specified by:
onMapRenderFinishin interfaceMapView.MapEventListener
-
onMapLoadFail
Description copied from interface:MapView.MapEventListenerCalled when there has been an error retrieving the map from the internet or parsing the map that was retrieved.- Specified by:
onMapLoadFailin interfaceMapView.MapEventListener- Parameters:
tr- Exception that occurred while loading map.
-
onMapTransformChange
public void onMapTransformChange(android.graphics.Matrix transform) Description copied from interface:MapView.MapEventListenerCalled when screen to map transform for this map changes.- Specified by:
onMapTransformChangein interfaceMapView.MapEventListener- Parameters:
transform- new transform matrix.
-
onLocationUpdated
Description copied from interface:MapView.MapEventListenerCalled when the Location has updated for this map.- Specified by:
onLocationUpdatedin interfaceMapView.MapEventListener- Parameters:
location- The updated location.
-
onOrientationUpdated
Description copied from interface:MapView.MapEventListenerCalled when orientation of the device has been updated.- Specified by:
onOrientationUpdatedin interfaceMapView.MapEventListener- Parameters:
orientation- The updated orientation.
-
onLocationButtonClick
public boolean onLocationButtonClick()Description copied from interface:MapView.MapClickEventListenerCalled when the user clicks the Location button.- Specified by:
onLocationButtonClickin interfaceMapView.MapClickEventListener- Returns:
- true if the event has been handled, false if we still want the default behavior to occur.
-
onOverviewButtonClick
public boolean onOverviewButtonClick()Description copied from interface:MapView.MapClickEventListenerCalled when the user clicks the Overview button.Note that the overview button is in the upper left corner of the map and only appears if there is a map without a building that is the default map. This is not associated with the overview button in directions.
- Specified by:
onOverviewButtonClickin interfaceMapView.MapClickEventListener- Returns:
- true if the event has been handled, false if we still want the default behavior to occur.
-
onMapClick
public boolean onMapClick()Description copied from interface:MapView.MapClickEventListenerCalled when the user clicks on the map, but not on a control or Marker.In most cases this should be an indicator that the user is trying to dismiss the active UI.
- Specified by:
onMapClickin interfaceMapView.MapClickEventListener- Returns:
- true if the event has been handled, false if we still want the default behavior to occur.
-
onLongPress
public boolean onLongPress(float x, float y) Description copied from interface:MapView.MapClickEventListenerCalled when the user long presses on the map.- Specified by:
onLongPressin interfaceMapView.MapClickEventListener- Returns:
- true if the event has been handled, false if we still want the default behavior to occur.
-
onDirectionsReroute
public void onDirectionsReroute()Description copied from interface:MapView.DirectionsEventListenerCalled when the directions need to reroute.- Specified by:
onDirectionsReroutein interfaceMapView.DirectionsEventListener
-
onDirectionsClick
Description copied from interface:MapView.DirectionsEventListenerCalled when the directions action of the marker callout view is tapped.- Specified by:
onDirectionsClickin interfaceMapView.DirectionsEventListener- Parameters:
marker- An instance of the marker that was active when the callout was tapped.- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onDirectionsStart
public boolean onDirectionsStart()Description copied from interface:MapView.DirectionsEventListenerCalled when the directions are calculated.- Specified by:
onDirectionsStartin interfaceMapView.DirectionsEventListener- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onRouteStepIndexChange
public boolean onRouteStepIndexChange(int index) Description copied from interface:MapView.DirectionsEventListenerCalled when the route step has been updated.- Specified by:
onRouteStepIndexChangein interfaceMapView.DirectionsEventListener- Parameters:
index- The index of the updated step.- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onDirectionsClosed
public boolean onDirectionsClosed()Description copied from interface:MapView.DirectionsEventListenerCalled when the user exits directions.- Specified by:
onDirectionsClosedin interfaceMapView.DirectionsEventListener- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onDirectionsError
Description copied from interface:MapView.DirectionsEventListenerCalled when there has been an error getting directions.- Specified by:
onDirectionsErrorin interfaceMapView.DirectionsEventListener- Parameters:
tr- Exception that occurred while loading directions.- Returns:
trueto indicate that the event has been handled,falseto allow the default action to take place.
-
onUseAccessiblePathsChange
public void onUseAccessiblePathsChange()Description copied from interface:MapView.DirectionsEventListenerCalled when the accessibility option has been toggled by the user.- Specified by:
onUseAccessiblePathsChangein interfaceMapView.DirectionsEventListener
-
onOrientationRight
public void onOrientationRight()- Specified by:
onOrientationRightin interfaceOrientationDetector.Listener
-
onOrientationWrong
public void onOrientationWrong()- Specified by:
onOrientationWrongin interfaceOrientationDetector.Listener
-