public class MapFragment extends androidx.fragment.app.Fragment implements MapView.MarkerEventListener, MapView.DirectionsEventListener, MapView.MapEventListener, OrientationDetector.Listener
A Fragment for providing an interactive Meridian map surface with map and directions controls.
| Modifier and Type | Class and Description |
|---|---|
static class |
MapFragment.Builder |
| Constructor and Description |
|---|
MapFragment() |
| Modifier and Type | Method and Description |
|---|---|
MapOptions |
getMapOptions()
Gets a copy of the current
MapOptions, defaulting to the MapView options if none are set on this fragment or the default ones if a MapView was not initialized yet. |
MapView |
getMapView()
Gets our owned
MapView if created, otherwise null. |
Marker |
markerForPlacemark(Placemark placemark)
This method is an opportunity to supply your own
Marker instance for a given Placemark. |
Marker |
markerForSelectedMarker(Marker markerToSelect)
|
void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent data) |
boolean |
onCalloutClick(Marker marker)
Called when the callout is tapped.
|
void |
onCreate(android.os.Bundle savedInstanceState) |
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState) |
void |
onDestroy() |
boolean |
onDirectionsClick(Marker marker)
Called when the directions action of the marker callout view is tapped.
|
boolean |
onDirectionsClosed()
Called when the user exits directions
|
boolean |
onDirectionsError(java.lang.Throwable tr)
Called when there has been an error getting directions
|
void |
onDirectionsReroute()
Called when our directions need to reroute
|
boolean |
onDirectionsStart()
Called when the directions are calculated
|
boolean |
onLocationButtonClick()
Called when the user taps the location button.
|
void |
onLocationUpdated(MeridianLocation location)
Called when the Location has updated for this map.
|
void |
onMapLoadFail(java.lang.Throwable tr)
Called when there has been an error retrieving the map from the internet or parsing the map that was retrieved.
|
void |
onMapLoadFinish()
Called after loading of the map image is complete.
|
void |
onMapLoadStart()
Called when initial loading of a map starts, this is called before any web request or graphics related loading happens.
|
void |
onMapRenderFinish()
Called after the map and placemarks have been loaded and rendered.
|
void |
onMapTransformChange(android.graphics.Matrix transform)
Called when screen to map transform for this map changes.
|
boolean |
onMarkerDeselect(Marker marker)
Called when a user taps somewhere on the map deselecting a marker.
|
boolean |
onMarkerSelect(Marker marker)
Called when a user taps a Marker on the map.
|
void |
onOrientationRight() |
void |
onOrientationUpdated(MeridianOrientation orientation)
Called when orientation of the device has been updated.
|
void |
onOrientationWrong() |
void |
onPause() |
void |
onPlacemarksLoadFinish()
Called 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.
|
void |
onResume() |
boolean |
onRouteStepIndexChange(int index)
Called when the route step has been updated
|
void |
onSaveInstanceState(android.os.Bundle outState) |
protected void |
onSourceResult(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.
|
void |
onStop() |
void |
onUseAccessiblePathsChange()
Called when the accessibility option has been toggled by the user.
|
void |
setDirectionsEventListener(MapView.DirectionsEventListener listener)
Set the DirectionsEventListener for this MapFragment.
|
void |
setMapEventListener(MapView.MapEventListener listener)
Set the MapEventListener for this MapFragment.
|
void |
setMapOptions(MapOptions options)
Set current map options.
|
void |
setMarkerEventListener(MapView.MarkerEventListener listener)
Set the MarkerEventListener for this MapFragment.
|
void |
startDirections(DirectionsDestination destination)
Start directions to the given placemark.
|
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, 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, onRequestPermissionsResult, onStart, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, requireActivity, requireContext, requireFragmentManager, requireHost, 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, unregisterForContextMenupublic MapOptions getMapOptions()
Gets a copy of the current MapOptions, defaulting to the MapView options if none are set on this fragment or the default ones if a MapView was not initialized yet. Changing the properties of the returned MapOptions will have no effect. To change the MapOptions for this MapFragment, call setMapOptions.
public void setMapOptions(MapOptions options)
Set current map options. These will be applied to our owned MapView instance either immediately if it exists, or automatically when created.
public MapView getMapView()
Gets our owned MapView if created, otherwise null. You may call methods and set properties on the returned view.
public void setMarkerEventListener(MapView.MarkerEventListener listener)
Set the MarkerEventListener for this MapFragment.
public void setDirectionsEventListener(MapView.DirectionsEventListener listener)
Set the DirectionsEventListener for this MapFragment.
public void setMapEventListener(MapView.MapEventListener listener)
Set the MapEventListener for this MapFragment.
public void onCreate(android.os.Bundle savedInstanceState)
onCreate in class androidx.fragment.app.Fragmentpublic void onSaveInstanceState(@NonNull
android.os.Bundle outState)
onSaveInstanceState in class androidx.fragment.app.Fragmentpublic android.view.View onCreateView(@NonNull
android.view.LayoutInflater inflater,
@Nullable
android.view.ViewGroup container,
@Nullable
android.os.Bundle savedInstanceState)
onCreateView in class androidx.fragment.app.Fragmentpublic void onResume()
onResume in class androidx.fragment.app.Fragmentpublic void onPause()
onPause in class androidx.fragment.app.Fragmentpublic void onStop()
onStop in class androidx.fragment.app.Fragmentpublic void onDestroy()
onDestroy in class androidx.fragment.app.Fragmentpublic void startDirections(DirectionsDestination destination)
Start directions to the given placemark.
public void onActivityResult(int requestCode,
int resultCode,
android.content.Intent data)
onActivityResult in class androidx.fragment.app.Fragmentprotected void onSourceResult(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. Make sure to call super or the directions request will be canceled.
public boolean onMarkerSelect(Marker marker)
MapView.MarkerEventListenerCalled when a user taps a Marker on the map. `
onMarkerSelect in interface MapView.MarkerEventListenermarker - An instance of the marker that was tapped.true to indicate that the event has been handled, false to allow the default action to take place.public boolean onMarkerDeselect(Marker marker)
MapView.MarkerEventListenerCalled when a user taps somewhere on the map deselecting a marker. `
onMarkerDeselect in interface MapView.MarkerEventListenermarker - An instance of the marker that was previously selected.true to indicate that the event has been handled, false to allow the default action to take place.public Marker markerForPlacemark(Placemark placemark)
MapView.MarkerEventListenerThis method is an opportunity to supply your own Marker instance for a given Placemark. You can use this to completely customize the look of placemarks on the map. The default implementation returns null.
markerForPlacemark in interface MapView.MarkerEventListenerplacemark - The placemark that is requesting a Marker for displaying on the mapMarker subclass, or null to request that MapView create a default Marker.public Marker markerForSelectedMarker(Marker markerToSelect)
MapView.MarkerEventListenerThis method is an opportunity to supply your own selected Marker instance for a given Marker. You can use this to completely customize the look of selected placemarks on the map. The default implementation returns null.
markerForSelectedMarker in interface MapView.MarkerEventListenermarkerToSelect - The Marker that is being selected.Marker subclass, or null to request that MapView create a default Marker.public boolean onCalloutClick(Marker marker)
MapView.MarkerEventListenerCalled when the callout is tapped.
onCalloutClick in interface MapView.MarkerEventListenermarker - An instance of the marker that was active when the callout was tapped.true to indicate that the event has been handled, false to allow the default action to take place.public void onMapLoadStart()
MapView.MapEventListenerCalled when initial loading of a map starts, this is called before any web request or graphics related loading happens.
onMapLoadStart in interface MapView.MapEventListenerpublic void onMapLoadFinish()
MapView.MapEventListenerCalled after loading of the map image is complete. It has not been rendered at this point.
onMapLoadFinish in interface MapView.MapEventListenerpublic void onPlacemarksLoadFinish()
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.
onPlacemarksLoadFinish in interface MapView.MapEventListenerpublic void onMapRenderFinish()
MapView.MapEventListenerCalled after the map and placemarks have been loaded and rendered. Changing any markers should be avoided.
onMapRenderFinish in interface MapView.MapEventListenerpublic void onMapLoadFail(java.lang.Throwable tr)
MapView.MapEventListenerCalled when there has been an error retrieving the map from the internet or parsing the map that was retrieved.
onMapLoadFail in interface MapView.MapEventListenerpublic void onMapTransformChange(android.graphics.Matrix transform)
MapView.MapEventListenerCalled when screen to map transform for this map changes.
onMapTransformChange in interface MapView.MapEventListenerpublic void onLocationUpdated(MeridianLocation location)
MapView.MapEventListenerCalled when the Location has updated for this map.
onLocationUpdated in interface MapView.MapEventListenerpublic void onOrientationUpdated(MeridianOrientation orientation)
MapView.MapEventListenerCalled when orientation of the device has been updated.
onOrientationUpdated in interface MapView.MapEventListenerpublic boolean onLocationButtonClick()
MapView.MapEventListenerCalled when the user taps the location button.
onLocationButtonClick in interface MapView.MapEventListenerpublic void onDirectionsReroute()
MapView.DirectionsEventListenerCalled when our directions need to reroute
onDirectionsReroute in interface MapView.DirectionsEventListenerpublic boolean onDirectionsClick(Marker marker)
MapView.DirectionsEventListenerCalled when the directions action of the marker callout view is tapped.
onDirectionsClick in interface MapView.DirectionsEventListenermarker - An instance of the marker that was active when the callout was tapped.true to indicate that the event has been handled, false to allow the default action to take place.public boolean onDirectionsStart()
MapView.DirectionsEventListenerCalled when the directions are calculated
onDirectionsStart in interface MapView.DirectionsEventListenertrue to indicate that the event has been handled, false to allow the default action to take place.public boolean onRouteStepIndexChange(int index)
MapView.DirectionsEventListenerCalled when the route step has been updated
onRouteStepIndexChange in interface MapView.DirectionsEventListenerindex - The index of the updated step.true to indicate that the event has been handled, false to allow the default action to take place.public boolean onDirectionsClosed()
MapView.DirectionsEventListenerCalled when the user exits directions
onDirectionsClosed in interface MapView.DirectionsEventListenertrue to indicate that the event has been handled, false to allow the default action to take place.public boolean onDirectionsError(java.lang.Throwable tr)
MapView.DirectionsEventListenerCalled when there has been an error getting directions
onDirectionsError in interface MapView.DirectionsEventListenertrue to indicate that the event has been handled, false to allow the default action to take place.public void onUseAccessiblePathsChange()
MapView.DirectionsEventListenerCalled when the accessibility option has been toggled by the user.
onUseAccessiblePathsChange in interface MapView.DirectionsEventListenerpublic void onOrientationRight()
onOrientationRight in interface OrientationDetector.Listenerpublic void onOrientationWrong()
onOrientationWrong in interface OrientationDetector.Listener