public class MapView extends ViewGroup implements IMapView, MapViewConstants, MultiTouchController.MultiTouchObjectCanvas<Object>
Modifier and Type | Class and Description |
---|---|
static class |
MapView.LayoutParams
Per-child layout information associated with OpenStreetMapView.
|
static interface |
MapView.OnFirstLayoutListener |
Modifier and Type | Field and Description |
---|---|
protected AtomicBoolean |
mIsAnimating |
protected boolean |
mIsFlinging |
protected MapListener |
mListener |
protected Integer |
mMaximumZoomLevel |
protected Integer |
mMinimumZoomLevel |
protected float |
mMultiTouchScale |
protected PointF |
mMultiTouchScalePoint |
protected Projection |
mProjection |
(package private) Matrix |
mRotateScaleMatrix |
(package private) Point |
mRotateScalePoint |
protected BoundingBox |
mScrollableAreaBoundingBox |
protected Rect |
mScrollableAreaLimit |
protected AtomicInteger |
mTargetZoomLevel |
ANIMATION_DURATION_DEFAULT, ANIMATION_DURATION_LONG, ANIMATION_DURATION_SHORT, ANIMATION_SMOOTHNESS_DEFAULT, ANIMATION_SMOOTHNESS_HIGH, ANIMATION_SMOOTHNESS_LOW, DEBUGMODE, MAXIMUM_ZOOMLEVEL, MINIMUM_ZOOMLEVEL, NOT_SET
Constructor and Description |
---|
MapView(Context context) |
MapView(Context context,
AttributeSet attrs)
Constructor used by XML layout resource (uses default tile source).
|
MapView(Context context,
MapTileProviderBase aTileProvider) |
MapView(Context context,
MapTileProviderBase aTileProvider,
Handler tileRequestCompleteHandler) |
MapView(Context context,
MapTileProviderBase tileProvider,
Handler tileRequestCompleteHandler,
AttributeSet attrs) |
MapView(Context context,
MapTileProviderBase tileProvider,
Handler tileRequestCompleteHandler,
AttributeSet attrs,
boolean hardwareAccelerated) |
Modifier and Type | Method and Description |
---|---|
void |
addOnFirstLayoutListener(MapView.OnFirstLayoutListener listener) |
boolean |
canZoomIn() |
boolean |
canZoomOut() |
protected boolean |
checkLayoutParams(ViewGroup.LayoutParams p) |
void |
computeScroll() |
protected void |
dispatchDraw(Canvas c) |
boolean |
dispatchTouchEvent(MotionEvent event) |
protected ViewGroup.LayoutParams |
generateDefaultLayoutParams()
Returns a set of layout parameters with a width of
ViewGroup.LayoutParams , a height of
ViewGroup.LayoutParams at the GeoPoint (0, 0) align
with MapView.LayoutParams.BOTTOM_CENTER . |
ViewGroup.LayoutParams |
generateLayoutParams(AttributeSet attrs) |
protected ViewGroup.LayoutParams |
generateLayoutParams(ViewGroup.LayoutParams p) |
BoundingBox |
getBoundingBox() |
BoundingBoxE6 |
getBoundingBoxE6() |
IMapController |
getController() |
Object |
getDraggableObjectAtPoint(MultiTouchController.PointInfo pt)
See if there is a draggable object at the current point.
|
Rect |
getIntrinsicScreenRect(Rect reuse) |
int |
getLatitudeSpan() |
double |
getLatitudeSpanDouble() |
int |
getLongitudeSpan() |
double |
getLongitudeSpanDouble() |
IGeoPoint |
getMapCenter()
Returns the current center-point position of the map, as a GeoPoint (latitude and longitude).
|
float |
getMapOrientation() |
int |
getMaxZoomLevel()
Get the maximum allowed zoom level for the maps.
|
int |
getMinZoomLevel()
Get the minimum allowed zoom level for the maps.
|
OverlayManager |
getOverlayManager() |
List<Overlay> |
getOverlays()
You can add/remove/reorder your Overlays using the List of
Overlay . |
void |
getPositionAndScale(Object obj,
MultiTouchController.PositionAndScale objPosAndScaleOut)
Get the screen coords of the dragged object's origin, and scale multiplier to convert screen coords to obj coords.
|
Projection |
getProjection()
Get a projection for converting between screen-pixel coordinates and latitude/longitude
coordinates.
|
Rect |
getScreenRect(Rect reuse)
Gets the current bounds of the screen in screen coordinates.
|
BoundingBox |
getScrollableAreaLimit() |
Scroller |
getScroller() |
MapTileProviderBase |
getTileProvider() |
Handler |
getTileRequestCompleteHandler() |
int |
getZoomLevel()
Get the current ZoomLevel for the map tiles.
|
int |
getZoomLevel(boolean aPending)
Get the current ZoomLevel for the map tiles.
|
void |
invalidateMapCoordinates(int left,
int top,
int right,
int bottom) |
void |
invalidateMapCoordinates(Rect dirty) |
boolean |
isAnimating()
Determines if maps are animating a zoom operation.
|
boolean |
isFlingEnabled() |
boolean |
isLayoutOccurred() |
boolean |
isTilesScaledToDpi() |
void |
onDetach() |
protected void |
onDetachedFromWindow() |
boolean |
onKeyDown(int keyCode,
KeyEvent event) |
boolean |
onKeyUp(int keyCode,
KeyEvent event) |
protected void |
onLayout(boolean changed,
int l,
int t,
int r,
int b) |
protected void |
onMeasure(int widthMeasureSpec,
int heightMeasureSpec) |
boolean |
onTouchEvent(MotionEvent event) |
boolean |
onTrackballEvent(MotionEvent event) |
void |
postInvalidateMapCoordinates(int left,
int top,
int right,
int bottom) |
void |
removeOnFirstLayoutListener(MapView.OnFirstLayoutListener listener) |
void |
scrollTo(int x,
int y) |
void |
selectObject(Object obj,
MultiTouchController.PointInfo pt)
Select an object at the given point.
|
void |
setBackgroundColor(int pColor) |
void |
setBuiltInZoomControls(boolean on) |
void |
setFlingEnabled(boolean b) |
(package private) void |
setMapCenter(double aLatitude,
double aLongitude) |
(package private) void |
setMapCenter(IGeoPoint aCenter) |
(package private) void |
setMapCenter(int aLatitudeE6,
int aLongitudeE6)
Deprecated.
|
void |
setMapListener(MapListener ml) |
void |
setMapOrientation(float degrees)
rotates the map to the desired heading
|
void |
setMaxZoomLevel(Integer zoomLevel)
Set the maximum allowed zoom level, or pass null to use the maximum zoom level from the tile
provider.
|
void |
setMinZoomLevel(Integer zoomLevel)
Set the minimum allowed zoom level, or pass null to use the minimum zoom level from the tile
provider.
|
void |
setMultiTouchControls(boolean on) |
void |
setOverlayManager(OverlayManager overlayManager) |
boolean |
setPositionAndScale(Object obj,
MultiTouchController.PositionAndScale aNewObjPosAndScale,
MultiTouchController.PointInfo aTouchPoint)
Callback to update the position and scale (in object coords) of the currently-dragged object.
|
protected void |
setProjection(Projection p) |
void |
setScrollableAreaLimit(BoundingBoxE6 boundingBox)
Deprecated.
|
void |
setScrollableAreaLimitDouble(BoundingBox boundingBox)
Set the map to limit it's scrollable view to the specified BoundingBox.
|
void |
setTileProvider(MapTileProviderBase base)
enables you to programmatically set the tile provider (zip, assets, sqlite, etc)
|
void |
setTileSource(ITileSource aTileSource) |
void |
setTilesScaledToDpi(boolean tilesScaledToDpi) |
void |
setUseDataConnection(boolean aMode)
Set whether to use the network connection if it's available.
|
(package private) int |
setZoomLevel(int aZoomLevel) |
boolean |
useDataConnection()
Whether to use the network connection if it's available.
|
(package private) boolean |
zoomIn()
Zoom in by one zoom level.
|
(package private) boolean |
zoomInFixing(IGeoPoint point)
Deprecated.
|
(package private) boolean |
zoomInFixing(int xPixel,
int yPixel)
Deprecated.
|
(package private) boolean |
zoomOut()
Zoom out by one zoom level.
|
(package private) boolean |
zoomOutFixing(IGeoPoint point)
Deprecated.
|
(package private) boolean |
zoomOutFixing(int xPixel,
int yPixel)
Deprecated.
|
void |
zoomToBoundingBox(BoundingBox boundingBox,
boolean animated)
Zoom the map to enclose the specified bounding box, as closely as possible.
|
void |
zoomToBoundingBox(BoundingBoxE6 boundingBox)
Deprecated.
|
protected Projection mProjection
protected boolean mIsFlinging
protected final AtomicInteger mTargetZoomLevel
protected final AtomicBoolean mIsAnimating
protected Integer mMinimumZoomLevel
protected Integer mMaximumZoomLevel
protected float mMultiTouchScale
protected PointF mMultiTouchScalePoint
protected MapListener mListener
protected BoundingBox mScrollableAreaBoundingBox
protected Rect mScrollableAreaLimit
final Matrix mRotateScaleMatrix
final Point mRotateScalePoint
public MapView(Context context, MapTileProviderBase tileProvider, Handler tileRequestCompleteHandler, AttributeSet attrs)
public MapView(Context context, MapTileProviderBase tileProvider, Handler tileRequestCompleteHandler, AttributeSet attrs, boolean hardwareAccelerated)
public MapView(Context context, AttributeSet attrs)
public MapView(Context context)
public MapView(Context context, MapTileProviderBase aTileProvider)
public MapView(Context context, MapTileProviderBase aTileProvider, Handler tileRequestCompleteHandler)
public IMapController getController()
getController
in interface IMapView
public List<Overlay> getOverlays()
Overlay
. The first (index
0) Overlay gets drawn first, the one with the highest as the last one.public OverlayManager getOverlayManager()
public void setOverlayManager(OverlayManager overlayManager)
public MapTileProviderBase getTileProvider()
public Scroller getScroller()
public Handler getTileRequestCompleteHandler()
public int getLatitudeSpan()
getLatitudeSpan
in interface IMapView
public double getLatitudeSpanDouble()
getLatitudeSpanDouble
in interface IMapView
public int getLongitudeSpan()
getLongitudeSpan
in interface IMapView
public double getLongitudeSpanDouble()
getLongitudeSpanDouble
in interface IMapView
public BoundingBoxE6 getBoundingBoxE6()
public BoundingBox getBoundingBox()
public Rect getScreenRect(Rect reuse)
public Rect getIntrinsicScreenRect(Rect reuse)
public Projection getProjection()
getProjection
in interface IMapView
protected void setProjection(Projection p)
void setMapCenter(IGeoPoint aCenter)
void setMapCenter(int aLatitudeE6, int aLongitudeE6)
setMapCenter(IGeoPoint)
void setMapCenter(double aLatitude, double aLongitude)
public boolean isTilesScaledToDpi()
public void setTilesScaledToDpi(boolean tilesScaledToDpi)
public void setTileSource(ITileSource aTileSource)
int setZoomLevel(int aZoomLevel)
aZoomLevel
- the zoom level bound by the tile source@Deprecated public void zoomToBoundingBox(BoundingBoxE6 boundingBox)
public void zoomToBoundingBox(BoundingBox boundingBox, boolean animated)
public int getZoomLevel()
getZoomLevel
in interface IMapView
public int getZoomLevel(boolean aPending)
aPending
- if true and we're animating then return the zoom level that we're animating
towards, otherwise return the current zoom levelpublic int getMinZoomLevel()
public int getMaxZoomLevel()
getMaxZoomLevel
in interface IMapView
public void setMinZoomLevel(Integer zoomLevel)
public void setMaxZoomLevel(Integer zoomLevel)
public boolean canZoomIn()
public boolean canZoomOut()
boolean zoomIn()
@Deprecated boolean zoomInFixing(IGeoPoint point)
@Deprecated boolean zoomInFixing(int xPixel, int yPixel)
boolean zoomOut()
@Deprecated boolean zoomOutFixing(IGeoPoint point)
@Deprecated boolean zoomOutFixing(int xPixel, int yPixel)
public IGeoPoint getMapCenter()
getMapCenter
in interface IMapView
public void setMapOrientation(float degrees)
degrees
- public float getMapOrientation()
public boolean useDataConnection()
public void setUseDataConnection(boolean aMode)
aMode
- if true use the network connection if it's available. if false don't use the
network connection even if it's available.@Deprecated public void setScrollableAreaLimit(BoundingBoxE6 boundingBox)
boundingBox
- A lat/long bounding box to limit scrolling to, or null to remove any scrolling
limitationspublic void setScrollableAreaLimitDouble(BoundingBox boundingBox)
boundingBox
- A lat/long bounding box to limit scrolling to, or null to remove any scrolling
limitationspublic BoundingBox getScrollableAreaLimit()
public void invalidateMapCoordinates(Rect dirty)
public void invalidateMapCoordinates(int left, int top, int right, int bottom)
public void postInvalidateMapCoordinates(int left, int top, int right, int bottom)
protected ViewGroup.LayoutParams generateDefaultLayoutParams()
ViewGroup.LayoutParams
, a height of
ViewGroup.LayoutParams
at the GeoPoint
(0, 0) align
with MapView.LayoutParams.BOTTOM_CENTER
.public ViewGroup.LayoutParams generateLayoutParams(AttributeSet attrs)
protected boolean checkLayoutParams(ViewGroup.LayoutParams p)
protected ViewGroup.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
protected void onLayout(boolean changed, int l, int t, int r, int b)
public void addOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)
public void removeOnFirstLayoutListener(MapView.OnFirstLayoutListener listener)
public boolean isLayoutOccurred()
public void onDetach()
public boolean onKeyDown(int keyCode, KeyEvent event)
public boolean onKeyUp(int keyCode, KeyEvent event)
public boolean onTrackballEvent(MotionEvent event)
public boolean dispatchTouchEvent(MotionEvent event)
public boolean onTouchEvent(MotionEvent event)
public void computeScroll()
public void scrollTo(int x, int y)
public void setBackgroundColor(int pColor)
setBackgroundColor
in interface IMapView
protected void dispatchDraw(Canvas c)
protected void onDetachedFromWindow()
public boolean isAnimating()
public Object getDraggableObjectAtPoint(MultiTouchController.PointInfo pt)
MultiTouchController.MultiTouchObjectCanvas
getDraggableObjectAtPoint
in interface MultiTouchController.MultiTouchObjectCanvas<Object>
pt
- The point being tested (in object coordinates). Return the topmost object under this point, or if dragging/stretching the whole
canvas, just return a reference to the canvas.public void getPositionAndScale(Object obj, MultiTouchController.PositionAndScale objPosAndScaleOut)
MultiTouchController.MultiTouchObjectCanvas
getPositionAndScale
in interface MultiTouchController.MultiTouchObjectCanvas<Object>
obj
- The object being dragged/stretched.objPosAndScaleOut
- Output parameter: You need to call objPosAndScaleOut.set() to record the current position and scale of obj.public void selectObject(Object obj, MultiTouchController.PointInfo pt)
MultiTouchController.MultiTouchObjectCanvas
selectObject
in interface MultiTouchController.MultiTouchObjectCanvas<Object>
obj
- The object being selected by single-touch, or null on touch-up.pt
- The current touch point.public boolean setPositionAndScale(Object obj, MultiTouchController.PositionAndScale aNewObjPosAndScale, MultiTouchController.PointInfo aTouchPoint)
MultiTouchController.MultiTouchObjectCanvas
setPositionAndScale
in interface MultiTouchController.MultiTouchObjectCanvas<Object>
obj
- The object being dragged/stretched.aNewObjPosAndScale
- The new position and scale of the object, in object coordinates. Use this to move/resize the object before returning.aTouchPoint
- Info about the current touch point, including multitouch information and utilities to calculate and cache multitouch pinch
diameter etc. (Note: touchPoint is volatile, if you want to keep any fields of touchPoint, you must copy them before the method
body exits.)public void setMapListener(MapListener ml)
public void setBuiltInZoomControls(boolean on)
public void setMultiTouchControls(boolean on)
public void setFlingEnabled(boolean b)
public boolean isFlingEnabled()
public void setTileProvider(MapTileProviderBase base)
base
- MapTileProviderBasic