Package 

Class CompassOverlay

  • All Implemented Interfaces:
    org.osmdroid.views.overlay.IOverlayMenuProvider , org.osmdroid.views.overlay.compass.IOrientationConsumer , org.osmdroid.views.util.constants.OverlayConstants

    
    public class CompassOverlay
    extends Overlay implements IOverlayMenuProvider, IOrientationConsumer
                        

    Note: the compass overlay causes issues on API 8 devices. See https://github.com/osmdroid/osmdroid/issues/218

    Note: this class can cause issues if you're also relying on addOnFirstLayoutListener If you happen to be using both, see Issue 324

    • Method Detail

      • onPause

         void onPause()

        Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github.com/osmdroid/osmdroid/issues/806

      • onResume

         void onResume()

        Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github.com/osmdroid/osmdroid/issues/806

      • onDetach

         void onDetach(MapView mapView)

        Override to perform clean up of resources before shutdown. By default does nothing.

      • setCompassInCenter

         void setCompassInCenter(boolean b)

        Put the compass in the center of the map regardless of the supplied coordinates.

      • setAzimuthOffset

         void setAzimuthOffset(float f)

        An offset added to the bearing when drawing the compass.eg. to account for local magnetic declination to indicate true north

      • isOptionsMenuEnabled

         boolean isOptionsMenuEnabled()

        Can be used to signal to external callers that this Overlay should not be used for providingoption menu items.

      • enableCompass

         boolean enableCompass()

        Enable receiving orientation updates from the provided IOrientationProvider and show acompass on the map. You will likely want to call enableCompass() from your Activity'sActivity.onResume() method, to enable the features of this overlay. Remember to call thecorresponding disableCompass() in your Activity's Activity.onPause() method to turn offupdates when in the background.

      • disableCompass

         void disableCompass()

        Disable orientation updates.

        Note the behavior has changed since v6.0.0. This method no longer releasesreferences to the orientation provider. Instead, that happens in the onDetachedmethod.

      • isCompassEnabled

         boolean isCompassEnabled()

        If enabled, the map is receiving orientation updates and drawing your location on the map.

      • setPointerMode

         void setPointerMode(boolean usePointArrow)

        The compass can operate in two modes.

        • false - a conventional compass needle pointing north/south (false, default)
        • true - a pointer arrow that indicates the device's real world orientation on the map (true)
        A different picture is used in each case.
        Parameters:
        usePointArrow - if true the pointer arrow is used, otherwise a compass rose is used