com.google.android.maps
Class MapView
java.lang.Object android.view.View android.view.ViewGroup com.google.android.maps.MapView
-
All Implemented Interfaces:
- android.graphics.drawable.Drawable.Callback, android.view.KeyEvent.Callback, android.view.ViewManager, android.view.ViewParent
public class MapView extends android.view.ViewGroup
A View which displays a map (with data obtained from the Google Maps service). When focused, it will capture keypresses and touch gestures to pan and zoom the map. It can also be controlled programmatically (getController()
) and can draw a number of Overlay
s on top of the map (getOverlays()
).
The map can be displayed in a number of modes; see setSatellite(boolean)
, setTraffic(boolean)
, and setStreetView(boolean)
. It can optionally display a "reticle" when not it touch-mode, to aid in using pan-to-select; see setReticleDrawMode(com.google.android.maps.MapView.ReticleDrawMode)
. It also draws a Google logo in the bottom-left corner.
The preferred zoom mechanism is the built-in zoom, see setBuiltInZoomControls(boolean)
. As the user pans the map, zoom controls will automatically be shown at the bottom of the MapView.
The MapView is also a ViewGroup, with LayoutParameters allowing you to attach views either to a specific pixel offset, or to a specific latitude/longitude pair.
A MapView can only be constructed (or inflated) by a MapActivity
. This is because it depends on threads which access the network and filesystem in the background; these threads must be shepherded by the lifecycle management in MapActivity
. Tiles are cached on the filesystem in your application's directory. The cache is auto-managed so you don't need to do anything with it, and can delete it at any time.
In order to display Google Maps data in a MapView, you must register with the Google Maps service and obtain a Maps API Key. For information about how to get a Maps API Key, see Obtaining a Maps API Key.
Once you have a Maps API Key, you need to reference it from a special attribute -- android:apiKey
-- in the MapView element in the XML layout. If you are instantiating a MapView directly from code, you should pass the Maps API Key in the MapView constructor.
Nested Class Summary | |
---|---|
static class | MapView.LayoutParams Per-child layout information associated with MapView. |
static class | MapView.ReticleDrawMode Allow the user to specify the mode in which the reticle is drawn. |
Nested classes/interfaces inherited from class android.view.ViewGroup |
---|
android.view.ViewGroup.MarginLayoutParams, android.view.ViewGroup.OnHierarchyChangeListener |
Nested classes/interfaces inherited from class android.view.View |
---|
android.view.View.BaseSavedState, android.view.View.MeasureSpec, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnFocusChangeListener, android.view.View.OnKeyListener, android.view.View.OnLongClickListener, android.view.View.OnTouchListener |
Field Summary |
---|
Fields inherited from class android.view.ViewGroup |
---|
CLIP_TO_PADDING_MASK, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE |
Fields inherited from class android.view.View |
---|
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FIRST_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, INVISIBLE, KEEP_SCREEN_ON, LAST_STATE_SET, mBottom, mContext, mCurrentAnimation, MIDDLE_STATE_SET, mLayoutParams, mLeft, mMeasuredHeight, mMeasuredWidth, mOnClickListener, mOnCreateContextMenuListener, mOnFocusChangeListener, mOnLongClickListener, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FIRST_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_LAST_STATE_SET, PRESSED_MIDDLE_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_SINGLE_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SINGLE_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET |
Constructor Summary | |
---|---|
MapView(android.content.Context context, android.util.AttributeSet attrs) Constructs a MapView object. | |
MapView(android.content.Context context, android.util.AttributeSet attrs, int defStyle) Constructs a MapView object. | |
MapView(android.content.Context context, java.lang.String apiKey) Constructs a MapView object. |
Method Summary | |
---|---|
boolean | canCoverCenter() Checks whether we currently have a map tile to cover the center of the map. |
protected boolean | checkLayoutParams(android.view.ViewGroup.LayoutParams p) Just checks if p instanceof MapView.LayoutParams . |
void | computeScroll() Captures scroll events and uses them to pan the map. |
void | displayZoomControls(boolean takeFocus) Makes the zoom controls visible and optionally requests focus upon them so they can be accessed via keys. |
protected MapView.LayoutParams | generateDefaultLayoutParams() Returns a set of layout parameters with a width of ViewGroup.LayoutParams.WRAP_CONTENT , a height of ViewGroup.LayoutParams.WRAP_CONTENT and with the coordinates (0, 0). |
android.view.ViewGroup.LayoutParams | generateLayoutParams(android.util.AttributeSet attrs) |
protected android.view.ViewGroup.LayoutParams | generateLayoutParams(android.view.ViewGroup.LayoutParams p) |
MapController | getController() Returns the MapController for this map, which you can use to control and animate pan and zoom. |
int | getLatitudeSpan() The current latitude span (from the top edge to the bottom edge of the map) in decimal degrees multiplied by one million. |
int | getLongitudeSpan() The current longitude span (from the left edge to the right edge of the map) in decimal degrees multiplied by one million. |
GeoPoint | getMapCenter() Returns the current center-point position of the map, as a GeoPoint (latitude and longitude). |
int | getMaxZoomLevel() Returns the maximum zoom level for the point currently at the center. |
java.util.List<Overlay> | getOverlays() Access the overlay list. |
Projection | getProjection() Get a projection for converting between screen-pixel coordinates and latitude/longitude coordinates. |
android.view.View | getZoomControls() Deprecated. The built-in zoom mechanism is preferred, see setBuiltInZoomControls(boolean) . |
int | getZoomLevel() Returns the current zoom level of the map. |
boolean | isSatellite() Checks whether the map is in "satellite" image mode. |
boolean | isStreetView() Checks whether the map is drawing street view availability (blue outlines). |
boolean | isTraffic() Checks whether the map is drawing traffic where available. |
protected void | onDetachedFromWindow() Called when being detached, clean up the zoom controls. |
protected void | onDraw(android.graphics.Canvas canvas) The main draw method. |
void | onFocusChanged(boolean hasFocus, int direction, android.graphics.Rect unused) Called by the view system when the focus state of this view changes. |
boolean | onKeyDown(int keyCode, android.view.KeyEvent event) Passes keys to the overlays first, and if they don't handle them, try using them to pan. |
boolean | onKeyUp(int keyCode, android.view.KeyEvent event) Passes keys to the overlays first, and if they don't handle them, try using them to pan. |
protected void | onLayout(boolean changed, int left, int top, int right, int bottom) |
protected void | onMeasure(int widthMeasureSpec, int heightMeasureSpec) |
void | onRestoreInstanceState(android.os.Bundle state) Restores the state of the MapView to a Bundle. |
void | onSaveInstanceState(android.os.Bundle state) Saves the state of the MapView to a Bundle. |
protected void | onSizeChanged(int w, int h, int oldw, int oldh) This resizes the map object and repositions the reticle. |
boolean | onTouchEvent(android.view.MotionEvent ev) Passes trackball events to the overlays first, and if they don't handle them, feed it to a gesture detector, and dispatch the detected gestures. |
boolean | onTrackballEvent(android.view.MotionEvent event) Passes trackball events to the overlays first, and if they don't handle them, try using them to pan and "tap". |
void | onWindowFocusChanged(boolean hasFocus) Called when the window containing this view gains or loses focus. |
void | preLoad() Preload the tiles at the map's current center. |
void | setBuiltInZoomControls(boolean on) Sets whether to enable the built-in zoom controls. |
void | setReticleDrawMode(MapView.ReticleDrawMode mode) Specify how the reticle should be drawn when the device is not in touch mode. |
void | setSatellite(boolean on) Sets the map mode to "satellite" mode, loading tiles of aerial imagery with roads and names superimposed. |
void | setStreetView(boolean on) Control whether Street View availability (blue outlines) is shown on the map. |
void | setTraffic(boolean on) Control whether traffic is shown on the map. |
Methods inherited from class android.view.ViewGroup |
---|
addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchDraw, dispatchFreezeSelfOnly, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetPressed, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, findFocus, findViewTraversal, findViewWithTagTraversal, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onCreateDrawableState, onInterceptTouchEvent, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, setStaticTransformationsEnabled, showContextMenuForChild, startLayoutAnimation, updateViewLayout |
Methods inherited from class android.view.View |
---|
applyDrawableToTransparentRegion, bringToFront, buildDrawingCache, cancelLongPress, checkInputConnectionProxy, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createContextMenu, debug, debugIndent, destroyDrawingCache, draw, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getContext, getContextMenuInfo, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInEditMode, isInTouchMode, isLayoutRequested, isLongClickable, isPaddingOffsetRequired, isPressed, isRootNamespace, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCheckIsTextEditor, onCreateContextMenu, onCreateInputConnection, onFinishInflate, onFinishTemporaryDetach, onKeyMultiple, onKeyPreIme, onKeyShortcut, onRestoreInstanceState, onSaveInstanceState, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onWindowVisibilityChanged, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFocusable, setFocusableInTouchMode, setFrame, setHapticFeedbackEnabled, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setIsRootNamespace, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setScrollContainer, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface android.view.ViewParent |
---|
createContextMenu, getParent, isLayoutRequested, requestLayout |
Constructor Detail |
---|
MapView
public MapView(android.content.Context context, java.lang.String apiKey)
-
Constructs a MapView object.
-
Parameters:
-
context
- AMapActivity
object. -
apiKey
- A Google Maps API Key. See Obtaining a Maps API Key for complete information.
Throws:
-
java.lang.IllegalArgumentException
- if the enclosing context is not an instance ofMapActivity
.
-
MapView
public MapView(android.content.Context context, android.util.AttributeSet attrs)
-
Constructs a MapView object.
-
Parameters:
-
context
- AMapActivity
object. -
attrs
- An attribute set; currently no attributes are used.
Throws:
-
java.lang.IllegalArgumentException
- if the enclosing context is not an instance ofMapActivity
.
-
MapView
public MapView(android.content.Context context, android.util.AttributeSet attrs, int defStyle)
-
Constructs a MapView object.
-
Parameters:
-
context
- AMapActivity
object. -
attrs
- An attribute set; we currently have no attributes. -
defStyle
- The default style to apply to this view. If 0, no style will be applied (beyond what is included in the theme). This may either be an attribute resource, whose value will be retrieved from the current theme, or an explicit style resource.
Throws:
-
java.lang.IllegalArgumentException
- if the enclosing context is not an instance ofMapActivity
, or if the attributes do not include an apiKey.
-
Method Detail |
---|
onSizeChanged
protected void onSizeChanged(int w, int h, int oldw, int oldh)
- This resizes the map object and repositions the reticle. If you override this method, be sure to call through to super.onSizeChanged().
-
-
Overrides:
-
onSizeChanged
in classandroid.view.View
-
-
onDetachedFromWindow
protected void onDetachedFromWindow()
- Called when being detached, clean up the zoom controls.
-
-
Overrides:
-
onDetachedFromWindow
in classandroid.view.View
-
-
computeScroll
public void computeScroll()
- Captures scroll events and uses them to pan the map.
-
-
Overrides:
-
computeScroll
in classandroid.view.View
-
-
onDraw
protected final void onDraw(android.graphics.Canvas canvas)
- The main draw method. We draw the map background (loading tiles as appropriate), all our Overlays, the reticle (if desired), and the Google logo. We also update any panning animation currently underway.
-
-
Overrides:
-
onDraw
in classandroid.view.View
-
-
onMeasure
protected final void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
-
-
Overrides:
-
onMeasure
in classandroid.view.View
-
-
onWindowFocusChanged
public void onWindowFocusChanged(boolean hasFocus)
- Called when the window containing this view gains or loses focus. Catch focus changed events to stop panning (since we might not get the keyUp anymore).
-
-
Overrides:
-
onWindowFocusChanged
in classandroid.view.View
-
-
onFocusChanged
public void onFocusChanged(boolean hasFocus, int direction, android.graphics.Rect unused)
- Called by the view system when the focus state of this view changes. Catch focus changed events to stop panning (since we might not get the keyUp anymore)
-
-
Overrides:
-
onFocusChanged
in classandroid.view.View
-
-
onKeyDown
public boolean onKeyDown(int keyCode, android.view.KeyEvent event)
- Passes keys to the overlays first, and if they don't handle them, try using them to pan.
-
-
Specified by:
-
onKeyDown
in interfaceandroid.view.KeyEvent.Callback
Overrides:
-
onKeyDown
in classandroid.view.View
-
onKeyUp
public boolean onKeyUp(int keyCode, android.view.KeyEvent event)
- Passes keys to the overlays first, and if they don't handle them, try using them to pan.
-
-
Specified by:
-
onKeyUp
in interfaceandroid.view.KeyEvent.Callback
Overrides:
-
onKeyUp
in classandroid.view.View
-
onTrackballEvent
public boolean onTrackballEvent(android.view.MotionEvent event)
- Passes trackball events to the overlays first, and if they don't handle them, try using them to pan and "tap".
-
-
Overrides:
-
onTrackballEvent
in classandroid.view.View
-
-
onTouchEvent
public boolean onTouchEvent(android.view.MotionEvent ev)
-
Passes trackball events to the overlays first, and if they don't handle them, feed it to a gesture detector, and dispatch the detected gestures. It will always return false if this MapView is not
View.isEnabled()
or is notView.isClickable()
. -
-
Overrides:
-
onTouchEvent
in classandroid.view.View
-
-
generateDefaultLayoutParams
protected MapView.LayoutParams generateDefaultLayoutParams()
-
Returns a set of layout parameters with a width of
ViewGroup.LayoutParams.WRAP_CONTENT
, a height ofViewGroup.LayoutParams.WRAP_CONTENT
and with the coordinates (0, 0). -
-
Overrides:
-
generateDefaultLayoutParams
in classandroid.view.ViewGroup
-
-
onLayout
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
-
-
Specified by:
-
onLayout
in classandroid.view.ViewGroup
-
-
generateLayoutParams
public android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
-
-
Overrides:
-
generateLayoutParams
in classandroid.view.ViewGroup
-
-
checkLayoutParams
protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p)
-
Just checks if p instanceof
MapView.LayoutParams
. -
-
Overrides:
-
checkLayoutParams
in classandroid.view.ViewGroup
-
-
-
Parameters:
-
p
- The LayoutParams object to verify.
Returns:
- True if p is an instance of MapView LayoutParams; false otherwise.
-
generateLayoutParams
protected android.view.ViewGroup.LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams p)
-
-
Overrides:
-
generateLayoutParams
in classandroid.view.ViewGroup
-
-
displayZoomControls
public void displayZoomControls(boolean takeFocus)
- Makes the zoom controls visible and optionally requests focus upon them so they can be accessed via keys.
-
-
Parameters:
-
takeFocus
- If true, bring the zoom controls into focus. If false, do not bring controls into focus.
-
canCoverCenter
public boolean canCoverCenter()
- Checks whether we currently have a map tile to cover the center of the map.
-
-
Returns:
- True if there is a tile for the center, false otherwise.
preLoad
public void preLoad()
- Preload the tiles at the map's current center. This will begin fetching tiles.
-
getZoomLevel
public int getZoomLevel()
- Returns the current zoom level of the map. At zoom level 1 (fully zoomed out), the equator of the earth is 256 pixels long. Each successive zoom level is magnified by a factor of 2.
-
-
Returns:
- The zoom level of the map.
setSatellite
public void setSatellite(boolean on)
- Sets the map mode to "satellite" mode, loading tiles of aerial imagery with roads and names superimposed. Note that this may change the zoom level when switching into map mode (if the current zoom is too high for map mode, the zoom is switched to the maximum map zoom).
-
-
Parameters:
-
on
- If true, turn satellite tiles on. If false, turn regular map tiles on.
-
isSatellite
public boolean isSatellite()
- Checks whether the map is in "satellite" image mode.
-
-
Returns:
- True if in satellite image mode, false otherwise.
setTraffic
public void setTraffic(boolean on)
- Control whether traffic is shown on the map. This is incompatible with Street View indicators, so they will be deactivated if necessary. They can be drawn over map tiles or over satellite tiles; however, they are optimized for map tiles.
-
-
Parameters:
-
on
- If true, turn traffic lines on. If false, turn them off.
-
isTraffic
public boolean isTraffic()
- Checks whether the map is drawing traffic where available.
-
-
Returns:
- True if the map is drawing traffic; false otherwise.
setStreetView
public void setStreetView(boolean on)
- Control whether Street View availability (blue outlines) is shown on the map. This is incompatible with Traffic indicators, so they will be deactivated if necessary. Street View availability can be drawn over map tiles or over satellite tiles; however, they are optimized for map tiles.
-
-
Parameters:
-
on
- If true, turn street view availability on. If false, turn them off.
-
isStreetView
public boolean isStreetView()
- Checks whether the map is drawing street view availability (blue outlines).
-
-
Returns:
- True if the map is drawing street view availability; false otherwise.
getMapCenter
public GeoPoint getMapCenter()
- Returns the current center-point position of the map, as a GeoPoint (latitude and longitude).
-
-
Returns:
- A GeoPoint of the map's center-point.
getController
public MapController getController()
- Returns the MapController for this map, which you can use to control and animate pan and zoom.
-
-
Returns:
- This map's MapController.
getOverlays
public final java.util.List<Overlay> getOverlays()
-
Access the overlay list. Any
Overlay
s in this list will be drawn (in increasing order) and will receive events (in decreasing order, until one returns true). If you modify the list, you will probably want to callView.postInvalidate()
so that the change will be made visible to the user. -
-
Returns:
-
The list of overlays. This has been run through
Collections.synchronizedList(java.util.List)
; thus feel free to query it or modify it as you see fit and the changes will be reflected on the next draw or event. However, if you iterate over it, the entire loop should be enclosed in a block synchronizing on the list.
-
The list of overlays. This has been run through
getLatitudeSpan
public int getLatitudeSpan()
- The current latitude span (from the top edge to the bottom edge of the map) in decimal degrees multiplied by one million.
-
-
Returns:
- Latitude span in decimal degrees * 1,000,000.
getLongitudeSpan
public int getLongitudeSpan()
- The current longitude span (from the left edge to the right edge of the map) in decimal degrees multiplied by one million.
-
-
Returns:
- Longitude span in decimal degrees * 1,000,000.
setReticleDrawMode
public void setReticleDrawMode(MapView.ReticleDrawMode mode)
- Specify how the reticle should be drawn when the device is not in touch mode.
-
-
Parameters:
-
mode
- The reticle draw mode. Valid values are:MapView.ReticleDrawMode.DRAW_RETICLE_OVER
- this is the default mode and in this mode the reticle will be drawn over all the overlays so it's always visible.MapView.ReticleDrawMode.DRAW_RETICLE_UNDER
- the reticle will be drawn before all the overlays are drawn meaning the reticle is there but if any object is drawn at the same position it will cover the reticle.MapView.ReticleDrawMode.DRAW_RETICLE_NEVER
- the reticle is not drawn
-
getMaxZoomLevel
public int getMaxZoomLevel()
- Returns the maximum zoom level for the point currently at the center. (Not all areas of the map offer the same high-res, close-up map tiles.) Takes into account whether satellite mode is enabled.
-
-
Returns:
- The maximum zoom level for the map's current center.
onSaveInstanceState
public void onSaveInstanceState(android.os.Bundle state)
- Saves the state of the MapView to a Bundle. Currently, this persists the center, zoomlevel, and state of the Zoom dialog.
-
-
Parameters:
-
state
- The Bundle to maintain the current state.
-
onRestoreInstanceState
public void onRestoreInstanceState(android.os.Bundle state)
- Restores the state of the MapView to a Bundle. Currently, this restores the center, zoomlevel, and state of the Zoom dialog.
-
-
Parameters:
-
state
- The Bundle with the prior instance state.
-
getZoomControls
@Deprecated
public android.view.View getZoomControls()
-
Deprecated.
The built-in zoom mechanism is preferred, see
setBuiltInZoomControls(boolean)
. -
Returns a View containing a ZoomControls widget (i.e. +/- buttons). This view will become visible when the user starts panning the Map via touch and fade away if the user does not interact with it. The MapView handles this show and hide as appropriate, but the Activity is responsible for placing the controls on the screen. Using
ViewGroup.addView(View)
is the common way to add this View to the screen.API version 3 introduces a built-in zoom mechanism that is shown automatically by the MapView. This is the preferred approach for showing the zoom UI.
-
-
Returns:
- A View with the ZoomControls.
setBuiltInZoomControls
public void setBuiltInZoomControls(boolean on)
- Sets whether to enable the built-in zoom controls. If enabled, the MapView will show these zoom controls automatically.
-
-
Parameters:
-
on
- Whether the built-in zoom controls are enabled. If false, the client handles showing the UI for zoom controls.
-
getProjection
public Projection getProjection()
- Get a projection for converting between screen-pixel coordinates and latitude/longitude coordinates.
-
-
Returns:
- The Projection of the map in its current state. You should not hold on to this object for more than one draw, since the projection of the map could change.