de.fhpotsdam.unfolding
Class UnfoldingMap

java.lang.Object
  extended by de.fhpotsdam.unfolding.UnfoldingMap
All Implemented Interfaces:
MapEventListener, java.util.EventListener
Direct Known Subclasses:
Map

public class UnfoldingMap
extends java.lang.Object
implements MapEventListener

An interactive map. Uses the MapDisplay, and handles hit test, active status, as well as all interactions such as panning, zooming, and rotating (with or without tweening). Acts as facade for the map interactions, e.g. using innerScale for zooming, and outerRotate for rotating.


Field Summary
protected  boolean active
          Indicates whether this map is currently active.
static boolean DEFAULT_TWEENING
          UnfoldingMap do not use tweened animation by default.
static int DEFAULT_ZOOM_LEVEL
          The default zoom level of an UnfoldingMap shows the whole world.
static java.lang.String GREETING_MESSAGE
           
protected  java.lang.String id
          The ID of this map.
static org.apache.log4j.Logger log
           
 AbstractMapDisplay mapDisplay
          The display of the map.
protected  float maxPanningDistance
          The maximum distance to the center location of the restricted pan area.
 float maxScale
          The maximum scale.
 float minScale
          The minimum scale.
protected  processing.core.PApplet p
          The Processing applet.
static Location PRIME_MERIDIAN_EQUATOR_LOCATION
           
protected  Location restrictedPanLocation
          The center location of the restricted pan area.
static float SCALE_DELTA_IN
           
static float SCALE_DELTA_OUT
           
 Integrator scaleIntegrator
          Tweens the scale.
static int TILE_HEIGHT
          The default tile height of 256px.
static int TILE_WIDTH
          The default tile width of 256px.
 
Constructor Summary
UnfoldingMap(processing.core.PApplet p)
          Creates a new full canvas map with a generated ID.
UnfoldingMap(processing.core.PApplet p, AbstractMapProvider provider)
          Creates a new full canvas map with tiles from the given provider.
UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height)
          Creates a new map with specific position and dimension.
UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height, AbstractMapProvider provider)
          Creates a new map with specific position and dimension.
UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height, AbstractMapProvider provider, java.lang.String renderer)
           
UnfoldingMap(processing.core.PApplet p, float x, float y, float width, float height, java.lang.String renderer)
           
UnfoldingMap(processing.core.PApplet p, java.lang.String id)
          Creates a new full canvas map with the given ID.
UnfoldingMap(processing.core.PApplet p, java.lang.String id, AbstractMapProvider provider)
          Creates a new full canvas map with given ID, and with tiles from the given provider.
UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height)
          Creates a new map with specific position and dimension.
UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useDistortion)
           
UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useMask, boolean useDistortion, AbstractMapProvider provider)
           
UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useMask, boolean useDistortion, AbstractMapProvider provider, java.lang.String renderer)
          Creates a new map with specific position and dimension.
UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, boolean useDistortion, java.lang.String renderer)
           
UnfoldingMap(processing.core.PApplet p, java.lang.String id, float x, float y, float width, float height, java.lang.String renderer)
           
 
Method Summary
protected  void addInnerOffset(float dx, float dy)
           
 void addMarker(Marker marker)
          Adds a marker to the map.
 void addMarkerManager(MarkerManager<Marker> markerManager)
          Add a MarkerManager to the map.
 void addMarkers(java.util.List<Marker> markers)
          Adds multiple markers to the map.
 void addMarkers(Marker... marker)
          Adds one or multiple markers to the map.
protected  void addOffset(float dx, float dy)
          Moves the offset of the map.
 boolean allTilesLoaded()
          Check whether all currently visible tiles have been loaded.
 void draw()
          Updates and draws the map.
