public class MapFragment extends android.support.v4.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 |
Modifier | Constructor and Description |
---|---|
protected |
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. |
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) |
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, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroy, onDestroyOptionsMenu, onDestroyView, onDetach, onGetLayoutInflater, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPictureInPictureModeChanged, onPrepareOptionsMenu, onRequestPermissionsResult, onStart, onViewCreated, onViewStateRestored, postponeEnterTransition, registerForContextMenu, requestPermissions, 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
public 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 android.support.v4.app.Fragment
public void onSaveInstanceState(android.os.Bundle outState)
onSaveInstanceState
in class android.support.v4.app.Fragment
public android.view.View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
onCreateView
in class android.support.v4.app.Fragment
public void onResume()
onResume
in class android.support.v4.app.Fragment
public void onPause()
onPause
in class android.support.v4.app.Fragment
public void onStop()
onStop
in class android.support.v4.app.Fragment
public void startDirections(DirectionsDestination destination)
Start directions to the given placemark.
public void onActivityResult(int requestCode, int resultCode, android.content.Intent data)
onActivityResult
in class android.support.v4.app.Fragment
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. Make sure to call super or the directions request will be canceled.
public boolean onMarkerSelect(Marker marker)
MapView.MarkerEventListener
Called when a user taps a Marker on the map. `
onMarkerSelect
in interface MapView.MarkerEventListener
marker
- 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.MarkerEventListener
Called when a user taps somewhere on the map deselecting a marker. `
onMarkerDeselect
in interface MapView.MarkerEventListener
marker
- 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.MarkerEventListener
This 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.MarkerEventListener
placemark
- The placemark that is requesting a Marker
for displaying on the mapMarker
subclass, or null to request that MapView create a default Marker
.public boolean onCalloutClick(Marker marker)
MapView.MarkerEventListener
Called when the callout is tapped.
onCalloutClick
in interface MapView.MarkerEventListener
marker
- 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.MapEventListener
Called when initial loading of a map starts, this is called before any web request or graphics related loading happens.
onMapLoadStart
in interface MapView.MapEventListener
public void onMapLoadFinish()
MapView.MapEventListener
Called after loading of the map image is complete. It has not been rendered at this point.
onMapLoadFinish
in interface MapView.MapEventListener
public void onPlacemarksLoadFinish()
MapView.MapEventListener
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.
onPlacemarksLoadFinish
in interface MapView.MapEventListener
public void onMapRenderFinish()
MapView.MapEventListener
Called after the map and placemarks have been loaded and rendered. Changing any markers should be avoided.
onMapRenderFinish
in interface MapView.MapEventListener
public void onMapLoadFail(java.lang.Throwable tr)
MapView.MapEventListener
Called when there has been an error retrieving the map from the internet or parsing the map that was retrieved.
onMapLoadFail
in interface MapView.MapEventListener
public void onMapTransformChange(android.graphics.Matrix transform)
MapView.MapEventListener
Called when screen to map transform for this map changes.
onMapTransformChange
in interface MapView.MapEventListener
public void onLocationUpdated(MeridianLocation location)
MapView.MapEventListener
Called when the Location has updated for this map.
onLocationUpdated
in interface MapView.MapEventListener
public void onOrientationUpdated(MeridianOrientation orientation)
MapView.MapEventListener
Called when orientation of the device has been updated.
onOrientationUpdated
in interface MapView.MapEventListener
public boolean onLocationButtonClick()
MapView.MapEventListener
Called when the user taps the location button.
onLocationButtonClick
in interface MapView.MapEventListener
public void onDirectionsReroute()
MapView.DirectionsEventListener
Called when our directions need to reroute
onDirectionsReroute
in interface MapView.DirectionsEventListener
public boolean onDirectionsClick(Marker marker)
MapView.DirectionsEventListener
Called when the directions action of the marker callout view is tapped.
onDirectionsClick
in interface MapView.DirectionsEventListener
marker
- 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.DirectionsEventListener
Called when the directions are calculated
onDirectionsStart
in interface MapView.DirectionsEventListener
true
to indicate that the event has been handled, false
to allow the default action to take place.public boolean onRouteStepIndexChange(int index)
MapView.DirectionsEventListener
Called when the route step has been updated
onRouteStepIndexChange
in interface MapView.DirectionsEventListener
index
- 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.DirectionsEventListener
Called when the user exits directions
onDirectionsClosed
in interface MapView.DirectionsEventListener
true
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.DirectionsEventListener
Called when there has been an error getting directions
onDirectionsError
in interface MapView.DirectionsEventListener
true
to indicate that the event has been handled, false
to allow the default action to take place.public void onUseAccessiblePathsChange()
MapView.DirectionsEventListener
Called when the accessibility option has been toggled by the user.
onUseAccessiblePathsChange
in interface MapView.DirectionsEventListener
public void onOrientationRight()
onOrientationRight
in interface OrientationDetector.Listener
public void onOrientationWrong()
onOrientationWrong
in interface OrientationDetector.Listener