Class MapViewPosition

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void animateTo​(org.mapsforge.core.model.LatLong latLong)
      Animate the map towards the given position.
      boolean animationInProgress()  
      void destroy()
      Destroys the class.
      org.mapsforge.core.model.LatLong getCenter()
      Returns the current center position of the map.
      org.mapsforge.core.model.BoundingBox getMapLimit()  
      org.mapsforge.core.model.MapPosition getMapPosition()
      Returns a newly instantiated object representing the current position and zoomlevel.
      org.mapsforge.core.model.LatLong getPivot()
      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.
      double getScaleFactor()
      Gets the current scale factor.
      byte getZoomLevel()  
      byte getZoomLevelMax()  
      byte getZoomLevelMin()  
      void init​(PreferencesFacade preferencesFacade)
      Initializes the class.
      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 save​(PreferencesFacade preferencesFacade)
      Saves the current state.
      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 setPivot​(org.mapsforge.core.model.LatLong pivot)
      The pivot point is the point the map is scaled around when zooming.
      void setScaleFactor​(double scaleFactor)
      Sets the new scale factor to be applied.
      void setScaleFactorAdjustment​(double adjustment)  
      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 zoomIn()
      Increases the current zoom level by one if possible.
      void zoomIn​(boolean animated)
      Increases the current zoom level by one if possible.
      void zoomOut()
      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 java.lang.Object

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

      • MapViewPosition

        public MapViewPosition​(DisplayModel displayModel)
    • Method Detail

      • animateTo

        public void animateTo​(org.mapsforge.core.model.LatLong latLong)
        Animate the map towards the given position.
        Specified by:
        animateTo in interface IMapViewPosition
      • animationInProgress

        public boolean animationInProgress()
        Specified by:
        animationInProgress in interface IMapViewPosition
        Returns:
        true if animation is in progress or animation is in the queue for being processed.
      • getCenter

        public org.mapsforge.core.model.LatLong getCenter()
        Description copied from interface: IMapViewPosition
        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.
        Specified by:
        getCenter in interface IMapViewPosition
        Returns:
        the current center position of the map.
      • getMapLimit

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

        public org.mapsforge.core.model.MapPosition getMapPosition()
        Description copied from interface: IMapViewPosition
        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.
        Specified by:
        getMapPosition in interface IMapViewPosition
        Returns:
        the current center position and zoom level of the map.
      • getPivot

        public org.mapsforge.core.model.LatLong getPivot()
        The pivot point is the point the map zooms around.
        Specified by:
        getPivot in interface IMapViewPosition
        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.
      • getScaleFactor

        public double getScaleFactor()
        Description copied from interface: IMapViewPosition
        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.

        Specified by:
        getScaleFactor in interface IMapViewPosition
      • getZoomLevel

        public byte getZoomLevel()
        Specified by:
        getZoomLevel in interface IMapViewPosition
        Returns:
        the current zoom level of the map.
      • moveCenter

        public void moveCenter​(double moveHorizontal,
                               double moveVertical)
        Animates the center position of the map by the given amount of pixels.
        Specified by:
        moveCenter in interface IMapViewPosition
        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.
        Specified by:
        moveCenter in interface IMapViewPosition
        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.
        Specified by:
        moveCenterAndZoom in interface IMapViewPosition
        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.
        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.
        Specified by:
        setCenter in interface IMapViewPosition
      • setMapLimit

        public void setMapLimit​(org.mapsforge.core.model.BoundingBox mapLimit)
        Sets the new limit of the map (might be null).
        Specified by:
        setMapLimit in interface IMapViewPosition
      • setMapPosition

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

        Note: The default zoom level changes are animated.

        Specified by:
        setMapPosition in interface IMapViewPosition
      • setMapPosition

        public void setMapPosition​(org.mapsforge.core.model.MapPosition mapPosition,
                                   boolean animated)
        Sets the new center position and zoom level of the map.
        Specified by:
        setMapPosition in interface IMapViewPosition
      • 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.
        Specified by:
        setPivot in interface IMapViewPosition
        Parameters:
        pivot - lat/long of pivot point, null for map center
      • setScaleFactor

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

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

        Note: The default zoom level changes are animated.

        Specified by:
        setZoomLevel in interface IMapViewPosition
        Parameters:
        zoomLevel - new zoom level.
        Throws:
        java.lang.IllegalArgumentException - if the zoom level is negative.
      • setZoomLevel

        public void setZoomLevel​(byte zoomLevel,
                                 boolean animated)
        Sets the new zoom level of the map
        Specified by:
        setZoomLevel in interface IMapViewPosition
        Parameters:
        zoomLevel - desired zoom level
        animated - true if the transition should be animated, false otherwise
        Throws:
        java.lang.IllegalArgumentException - if the zoom level is negative.
      • 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.

        Specified by:
        zoom in interface IMapViewPosition
      • 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.

        Note: The default zoom level changes are animated.

        Specified by:
        zoomIn in interface IMapViewPosition
      • zoomIn

        public void zoomIn​(boolean animated)
        Increases the current zoom level by one if possible.
        Specified by:
        zoomIn in interface IMapViewPosition
      • zoomOut

        public void zoomOut()
        Decreases the current zoom level by one if possible.

        Note: The default zoom level changes are animated.

        Specified by:
        zoomOut in interface IMapViewPosition
      • zoomOut

        public void zoomOut​(boolean animated)
        Decreases the current zoom level by one if possible.
        Specified by:
        zoomOut in interface IMapViewPosition