protected static java.lang.String generateId()
           
 Location getBottomRightBorder()
          Returns the bottom right corner of the visible map.
 Location getCenter()
          Returns the center location of the visible map.
 MarkerManager<Marker> getDefaultMarkerManager()
          Returns the default MarkerManager, i.e.
 Marker getFirstHitMarker(float checkX, float checkY)
          Checks whether a marker got hit with the given screen coordinates.
 float getHeight()
          Returns the height of this map.
 java.util.List<Marker> getHitMarker(float checkX, float checkY)
          Deprecated. Use getHitMarkers(float, float) instead.
 java.util.List<Marker> getHitMarkers(float checkX, float checkY)
          Checks whether multiple markers got hit with the given screen coordinates.
 java.lang.String getId()
          Returns the ID of this map.
 MarkerManager<Marker> getLastMarkerManager()
          Returns the lastly added MarkerManager.
 Location getLocation(float x, float y)
          Converts a position on the screen to a geographic location.
 Location getLocation(ScreenPosition screenPosition)
          Converts a position on the screen to a geographic location.
 Location getLocationFromScreenPosition(float x, float y)
          Deprecated. 
 MarkerManager<Marker> getMarkerManager(int index)
          Returns the MarkerManager at the given index position.
 java.util.List<MarkerManager<Marker>> getMarkerManagerList()
           
 java.util.List<Marker> getMarkers()
          Gets markers of the map.
static float getScaleFromZoom(float zoom)
          Converts zoom to scale.
 ScreenPosition getScreenPosition(Location location)
          Converts the geographic location to a position on the screen.
 float[] getScreenPositionFromLocation(Location location)
          Deprecated. 
 Location getTopLeftBorder()
          Returns the top left corner of the visible map.
 float getWidth()
          Returns the width of this map.
 float getZoom()
          Gets the current zoom of the map.
static float getZoomFromScale(double scale)
          Converts scale to zoom.
 int getZoomLevel()
          Gets the current zoom level of the map.
static int getZoomLevelFromScale(double scale)
          Converts scale to zoom level.
 void innerRotate(float angle)
          Deprecated. Use rotate(float) instead.
 void innerScale(float scale)
           
 boolean isActive()
          Indicates whether this map is currently active.
 boolean isHit(float checkX, float checkY)
          Checks whether the given screen coordinates are on this Map.
 boolean isHit(ScreenPosition screenPosition)
          Checks whether the given screen coordinates are on this Map.
 boolean isTweening()
          Indicates whether the map currently animates between different states.
 void move(float x, float y)
          Moves the map to the given position.
 void move(ScreenPosition screenPosition)
          Moves the map to the given ScreenPosition.
 void moveBy(float dx, float dy)
          Moves the map by the given screen coordinates.
 void onManipulation(MapEvent mapEvent)
          Internal method to listens to mapDisplay events.
 void outerRotate(float angle)
          Rotates the map container.
protected  void outerScale(float scale)
           
 void pan(float x1, float y1, float x2, float y2)
          Pans from point1 to point 2, given in screen coordinates.
 void pan(Location fromLocation, Location toLocation)
          Pans from one location to another one.
 void pan(ScreenPosition from, ScreenPosition to)
          Pans between two ScreenPosition.
 void panBy(float dx, float dy)
          Pans by distance in screen coordinates.
 void panDown()
          Pans one tile down.
 void panLeft()
          Pans one tile to the left.
protected  void panObjectPositionToObjectCenter(float x, float y)
          Pans object center to given object position.
 void panRight()
          Pans one tile to the right.
 void panTo(float x, float y)
          Pans to the given position.
 void panTo(Location location)
          Pans to the given Location.
 void panTo(ScreenPosition screenPosition)
          Pans to the given screen position.
 void panUp()
          Pans one tile up.
protected  void prepareMapChangedMethod()
          Internal method to call listening methods in your application for map changes.
 void removeMarkerManager(int i)
           
 void removeMarkerManager(MarkerManager<Marker> markerManager)
           
 void resetPanningRestriction()
          Frees this map from any panning restriction.
 void rotate(float angle)
          Rotates the map by given angle.
 void rotateTo(float angle)
          Rotates the map to the given angle, that is it is rotated to the target angle.
 void setActive(boolean active)
          Sets the active flag of this map.
 void setBackgroundColor(java.lang.Integer bgColor)
          Sets the background color of this map.
protected  void setInnerOffset(float x, float y)
           
protected  void setInnerRotate(float angle)
           
 void setInnerScale(float scale)
           
protected  void setOffset(float x, float y)
          Sets the offset of the map.
protected  void setOuterRotate(float angle)
           
