Class MapFragment

java.lang.Object
SdkFragment
com.mapfactor.sdk.map.MapFragment

public class MapFragment extends SdkFragment
Map fragment. Use directly or via MapView.
Since:
1.0
  • Constructor Details

    • MapFragment

      public MapFragment()
  • Method Details

    • addOnMapReadyListener

      public void addOnMapReadyListener(@NonNull MapReadyListener listener)
      Add MapReadyListener
      Parameters:
      listener - map ready listener
      Since:
      1.0
    • removeOnMapReadyListener

      public void removeOnMapReadyListener(@NonNull MapReadyListener listener)
      Remove MapReadyListener
      Parameters:
      listener - map ready listener
      Since:
      4.9
    • addOnMapClickedListener

      public void addOnMapClickedListener(@NonNull MapClickedListener listener)
      Add MapClickedListener
      Parameters:
      listener - map clicked listener
      Since:
      4.9
    • removeOnMapClickedListener

      public void removeOnMapClickedListener(@NonNull MapClickedListener listener)
      Remove MapClickedListener
      Parameters:
      listener - map clicked listener
      Since:
      4.9
    • setMapMode

      public MapFragment.SetMapModeResult setMapMode(@NonNull MapFragment.MapMode mapMode)
      Change map mode
      Parameters:
      mapMode - new map mode
      Returns:
      success/failure
      Since:
      1.0
    • setMapCenter

      public boolean setMapCenter(@NonNull Coordinate mapCenterCoordinate)
      Center map to given coordinate. Can be called only when not navigating in 3D.
      Parameters:
      mapCenterCoordinate - coordinate to move map center to
      Returns:
      true on success, false when there is an ongoing 3D navigation
      Since:
      4.2
    • getMapCenter

      @NonNull public Coordinate getMapCenter()
      Get map center coordinate
      Returns:
      map center coordinate
      Since:
      4.2
    • setUseCompass

      public void setUseCompass(boolean useCompass)
      Enable/disable using compass in 2D when MapFragment.MapMode.ROTATE or MapFragment.MapMode.ROTATE_CENTER map mode is on. If compass is disabled, azimuth from GPS is used.
      Parameters:
      useCompass - true/false to use/not use compass for map rotation in 2D
      Since:
      4.8
    • isCompassUsed

      public boolean isCompassUsed()
      Test whether compass is used in 2D for MapFragment.MapMode.ROTATE and MapFragment.MapMode.ROTATE_CENTER map modes
      Returns:
      true/false when compass is/is not used
      Since:
      4.8
    • setHUDMode

      public void setHUDMode(@NonNull MapFragment.HudMode mode)
      Set Head-up display mode during navigation
      Parameters:
      mode - head-up mode to set
      Since:
      2.2
    • getHUDMode

      @NonNull public MapFragment.HudMode getHUDMode()
      Get current Head-up mode
      Returns:
      current Head-up mode
      Since:
      2.2
    • getMapControls

      @NonNull public MapControls getMapControls()
      Get Map controls module
      Returns:
      Map controls instance
      Since:
      1.0
    • showOnMap

      public void showOnMap(@NonNull SearchResult searchResult)
      Show search result on map
      Parameters:
      searchResult - result from Search engine to show on map
      Since:
      1.0
    • showOnMap

      public void showOnMap(@NonNull NavigationHistoryRoute navigationHistoryRoute, int routeColor, int lineWidth)
      Show navigation history route on map
      Parameters:
      navigationHistoryRoute - navigation history route to show on map
      routeColor - color to paint the route
      lineWidth - width of the line
      Since:
      3.9
    • showMessage

      public boolean showMessage(@NonNull String message)
      Show a message
      Parameters:
      message - text to show
      Returns:
      success/failure (may fail when the fragment is npt attached to an activity)
      Since:
      1.0