Class MapViewPosition

java.lang.Object
org.mapsforge.map.model.common.Observable
org.mapsforge.map.model.MapViewPosition
All Implemented Interfaces:
ObservableInterface

public class MapViewPosition extends Observable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    animateTo(org.mapsforge.core.model.LatLong latLong)
    Animates the map towards the given position (move).
    boolean
     
    void
    Destroys the class.
    org.mapsforge.core.model.LatLong
    Returns the current center position of the map.
    org.mapsforge.core.model.BoundingBox
     
    org.mapsforge.core.model.MapPosition
    Returns a newly instantiated object representing the current position and zoomlevel.
    float
     
    float
     
    org.mapsforge.core.model.LatLong
    The pivot point is the point the map zooms around.
    org.mapsforge.core.model.Point
    getPivotXY(byte zoomLevel)
    The pivot point is the point the map zooms around.
    org.mapsforge.core.model.Rotation
     
    double
    Gets the current scale factor.
    double
     
    byte
     
    byte
     
    byte
     
    void
    moveCenter(double moveHorizontal, double moveVertical)
    Animates the center position of the map by the given amount of pixels.
    void
    moveCenter(double moveHorizontal, double moveVertical, boolean animated)
    Moves the center position of the map by the given amount of pixels.
    void
    moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff)
    Animates the center position of the map by the given amount of pixels.
    void
    moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated)
    Moves the center position of the map by the given amount of pixels.
    void
    setCenter(org.mapsforge.core.model.LatLong latLong)
    Sets the new center position of the map.
    void
    setMapLimit(org.mapsforge.core.model.BoundingBox mapLimit)
    Sets the new limit of the map (might be null).
    void
    setMapPosition(org.mapsforge.core.model.MapPosition mapPosition)
    Sets the new center position and zoom level of the map.
    void
    setMapPosition(org.mapsforge.core.model.MapPosition mapPosition, boolean animated)
    Sets the new center position and zoom level of the map.
    void
    setMapViewCenterX(float mapViewCenterX)
     
    void
    setMapViewCenterY(float mapViewCenterY)
     
    void
    setPivot(org.mapsforge.core.model.LatLong pivot)
    The pivot point is the point the map is scaled around when zooming.
    void
    setRotation(org.mapsforge.core.model.Rotation rotation)
    Sets the new rotation of the map.
    void
    setScaleFactor(double scaleFactor)
    Sets the new scale factor to be applied.
    void
    setScaleFactorAdjustment(double adjustment)
     
    void
    setZoom(double zoom)
    Sets the new zoom of the map.
    void
    setZoom(double zoom, boolean animated)
    Sets the new zoom of the map.
    void
    setZoomLevel(byte zoomLevel)
    Sets the new zoom level of the map.
    void
    setZoomLevel(byte zoomLevel, boolean animated)
    Sets the new zoom level of the map.
    void
    setZoomLevelMax(byte zoomLevelMax)
     
    void
    setZoomLevelMin(byte zoomLevelMin)
     
    void
    zoom(byte zoomLevelDiff)
    Changes the current zoom level by the given value if possible.
    void
    zoom(byte zoomLevelDiff, boolean animated)
    Changes the current zoom level by the given value if possible.
    void
    Increases the current zoom level by one if possible.
    void
    zoomIn(boolean animated)
    Increases the current zoom level by one if possible.
    void
    Decreases the current zoom level by one if possible.
    void
    zoomOut(boolean animated)
    Decreases the current zoom level by one if possible.

    Methods inherited from class org.mapsforge.map.model.common.Observable

    addObserver, notifyObservers, removeObserver

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MapViewPosition

      public MapViewPosition(DisplayModel displayModel)
  • Method Details

    • animateTo

      public void animateTo(org.mapsforge.core.model.LatLong latLong)
      Animates the map towards the given position (move). The given position will be at the center of the screen after the animation. The position is assured to be within the map limit.
    • animationInProgress

      public boolean animationInProgress()
      Returns:
      true if animation is in progress or animation is in the queue for being processed.
    • destroy

      public void destroy()
      Destroys the class.
    • getCenter

      public org.mapsforge.core.model.LatLong getCenter()
      Returns the current center position of the map. The position may change rapidly if an animation is in progress. If you are using animation consider keeping the positions and zoom factors in your code and not using this getter.
      Returns:
      the current center position of the map.
    • getMapLimit

      public org.mapsforge.core.model.BoundingBox getMapLimit()
      Returns:
      the current limit of the map (might be null).
    • getMapPosition

      public org.mapsforge.core.model.MapPosition getMapPosition()
      Returns a newly instantiated object representing the current position and zoomlevel. Note that the position or zoomlevel may change rapidly if an animation is in progress.
      Returns:
      the current center position and zoom level of the map.
    • getMapViewCenterX

      public float getMapViewCenterX()
    • getMapViewCenterY

      public float getMapViewCenterY()
    • getPivot

      public org.mapsforge.core.model.LatLong getPivot()
      The pivot point is the point the map zooms around.
      Returns:
      the lat/long coordinates of the map pivot point if set or null otherwise.
    • getPivotXY

      public org.mapsforge.core.model.Point getPivotXY(byte zoomLevel)
      The pivot point is the point the map zooms around. If the map zooms around its center null is returned, otherwise the zoom-specific x/y pixel coordinates for the MercatorProjection (note: not the x/y coordinates for the map view or the frame buffer, the MapViewPosition knows nothing about them).
      Parameters:
      zoomLevel - the zoomlevel to compute the x/y coordinates for
      Returns:
      the x/y coordinates of the map pivot point if set or null otherwise.
    • getRotation

      public org.mapsforge.core.model.Rotation getRotation()
    • getScaleFactor

      public double getScaleFactor()
      Gets the current scale factor. The scale factor is normally 2^zoomLevel but it may differ if in between a zoom-animation or in between a pinch-to-zoom process.

      Needed by mapsforge core classes.

    • getZoom

      public double getZoom()
      Returns:
      the current zoom of the map.
    • getZoomLevel

      public byte getZoomLevel()
      Returns:
      the current zoom level of the map.
    • getZoomLevelMax

      public byte getZoomLevelMax()
    • getZoomLevelMin

      public byte getZoomLevelMin()
    • moveCenter

      public void moveCenter(double moveHorizontal, double moveVertical)
      Animates the center position of the map by the given amount of pixels.

      Used by TouchGestureHandler.

      Parameters:
      moveHorizontal - the amount of pixels to move this MapViewPosition horizontally.
      moveVertical - the amount of pixels to move this MapViewPosition vertically.
    • moveCenter

      public void moveCenter(double moveHorizontal, double moveVertical, boolean animated)
      Moves the center position of the map by the given amount of pixels.

      Used by TouchGestureHandler.

      Parameters:
      moveHorizontal - the amount of pixels to move this MapViewPosition horizontally.
      moveVertical - the amount of pixels to move this MapViewPosition vertically.
      animated - whether the move should be animated.
    • moveCenterAndZoom

      public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff)
      Animates the center position of the map by the given amount of pixels.

      This method is used by the TouchGestureHandler to perform a zoom on double-tap action.

      Parameters:
      moveHorizontal - the amount of pixels to move this MapViewPosition horizontally.
      moveVertical - the amount of pixels to move this MapViewPosition vertically.
      zoomLevelDiff - the difference in desired zoom level.
    • moveCenterAndZoom

      public void moveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated)
      Moves the center position of the map by the given amount of pixels.

      This method is used by the TouchGestureHandler to perform a zoom on double-tap action.

      Parameters:
      moveHorizontal - the amount of pixels to move this MapViewPosition horizontally.
      moveVertical - the amount of pixels to move this MapViewPosition vertically.
      zoomLevelDiff - the difference in desired zoom level.
      animated - whether the move should be animated.
    • setCenter

      public void setCenter(org.mapsforge.core.model.LatLong latLong)
      Sets the new center position of the map.

      This is NOT animated.

    • setMapLimit

      public void setMapLimit(org.mapsforge.core.model.BoundingBox mapLimit)
      Sets the new limit of the map (might be null).
    • setMapPosition

      public void setMapPosition(org.mapsforge.core.model.MapPosition mapPosition)
      Sets the new center position and zoom level of the map.

      The default zoom level changes are animated.

    • setMapPosition

      public void setMapPosition(org.mapsforge.core.model.MapPosition mapPosition, boolean animated)
      Sets the new center position and zoom level of the map.
    • setMapViewCenterX

      public void setMapViewCenterX(float mapViewCenterX)
    • setMapViewCenterY

      public void setMapViewCenterY(float mapViewCenterY)
    • setPivot

      public void setPivot(org.mapsforge.core.model.LatLong pivot)
      The pivot point is the point the map is scaled around when zooming. In normal mode the pivot point is whatever the view center is (this is indicated by setting the pivot to null), but when hand-zooming the pivot point can be any point on the map. It is stored as lat/long and retrieved as an x/y coordinate depending on the current zoom level.
      Parameters:
      pivot - lat/long of pivot point, null for map center
    • setRotation

      public void setRotation(org.mapsforge.core.model.Rotation rotation)
      Sets the new rotation of the map.
    • setScaleFactor

      public void setScaleFactor(double scaleFactor)
      Sets the new scale factor to be applied.
    • setScaleFactorAdjustment

      public void setScaleFactorAdjustment(double adjustment)
    • setZoom

      public void setZoom(double zoom)
      Sets the new zoom of the map.

      Animation is NOT used.

      Implemented for external use, NOT used internally.

      Parameters:
      zoom - new zoom.
      Throws:
      IllegalArgumentException - if the zoom is negative.
    • setZoom

      public void setZoom(double zoom, boolean animated)
      Sets the new zoom of the map.
      Parameters:
      zoom - desired zoom
      animated - true if the transition should be animated, false otherwise
      Throws:
      IllegalArgumentException - if the zoom is negative.
    • setZoomLevel

      public void setZoomLevel(byte zoomLevel)
      Sets the new zoom level of the map.

      Animation is NOT used.

      Implemented for external use, NOT used internally.

      Parameters:
      zoomLevel - new zoom level.
      Throws:
      IllegalArgumentException - if the zoom level is negative.
    • setZoomLevel

      public void setZoomLevel(byte zoomLevel, boolean animated)
      Sets the new zoom level of the map.
      Parameters:
      zoomLevel - desired zoom level
      animated - true if the transition should be animated, false otherwise
      Throws:
      IllegalArgumentException - if the zoom level is negative.
    • setZoomLevelMax

      public void setZoomLevelMax(byte zoomLevelMax)
    • setZoomLevelMin

      public void setZoomLevelMin(byte zoomLevelMin)
    • zoom

      public void zoom(byte zoomLevelDiff)
      Changes the current zoom level by the given value if possible.

      Note: The default zoom level changes are animated.

    • zoom

      public void zoom(byte zoomLevelDiff, boolean animated)
      Changes the current zoom level by the given value if possible.
    • zoomIn

      public void zoomIn()
      Increases the current zoom level by one if possible. Zooming is always around the center.

      The default zoom level changes are animated.

    • zoomIn

      public void zoomIn(boolean animated)
      Increases the current zoom level by one if possible. Zooming is always around the center.
    • zoomOut

      public void zoomOut()
      Decreases the current zoom level by one if possible. Zooming is always around the center.

      The default zoom level changes are animated.

    • zoomOut

      public void zoomOut(boolean animated)
      Decreases the current zoom level by one if possible. Zooming is always around the center.