protected  void setOuterScale(float scale)
           
 void setPanningRestriction(Location location, float maxPanningDistance)
          Restricts the area this map can pan to in a radial fashion.
 void setScaleRange(float minScale, float maxScale)
          Sets the range of map scale factors.
 void setTweening(boolean tweening)
          Sets the tweening flag, i.e.
 void setZoomRange(float minZoomLevel, float maxZoomLevel)
          Sets the range of map zoom levels.
 void switchTweening()
          Switches the tweening flag.
 void updateMap()
          Updates the integrators for tweening.
 void zoom(float scaleDelta)
          Zooms in or out.
 void zoom(int levelDelta)
          Deprecated. Replaced by zoomLevel(int)
 void zoomAndPanTo(float x, float y, int level)
          Zooms in around position, and pans to it.
 void zoomAndPanTo(int zoomLevel, Location location)
          Zooms in around position, and pans to it.
 void zoomAndPanTo(int level, ScreenPosition screenPosition)
          Zooms in around position, and pans to it.
 void zoomAndPanTo(Location location, int zoomLevel)
          Deprecated. Use zoomAndPanTo(int, Location).
 void zoomAndPanTo(ScreenPosition screenPosition, int level)
          Deprecated. Use zoomAndPanTo(int, ScreenPosition).
 void zoomAndPanToFit(java.util.List<Location> locations)
           
 void zoomIn()
          Zooms into the map less than a full level.
 void zoomLevel(int levelDelta)
          Zooms in or out one or more levels.
 void zoomLevelIn()
          Zooms in a level.
 void zoomLevelOut()
          Zooms out a level.
 void zoomOut()
          Zooms out of the map less than a full level.
 void zoomTo(float zoom)
           
 void zoomToFit(java.util.List<Location> locations)
           
 void zoomToFit(Location[] boundingBox)
           
 void zoomToLevel(int level)
          Zooms to the given level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GREETING_MESSAGE

public static final java.lang.String GREETING_MESSAGE
See Also:
Constant Field Values

SCALE_DELTA_IN

public static final float SCALE_DELTA_IN
See Also:
Constant Field Values

SCALE_DELTA_OUT

public static final float SCALE_DELTA_OUT
See Also:
Constant Field Values

TILE_WIDTH

public static final int TILE_WIDTH
The default tile width of 256px.

See Also:
Constant Field Values

TILE_HEIGHT

public static final int TILE_HEIGHT
The default tile height of 256px.

See Also:
Constant Field Values

DEFAULT_TWEENING

public static final boolean DEFAULT_TWEENING
UnfoldingMap do not use tweened animation by default. Use setTweening(boolean) to switch it on.

See Also:
Constant Field Values

PRIME_MERIDIAN_EQUATOR_LOCATION

public static final Location PRIME_MERIDIAN_EQUATOR_LOCATION

DEFAULT_ZOOM_LEVEL

public static final int DEFAULT_ZOOM_LEVEL
The default zoom level of an UnfoldingMap shows the whole world.

See Also:
Constant Field Values

minScale

public float minScale
The minimum scale. If set the map cannot be further zoomed in. Use setZoomRange(float, float).


maxScale

public float maxScale
The maximum scale. If set the map cannot be further zoomed out. Use setZoomRange(float, float).


restrictedPanLocation

protected Location restrictedPanLocation
The center location of the restricted pan area.


maxPanningDistance

protected float maxPanningDistance
The maximum distance to the center location of the restricted pan area.


log

public static org.apache.log4j.Logger log

p

protected processing.core.PApplet p
The Processing applet.


mapDisplay

public AbstractMapDisplay mapDisplay
The display of the map.


id

protected java.lang.String id
The ID of this map.


active

protected boolean active
Indicates whether this map is currently active. May be used for non-direct interactions.


scaleIntegrator

public Integrator scaleIntegrator
Tweens the scale.

Constructor Detail

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id)
Creates a new full canvas map with the given ID.

Parameters:
p - The main applet.
id - The ID of this map.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p)
Creates a new full canvas map with a generated ID.

Parameters:
p - The main applet.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    AbstractMapProvider provider)
Creates a new full canvas map with tiles from the given provider.

Parameters:
p - The main applet.
provider - The map tiles provider to use.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    AbstractMapProvider provider)
Creates a new full canvas map with given ID, and with tiles from the given provider.

Parameters:
p - The main applet.
id - The ID of this map.
provider - The map tiles provider to use.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    float x,
                    float y,
                    float width,
                    float height)
Creates a new map with specific position and dimension.

Parameters:
p - The main applet.
x - The x position of this map.
y - The y position of this map.
width - The width of this map.
height - The height of this map.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    float x,
                    float y,
                    float width,
                    float height,
                    java.lang.String renderer)

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    float x,
                    float y,
                    float width,
                    float height)
