Package org.mapsforge.map.model
Class MapViewPosition
java.lang.Object
org.mapsforge.map.model.common.Observable
org.mapsforge.map.model.MapViewPosition
- All Implemented Interfaces:
ObservableInterface
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidanimateTo(org.mapsforge.core.model.LatLong latLong) Animates the map towards the given position (move).booleanvoiddestroy()Destroys the class.org.mapsforge.core.model.LatLongReturns the current center position of the map.org.mapsforge.core.model.BoundingBoxorg.mapsforge.core.model.MapPositionReturns a newly instantiated object representing the current position and zoomlevel.floatfloatorg.mapsforge.core.model.LatLonggetPivot()The pivot point is the point the map zooms around.org.mapsforge.core.model.PointgetPivotXY(byte zoomLevel) The pivot point is the point the map zooms around.org.mapsforge.core.model.RotationdoubleGets the current scale factor.doublegetZoom()bytebytebytevoidmoveCenter(double moveHorizontal, double moveVertical) Animates the center position of the map by the given amount of pixels.voidmoveCenter(double moveHorizontal, double moveVertical, boolean animated) Moves the center position of the map by the given amount of pixels.voidmoveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff) Animates the center position of the map by the given amount of pixels.voidmoveCenterAndZoom(double moveHorizontal, double moveVertical, byte zoomLevelDiff, boolean animated) Moves the center position of the map by the given amount of pixels.voidsetCenter(org.mapsforge.core.model.LatLong latLong) Sets the new center position of the map.voidsetMapLimit(org.mapsforge.core.model.BoundingBox mapLimit) Sets the new limit of the map (might be null).voidsetMapPosition(org.mapsforge.core.model.MapPosition mapPosition) Sets the new center position and zoom level of the map.voidsetMapPosition(org.mapsforge.core.model.MapPosition mapPosition, boolean animated) Sets the new center position and zoom level of the map.voidsetMapViewCenterX(float mapViewCenterX) voidsetMapViewCenterY(float mapViewCenterY) voidsetPivot(org.mapsforge.core.model.LatLong pivot) The pivot point is the point the map is scaled around when zooming.voidsetRotation(org.mapsforge.core.model.Rotation rotation) Sets the new rotation of the map.voidsetScaleFactor(double scaleFactor) Sets the new scale factor to be applied.voidsetScaleFactorAdjustment(double adjustment) voidsetZoom(double zoom) Sets the new zoom of the map.voidsetZoom(double zoom, boolean animated) Sets the new zoom of the map.voidsetZoomLevel(byte zoomLevel) Sets the new zoom level of the map.voidsetZoomLevel(byte zoomLevel, boolean animated) Sets the new zoom level of the map.voidsetZoomLevelMax(byte zoomLevelMax) voidsetZoomLevelMin(byte zoomLevelMin) voidzoom(byte zoomLevelDiff) Changes the current zoom level by the given value if possible.voidzoom(byte zoomLevelDiff, boolean animated) Changes the current zoom level by the given value if possible.voidzoomIn()Increases the current zoom level by one if possible.voidzoomIn(boolean animated) Increases the current zoom level by one if possible.voidzoomOut()Decreases the current zoom level by one if possible.voidzoomOut(boolean animated) Decreases the current zoom level by one if possible.Methods inherited from class org.mapsforge.map.model.common.Observable
addObserver, notifyObservers, removeObserver
-
Constructor Details
-
MapViewPosition
-
-
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 zoomanimated- 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 levelanimated- 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.
-