Creates a new map with specific position and dimension.

Parameters:
p - The main applet.
id - The ID of this map.
x - The x position of this map.
y - The y position of this map.
width - The width of this map.
height - The height of this map.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    float x,
                    float y,
                    float width,
                    float height,
                    java.lang.String renderer)

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    float x,
                    float y,
                    float width,
                    float height,
                    boolean useDistortion)

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    float x,
                    float y,
                    float width,
                    float height,
                    boolean useDistortion,
                    java.lang.String renderer)

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    float x,
                    float y,
                    float width,
                    float height,
                    AbstractMapProvider provider)
Creates a new map with specific position and dimension.

Parameters:
p - The main applet.
x - The x position of this map.
y - The y position of this map.
width - The width of this map.
height - The height of this map.
provider - The map tiles provider to use.

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    float x,
                    float y,
                    float width,
                    float height,
                    AbstractMapProvider provider,
                    java.lang.String renderer)

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    float x,
                    float y,
                    float width,
                    float height,
                    boolean useMask,
                    boolean useDistortion,
                    AbstractMapProvider provider)

UnfoldingMap

public UnfoldingMap(processing.core.PApplet p,
                    java.lang.String id,
                    float x,
                    float y,
                    float width,
                    float height,
                    boolean useMask,
                    boolean useDistortion,
                    AbstractMapProvider provider,
                    java.lang.String renderer)
Creates a new map with specific position and dimension.

Parameters:
p - The main applet.
id - The ID of this map.
x - The x position of this map.
y - The y position of this map.
width - The width of this map.
height - The height of this map.
useMask - Whether this map enables using masks (test)
useDistortion - Whether this map enables using distortion (test)
provider - The map tiles provider to use.
Method Detail

prepareMapChangedMethod

protected void prepareMapChangedMethod()
Internal method to call listening methods in your application for map changes.


allTilesLoaded

public boolean allTilesLoaded()
Check whether all currently visible tiles have been loaded.

Returns:
True if all tiles have been loaded, false otherwise.

generateId

protected static java.lang.String generateId()

isHit

public boolean isHit(float checkX,
                     float checkY)
Checks whether the given screen coordinates are on this Map.

Parameters:
checkX - The vertical position to check.
checkY - The horizontal position to check.
Returns:
True if map is hit, false otherwise.

isHit

public boolean isHit(ScreenPosition screenPosition)
Checks whether the given screen coordinates are on this Map.

Parameters:
screenPosition - The position to check.
Returns:
True if map is hit, false otherwise.

isActive

public boolean isActive()
Indicates whether this map is currently active. May be used for non-direct interactions.

Returns:
True if this map is active, false otherwise.

setActive

public void setActive(boolean active)
Sets the active flag of this map.

Parameters:
active - True if this map is active, false otherwise.

getId

public java.lang.String getId()
Returns the ID of this map.

Specified by:
getId in interface MapEventListener
Returns:
A identifying string for this map.

draw

public void draw()
Updates and draws the map. The main method to display this UnfoldingMap.


onManipulation

public void onManipulation(MapEvent mapEvent)
Internal method to listens to mapDisplay events. This will call any listening methods in your application.

Specified by:
onManipulation in interface MapEventListener

updateMap

public void updateMap()
Updates the integrators for tweening. Must be called before AbstractMapDisplay.draw() .


getTopLeftBorder

public Location getTopLeftBorder()
Returns the top left corner of the visible map.

Returns:
The geographic location with latitude and longitude.

getBottomRightBorder

public Location getBottomRightBorder()
Returns the bottom right corner of the visible map.

Returns:
The geographic location with latitude and longitude.

getCenter

public Location getCenter()
Returns the center location of the visible map.

Returns:
The geographic location with latitude and longitude.

getLocationFromScreenPosition

@Deprecated
public Location getLocationFromScreenPosition(float x,
                                                         float y)
Deprecated. 


getLocation

public Location getLocation(ScreenPosition screenPosition)
Converts a position on the screen to a geographic location.

Parameters:
screenPosition - The position in screen coordinates.
Returns:
The geographic location with latitude and longitude.

getLocation

public Location getLocation(float x,
                            float y)
Converts a position on the screen to a geographic location.

Parameters:
x - The x position in screen coordinates.
y - The y position in screen coordinates.
Returns:
The geographic location with latitude and longitude.

getScreenPositionFromLocation

@Deprecated
public float[] getScreenPositionFromLocation(Location location)
Deprecated. 


getScreenPosition

public ScreenPosition getScreenPosition(Location location)
Converts the geographic location to a position on the screen.

Parameters:
location - The geographic location with latitude and longitude.
Returns:
The screen position.

rotate

public void rotate(float angle)
Rotates the map by given angle.

Use outerRotate(float) to rotate the map container. Check RotatableMapApp in examples for a comparison.

Parameters:
angle - The angle to rotate the map by.

rotateTo

public void rotateTo(float angle)
Rotates the map to the given angle, that is it is rotated to the target angle.

Parameters:
angle - The angle to rotate the map to.

zoomToLevel

public void zoomToLevel(int level)
Zooms to the given level. Map tiles will be non-scaled.

Parameters:
level - The level to zoom to.

zoomTo

public void zoomTo(float zoom)

zoomLevel

public void zoomLevel(int levelDelta)
Zooms in or out one or more levels. Map tiles will be non-scaled.

Parameters:
levelDelta - The number of levels to zoom in or out.

zoom

@Deprecated
public void zoom(int levelDelta)
Deprecated. Replaced by zoomLevel(int)

Parameters:
levelDelta - The number of levels to zoom in or out.

zoomLevelIn

public void zoomLevelIn()
Zooms in a level.


zoomLevelOut

public void zoomLevelOut()
Zooms out a level.


zoom

public void zoom(float scaleDelta)
Zooms in or out. Map tiles may be scaled.

Parameters:
scaleDelta - The scale to zoom by.

zoomIn

public void zoomIn()
Zooms into the map less than a full level. Map tiles will be scaled.


zoomOut

public void zoomOut()
Zooms out of the map less than a full level. Map tiles will be scaled.


zoomAndPanTo

public void zoomAndPanTo(float x,
                         float y,
                         int level)
Zooms in around position, and pans to it. After the pan the center still is at the same location. (As innerTransformationCenter is in object coordinates, thus stays at same inner position.)

Parameters:
x - X position to zoom around and pan to (in screen coordinates).
y - Y position to zoom around and pan to (in screen coordinates).
level - Zoom level to zoom to.

zoomAndPanTo

public void zoomAndPanTo(ScreenPosition screenPosition,
                         int level)
Deprecated. Use zoomAndPanTo(int, ScreenPosition).

Zooms in around position, and pans to it.

Parameters:
screenPosition - ScreenPosition to zoom around and pan to.
level - Zoom level to zoom to.

zoomAndPanTo

public void zoomAndPanTo(int level,
                         ScreenPosition screenPosition)
Zooms in around position, and pans to it. After the pan the center still is at the same location. (As innerTransformationCenter is in object coordinates, thus stays at same inner position.)

Parameters:
level - Zoom level to zoom to.
screenPosition - ScreenPosition to zoom around and pan to.

zoomAndPanTo

public void zoomAndPanTo(Location location,
                         int zoomLevel)
Deprecated. Use zoomAndPanTo(int, Location).

Zooms in around position, and pans to it.

Parameters:
location - The Location to zoom around and pan to.
zoomLevel - Zoom level to zoom to.

zoomAndPanTo

public void zoomAndPanTo(int zoomLevel,
                         Location location)
Zooms in around position, and pans to it. After the pan the center still is at the same location. (As innerTransformationCenter is in object coordinates, thus stays at same inner position.)

Parameters:
zoomLevel - Zoom level to zoom to.
location - The Location to zoom around and pan to.

panTo

public void panTo(float x,
                  float y)
Pans to the given position. The position will be centered.

Parameters:
x - X of the position to pan to, in screen coordinates.
y - Y of the position to pan to, in screen coordinates.

panTo

public void panTo(ScreenPosition screenPosition)
Pans to the given screen position. The position will be centered.

Parameters:
screenPosition - the position to pan to.

panTo

public void panTo(Location location)
Pans to the given Location. The position of the location will be centered.

Parameters:
location - The Location to pan to.

pan

public void pan(float x1,
                float y1,
                float x2,
                float y2)
Pans from point1 to point 2, given in screen coordinates.


pan

public void pan(ScreenPosition from,
                ScreenPosition to)
Pans between two ScreenPosition.

Parameters:
from - ScreenPosition to start from.
to - ScreenPosition to pan to.

pan

public void pan(Location fromLocation,
                Location toLocation)
Pans from one location to another one.

Parameters:
fromLocation - Origin location to pan from.
toLocation - Destination location to pan to.

panBy

public void panBy(float dx,
                  float dy)
Pans by distance in screen coordinates.

Parameters:
dx - Horizontal distance in pixel.
dy - Vertical distance in pixel.

panLeft

public void panLeft()
Pans one tile to the left.


panRight

public void panRight()
Pans one tile to the right.


panUp

public void panUp()
Pans one tile up.


panDown

public void panDown()
Pans one tile down.


move

public void move(float x,
                 float y)
Moves the map to the given position.

The whole map container is moved. Use one of the panning methods to pan the geographical map.

Parameters:
x - X position in screen coordinates.
y - Y position in screen coordinates.

move

public void move(ScreenPosition screenPosition)
Moves the map to the given ScreenPosition.

Parameters:
screenPosition - the ScreenPosition to move to.

moveBy

public void moveBy(float dx,
                   float dy)
Moves the map by the given screen coordinates.

Parameters:
dx - The x distance to move by.
dy - The y distance to move by.

zoomAndPanToFit

public void zoomAndPanToFit(java.util.List<Location> locations)

zoomToFit

public void zoomToFit(java.util.List<Location> locations)

zoomToFit

public void zoomToFit(Location[] boundingBox)

addMarkerManager

public void addMarkerManager(MarkerManager<Marker> markerManager)
Add a MarkerManager to the map. Replaces the default MarkerManager if the given one is the first, and the default one is empty.

Use this if you want to handle multiple independent marker groups. Otherwise, simply use UnfoldingMap's marker methods directly (such as addMarker(Marker)) which handles this internally with the default MarkerManager.

Parameters:
markerManager - The MarkerManager to add.

getLastMarkerManager

public MarkerManager<Marker> getLastMarkerManager()
Returns the lastly added MarkerManager.

Returns:
The last MarkerManager.

getDefaultMarkerManager

public MarkerManager<Marker> getDefaultMarkerManager()
Returns the default MarkerManager, i.e. the first MarkerManager. This is the one used internally by all UnfoldingMap's marker methods.

Returns:
The default MarkerManager.

getMarkerManagerList

public java.util.List<MarkerManager<Marker>> getMarkerManagerList()

removeMarkerManager

public void removeMarkerManager(MarkerManager<Marker> markerManager)

removeMarkerManager

public void removeMarkerManager(int i)

getMarkerManager

public MarkerManager<Marker> getMarkerManager(int index)
Returns the MarkerManager at the given index position.

Parameters:
index - The index to get.
Returns:
The MarkerManager at the index, or null if not existing.

addMarkers

public void addMarkers(Marker... marker)
Adds one or multiple markers to the map.

Note: Uses the default marker manager. If you have more than one marker manager, use MarkerManager.addMarker(Marker) instead.

Parameters:
marker - The marker or markers to add.

addMarker

public void addMarker(Marker marker)
Adds a marker to the map.

Note: Uses the default marker manager. If you have more than one marker manager, use MarkerManager.addMarker(Marker) instead.

Parameters:
marker - The marker to add.

addMarkers

public void addMarkers(java.util.List<Marker> markers)
Adds multiple markers to the map.

Note: Uses the default marker manager. If you have more than one marker manager, use MarkerManager.addMarkers(List) instead.

Parameters:
markers - The markers to add.

getMarkers

public java.util.List<Marker> getMarkers()
Gets markers of the map.

Note: Returns only the markers of the default marker manager. If you have more than one marker manager, use MarkerManager.addMarkers(List) instead.

Returns:
The markers.

getFirstHitMarker

public Marker getFirstHitMarker(float checkX,
                                float checkY)
Checks whether a marker got hit with the given screen coordinates. Can be used for interactive selection, etc. This only returns the first found marker. Use getHitMarker(float, float) to get all hit markers.

Note: Returns only the markers of the default marker manager. If you have more than one marker manager, use MarkerManager.getFirstHitMarker(float, float) instead.

Returns:
The hit marker, or null if none was hit.

getHitMarkers

public java.util.List<Marker> getHitMarkers(float checkX,
                                            float checkY)
Checks whether multiple markers got hit with the given screen coordinates. Can be used for interactive selection, etc. This returns all found markers. Use getFirstHitMarker(float, float) to get only one marker.

Note: Returns only the markers of the default marker manager. If you have more than one marker manager, use MarkerManager.getHitMarkers(float, float) instead.

Returns:
All hit markers, or an empty list if none were hit.

getHitMarker

public java.util.List<Marker> getHitMarker(float checkX,
                                           float checkY)
Deprecated. Use getHitMarkers(float, float) instead.


setOuterRotate

protected void setOuterRotate(float angle)

outerRotate

public void outerRotate(float angle)
Rotates the map container.


setInnerRotate

protected void setInnerRotate(float angle)

innerRotate

public void innerRotate(float angle)
Deprecated. Use rotate(float) instead.

Parameters:
angle - The angle to rotate by.

outerScale

protected void outerScale(float scale)

setOuterScale

protected void setOuterScale(float scale)

innerScale

public void innerScale(float scale)

setInnerScale

public void setInnerScale(float scale)

getZoomLevel

public int getZoomLevel()
Gets the current zoom level of the map. Typically ranges from 0 to 18 or higher, depending on the MapProvider.

Returns:
The zoom level.

getZoom

public float getZoom()
Gets the current zoom of the map. Can be used to scale the size of markers. This is the actual scale of the map (not simply a floating zoom level value). It ranges from 0^2 to 18^2 or higher. Use getZoomFromScale(double) to convert to floating zoom level.

Returns:
The zoom value.

setScaleRange

public void setScaleRange(float minScale,
                          float maxScale)
Sets the range of map scale factors.


setZoomRange

public void setZoomRange(float minZoomLevel,
                         float maxZoomLevel)
Sets the range of map zoom levels. All zoom interactions will be restricted to these levels.

Parameters:
minZoomLevel - The lower zoom level boundary.
maxZoomLevel - The upper zoom level boundary.

setPanningRestriction

public void setPanningRestriction(Location location,
                                  float maxPanningDistance)
Restricts the area this map can pan to in a radial fashion.

Parameters:
location - The center location of the circular restriction area.
maxPanningDistance - The radius of the circular restriction area in kilometers.

resetPanningRestriction

public void resetPanningRestriction()
Frees this map from any panning restriction.


panObjectPositionToObjectCenter

protected void panObjectPositionToObjectCenter(float x,
                                               float y)
Pans object center to given object position.

Parameters:
x - X in object coordinates.
y - Y in object coordinates.

addInnerOffset

protected void addInnerOffset(float dx,
                              float dy)

setInnerOffset

protected void setInnerOffset(float x,
                              float y)

setOffset

protected void setOffset(float x,
                         float y)
Sets the offset of the map. Can be used to re-position the map container (not the map content itself).

Parameters:
x - The x of the screen position.
y - The y of the screen position.

addOffset

protected void addOffset(float dx,
                         float dy)
Moves the offset of the map. Can be used to re-position the map container (not the map content itself).

Parameters:
dx - The x distance in screen coordinates.
dy - The y distance in screen coordinates.

getScaleFromZoom

public static float getScaleFromZoom(float zoom)
Converts zoom to scale.

Parameters:
zoom - The zoom value (between 0 and typically 20+).
Returns:
The scale value (between 0 and 2zoom).

getZoomFromScale

public static float getZoomFromScale(double scale)
Converts scale to zoom.

Parameters:
scale - The scale value (between 0 and 2zoom).
Returns:
The zoom value (between 0 and typically 20+).

getZoomLevelFromScale

public static int getZoomLevelFromScale(double scale)
Converts scale to zoom level. Same as getZoomFromScale(double) but with integer values.


switchTweening

public void switchTweening()
Switches the tweening flag.


isTweening

public boolean isTweening()
Indicates whether the map currently animates between different states.

Returns:
True if tweening is on, false otherwise.

setTweening

public void setTweening(boolean tweening)
Sets the tweening flag, i.e. whether the map shall animate between different states.

Parameters:
tweening - Whether or not the map shall animate.

setBackgroundColor

public void setBackgroundColor(java.lang.Integer bgColor)
Sets the background color of this map.

Parameters:
bgColor - The color in the current colorMode.

getWidth

public float getWidth()
Returns the width of this map.

Returns:
The width in pixels.

getHeight

public float getHeight()
Returns the height of this map.

Returns:
The height in pixels.