com.google.android.maps
Class MapView

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by com.google.android.maps.MapView
All Implemented Interfaces:
android.graphics.drawable.Drawable.Callback, android.graphics.drawable.Drawable.Callback2, android.view.accessibility.AccessibilityEventSource, 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 Overlays 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.AccessibilityDelegate, android.view.View.BaseSavedState, android.view.View.DragShadowBuilder, android.view.View.MeasureSpec, android.view.View.OnAttachStateChangeListener, android.view.View.OnClickListener, android.view.View.OnCreateContextMenuListener, android.view.View.OnDragListener, android.view.View.OnFocusChangeListener, android.view.View.OnGenericMotionListener, android.view.View.OnHoverListener, android.view.View.OnKeyListener, android.view.View.OnLayoutChangeListener, android.view.View.OnLongClickListener, android.view.View.OnSystemUiVisibilityChangeListener, android.view.View.OnTouchListener
 
Field Summary
 
Fields inherited from class android.view.ViewGroup
CLIP_BOUNDS, CLIP_TO_PADDING_MASK, FLAG_DISALLOW_INTERCEPT, FLAG_SUPPORT_STATIC_TRANSFORMATIONS, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, mDisappearingChildren, mGroupFlags, mOnHierarchyChangeListener, mPersistentDrawingCache, OPTICAL_BOUNDS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
ACCESSIBILITY_FOCUS_BACKWARD, ACCESSIBILITY_FOCUS_DOWN, ACCESSIBILITY_FOCUS_FORWARD, ACCESSIBILITY_FOCUS_LEFT, ACCESSIBILITY_FOCUS_RIGHT, ACCESSIBILITY_FOCUS_UP, ACCESSIBILITY_FOCUSABLE_AUTO, ACCESSIBILITY_FOCUSABLE_NO, ACCESSIBILITY_FOCUSABLE_YES, ALPHA, DEBUG_LAYOUT_PROPERTY, DRAG_FLAG_GLOBAL, 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, FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS, FIND_VIEWS_WITH_CONTENT_DESCRIPTION, FIND_VIEWS_WITH_TEXT, FOCUS_ACCESSIBILITY, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSABLES_ACCESSIBILITY, FOCUSABLES_ALL, FOCUSABLES_TOUCH_MODE, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, HAPTIC_FEEDBACK_ENABLED, IMPORTANT_FOR_ACCESSIBILITY_AUTO, IMPORTANT_FOR_ACCESSIBILITY_NO, IMPORTANT_FOR_ACCESSIBILITY_YES, INVISIBLE, KEEP_SCREEN_ON, LAYER_TYPE_HARDWARE, LAYER_TYPE_NONE, LAYER_TYPE_SOFTWARE, LAYOUT_DIRECTION_INHERIT, LAYOUT_DIRECTION_LOCALE, LAYOUT_DIRECTION_LTR, LAYOUT_DIRECTION_RTL, mBottom, mCachingFailed, mContext, mCurrentAnimation, MEASURED_HEIGHT_STATE_SHIFT, MEASURED_SIZE_MASK, MEASURED_STATE_MASK, MEASURED_STATE_TOO_SMALL, mInputEventConsistencyVerifier, mLayoutParams, mLeft, mPaddingBottom, mPaddingLeft, mPaddingRight, mPaddingTop, mParent, mRight, mScrollX, mScrollY, mTag, mTop, mUserPaddingBottom, mUserPaddingLeft, mUserPaddingRight, NO_ID, OVER_SCROLL_ALWAYS, OVER_SCROLL_IF_CONTENT_SCROLLS, OVER_SCROLL_NEVER, 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_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, PUBLIC_STATUS_BAR_VISIBILITY_MASK, ROTATION, ROTATION_X, ROTATION_Y, SCALE_X, SCALE_Y, SCREEN_STATE_OFF, SCREEN_STATE_ON, SCROLLBAR_POSITION_DEFAULT, SCROLLBAR_POSITION_LEFT, SCROLLBAR_POSITION_RIGHT, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, STATUS_BAR_DISABLE_BACK, STATUS_BAR_DISABLE_CLOCK, STATUS_BAR_DISABLE_EXPAND, STATUS_BAR_DISABLE_HOME, STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, STATUS_BAR_DISABLE_NOTIFICATION_ICONS, STATUS_BAR_DISABLE_NOTIFICATION_TICKER, STATUS_BAR_DISABLE_RECENT, STATUS_BAR_DISABLE_SYSTEM_INFO, STATUS_BAR_HIDDEN, STATUS_BAR_VISIBLE, SYSTEM_UI_CLEARABLE_FLAGS, SYSTEM_UI_FLAG_FULLSCREEN, SYSTEM_UI_FLAG_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, SYSTEM_UI_FLAG_LAYOUT_STABLE, SYSTEM_UI_FLAG_LOW_PROFILE, SYSTEM_UI_FLAG_VISIBLE, SYSTEM_UI_LAYOUT_FLAGS, TEXT_ALIGNMENT_CENTER, TEXT_ALIGNMENT_DEFAULT, TEXT_ALIGNMENT_GRAVITY, TEXT_ALIGNMENT_INHERIT, TEXT_ALIGNMENT_RESOLVED_DEFAULT, TEXT_ALIGNMENT_TEXT_END, TEXT_ALIGNMENT_TEXT_START, TEXT_ALIGNMENT_VIEW_END, TEXT_ALIGNMENT_VIEW_START, TEXT_DIRECTION_ANY_RTL, TEXT_DIRECTION_DEFAULT, TEXT_DIRECTION_FIRST_STRONG, TEXT_DIRECTION_INHERIT, TEXT_DIRECTION_LOCALE, TEXT_DIRECTION_LTR, TEXT_DIRECTION_RTL, TRANSLATION_X, TRANSLATION_Y, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET, X, Y
 
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.widget.ZoomButtonsController getZoomButtonsController()
          Gets the ZoomButtonsController which can be used to add additional buttons to the zoom controls window.
 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 isOpaque()
           
 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".
protected  void onVisibilityChanged(android.view.View changedView, int visibility)
           
 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)
          Deprecated. Street view availability highlighting is no longer supported. This method operates as a no-op.
 void setTraffic(boolean on)
          Control whether traffic is shown on the map.
 
Methods inherited from class android.view.ViewGroup
addChildrenForAccessibility, addFocusables, addStatesFromChildren, addTouchables, addView, addView, addView, addView, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, canAnimate, childAccessibilityStateChanged, childDrawableStateChanged, childHasTransientStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchConfigurationChanged, dispatchDisplayHint, dispatchDragEvent, dispatchDraw, dispatchFinishTemporaryDetach, dispatchFreezeSelfOnly, dispatchGenericFocusedEvent, dispatchGenericPointerEvent, dispatchGetDisplayList, dispatchHoverEvent, dispatchKeyEvent, dispatchKeyEventPreIme, dispatchKeyShortcutEvent, dispatchRestoreInstanceState, dispatchSaveInstanceState, dispatchSetActivated, dispatchSetPressed, dispatchSetSelected, dispatchStartTemporaryDetach, dispatchSystemUiVisibilityChanged, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchVisibilityChanged, dispatchWindowFocusChanged, dispatchWindowSystemUiVisiblityChanged, dispatchWindowVisibilityChanged, drawableStateChanged, drawChild, endViewTransition, findFocus, findViewByPredicateTraversal, findViewsWithText, findViewToTakeAccessibilityFocusFromHover, findViewTraversal, findViewWithTagTraversal, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getLayoutMode, getLayoutTransition, getPersistentDrawingCache, hasFocus, hasFocusable, hasHoveredChild, hasTransientState, indexOfChild, invalidateChild, invalidateChildFast, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawingOrderEnabled, isChildrenDrawnWithCacheEnabled, isMotionEventSplittingEnabled, isTransformedTouchPointInView, jumpDrawablesToCurrentState, layout, makeOptionalFitsSystemWindows, measureChild, measureChildren, measureChildWithMargins, offsetChildrenTopAndBottom, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onChildVisibilityChanged, onCreateDrawableState, onDebugDraw, onDebugDrawMargins, onInterceptHoverEvent, onInterceptTouchEvent, onRequestFocusInDescendants, onRequestSendAccessibilityEvent, onResolvedLayoutDirectionReset, onResolvedTextAlignmentReset, onResolvedTextDirectionReset, onSetLayoutParams, onViewAdded, onViewRemoved, recomputeViewAttributes, removeAllViews, removeAllViewsInLayout, removeDetachedView, removeView, removeViewAt, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestChildRectangleOnScreen, requestDisallowInterceptTouchEvent, requestFocus, requestSendAccessibilityEvent, requestTransitionStart, requestTransparentRegion, resetAccessibilityStateChanged, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawingOrderEnabled, setChildrenDrawnWithCacheEnabled, setChildrenLayersEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setLayoutMode, setLayoutTransition, setMotionEventSplittingEnabled, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, setStaticTransformationsEnabled, shouldDelayChildPressedState, showContextMenuForChild, startActionModeForChild, startLayoutAnimation, startViewTransition, updateViewLayout
 
Methods inherited from class android.view.View
addFocusables, addOnAttachStateChangeListener, addOnLayoutChangeListener, animate, announceForAccessibility, applyDrawableToTransparentRegion, awakenScrollBars, awakenScrollBars, awakenScrollBars, bringToFront, buildDrawingCache, buildDrawingCache, buildLayer, callOnClick, cancelLongPress, canHaveDisplayList, canResolveLayoutDirection, canResolveTextAlignment, canResolveTextDirection, canScrollHorizontally, canScrollVertically, checkInputConnectionProxy, clearAccessibilityFocus, clearAnimation, combineMeasuredStates, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeOpaqueFlags, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, createAccessibilityNodeInfo, createContextMenu, debug, debugIndent, destroyDrawingCache, destroyHardwareResources, dispatchGenericMotionEvent, dispatchPointerEvent, dispatchPopulateAccessibilityEvent, draw, findViewById, findViewByPredicate, findViewByPredicateInsideOut, findViewWithTag, fitsSystemWindows, focusSearch, forceLayout, getAccessibilityCursorPosition, getAccessibilityFocusable, getAccessibilityNodeProvider, getAccessibilityViewId, getAccessibilityWindowId, getActualAndReportedWindowLeftDelta, getActualAndReportedWindowTopDelta, getAlpha, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getBottomFadingEdgeStrength, getBottomPaddingOffset, getCameraDistance, getContentDescription, getContext, getContextMenuInfo, getDefaultSize, getDisplayList, getDrawableState, getDrawingCache, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFadeHeight, getFadeTop, getFilterTouchesWhenObscured, getFitsSystemWindows, getFocusables, getFocusedRect, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHardwareRenderer, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getHorizontalScrollFactor, getId, getImportantForAccessibility, getIterableTextForAccessibility, getIteratorForGranularity, getKeepScreenOn, getKeyDispatcherState, getLayerType, getLayoutDirection, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLeftPaddingOffset, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMatrix, getMeasuredHeight, getMeasuredHeightAndState, getMeasuredState, getMeasuredWidth, getMeasuredWidthAndState, getMinimumHeight, getMinimumWidth, getNextFocusDownId, getNextFocusForwardId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getOpticalInsets, getOverScrollMode, getPaddingBottom, getPaddingEnd, getPaddingLeft, getPaddingRight, getPaddingStart, getPaddingTop, getParent, getParentForAccessibility, getPivotX, getPivotY, getResolvedLayoutDirection, getResolvedLayoutDirection, getResolvedTextAlignment, getResolvedTextDirection, getResources, getRight, getRightFadingEdgeStrength, getRightPaddingOffset, getRootView, getRotation, getRotationX, getRotationY, getScaleX, getScaleY, getScrollBarDefaultDelayBeforeFade, getScrollBarFadeDuration, getScrollBarSize, getScrollBarStyle, getScrollX, getScrollY, getSolidColor, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getSystemUiVisibility, getTag, getTag, getTextAlignment, getTextDirection, getTop, getTopFadingEdgeStrength, getTopPaddingOffset, getTouchables, getTouchDelegate, getTranslationX, getTranslationY, getVerticalFadingEdgeLength, getVerticalScrollbarPosition, getVerticalScrollbarWidth, getVerticalScrollFactor, getViewRootImpl, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowSystemUiVisibility, getWindowToken, getWindowVisibility, getWindowVisibleDisplayFrame, getX, getY, hackTurnOffWindowResizeAnim, hasOnClickListeners, hasOpaqueScrollbars, hasOverlappingRendering, hasWindowFocus, includeForAccessibility, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, invalidateParentCaches, invalidateParentIfNeeded, isAccessibilityFocusable, isActionableForAccessibility, isActivated, isClickable, isDirty, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHapticFeedbackEnabled, isHardwareAccelerated, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isHovered, isImportantForAccessibility, isInEditMode, isInScrollingContainer, isInTouchMode, isLayoutDirectionRtl, isLayoutRequested, isLayoutRtl, isLongClickable, isPaddingOffsetRequired, isPaddingRelative, isPressed, isRootNamespace, isSaveEnabled, isSaveFromParentEnabled, isScrollbarFadingEnabled, isScrollContainer, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, isVerticalScrollBarHidden, isVisibleToUser, isVisibleToUser, measure, mergeDrawableStates, notifyAccessibilityStateChanged, offsetLeftAndRight, offsetTopAndBottom, onAttachedToWindow, onCheckIsTextEditor, onCloseSystemDialogs, onConfigurationChanged, onCreateContextMenu, onCreateInputConnection, onDisplayHint, onDragEvent, onDrawHorizontalScrollBar, onDrawScrollBars, onDrawVerticalScrollBar, onFilterTouchEventForSecurity, onFinishInflate, onFinishTemporaryDetach, onFocusLost, onGenericMotionEvent, onHoverChanged, onHoverEvent, onInitializeAccessibilityEvent, onInitializeAccessibilityNodeInfo, onKeyLongPress, onKeyMultiple, onKeyPreIme, onKeyShortcut, onOverScrolled, onPaddingChanged, onPopulateAccessibilityEvent, onResolvedLayoutDirectionChanged, onResolvedTextAlignmentChanged, onResolvedTextDirectionChanged, onRestoreInstanceState, onSaveInstanceState, onScreenStateChanged, onScrollChanged, onSetAlpha, onStartTemporaryDetach, onWindowSystemUiVisibilityChanged, onWindowVisibilityChanged, outputDirtyFlags, overScrollBy, performAccessibilityAction, performButtonActionOnTouchDown, performClick, performHapticFeedback, performHapticFeedback, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, postInvalidateOnAnimation, postInvalidateOnAnimation, postOnAnimation, postOnAnimationDelayed, recomputePadding, refreshDrawableState, removeCallbacks, removeOnAttachStateChangeListener, removeOnLayoutChangeListener, requestAccessibilityFocus, requestFitSystemWindows, requestFocus, requestFocus, requestFocusFromTouch, requestLayout, requestRectangleOnScreen, requestRectangleOnScreen, resetResolvedLayoutDirection, resetResolvedTextAlignment, resetResolvedTextDirection, resolveLayoutDirection, resolvePadding, resolveSize, resolveSizeAndState, resolveTextAlignment, resolveTextDirection, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, sendAccessibilityEvent, sendAccessibilityEventUnchecked, setAccessibilityCursorPosition, setAccessibilityDelegate, setAccessibilityFocusable, setActivated, setAlpha, setAnimation, setBackground, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setBottom, setCameraDistance, setClickable, setContentDescription, setDisabledSystemUiVisibility, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setFilterTouchesWhenObscured, setFitsSystemWindows, setFocusable, setFocusableInTouchMode, setFrame, setHapticFeedbackEnabled, setHasTransientState, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setHovered, setId, setImportantForAccessibility, setIsRootNamespace, setKeepScreenOn, setLayerType, setLayoutDirection, setLayoutInsets, setLayoutParams, setLeft, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusForwardId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnClickListener, setOnCreateContextMenuListener, setOnDragListener, setOnFocusChangeListener, setOnGenericMotionListener, setOnHoverListener, setOnKeyListener, setOnLongClickListener, setOnSystemUiVisibilityChangeListener, setOnTouchListener, setOverScrollMode, setPaddingRelative, setPivotX, setPivotY, setPressed, setRight, setRotation, setRotationX, setRotationY, setSaveEnabled, setSaveFromParentEnabled, setScaleX, setScaleY, setScrollBarDefaultDelayBeforeFade, setScrollBarFadeDuration, setScrollbarFadingEnabled, setScrollBarSize, setScrollBarStyle, setScrollContainer, setScrollX, setScrollY, setSelected, setSoundEffectsEnabled, setSystemUiVisibility, setTag, setTag, setTagInternal, setTextAlignment, setTextDirection, setTop, setTouchDelegate, setTranslationX, setTranslationY, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVerticalScrollbarPosition, setVisibility, setWillNotCacheDrawing, setWillNotDraw, setX, setY, showContextMenu, showContextMenu, startActionMode, startAnimation, startDrag, unscheduleDrawable, unscheduleDrawable, verifyDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, getParentForAccessibility, isLayoutRequested, requestFitSystemWindows, requestLayout
 

Constructor Detail

MapView

public MapView(android.content.Context context,
               java.lang.String apiKey)
Constructs a MapView object.

Parameters:
context - A MapActivity 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 of MapActivity.

MapView

public MapView(android.content.Context context,
               android.util.AttributeSet attrs)
Constructs a MapView object.

Parameters:
context - A MapActivity object.
attrs - An attribute set; currently no attributes are used.
Throws:
java.lang.IllegalArgumentException - if the enclosing context is not an instance of MapActivity.

MapView

public MapView(android.content.Context context,
               android.util.AttributeSet attrs,
               int defStyle)
Constructs a MapView object.

Parameters:
context - A MapActivity 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 of MapActivity, 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 class android.view.View

onDetachedFromWindow

protected void onDetachedFromWindow()
Called when being detached, clean up the zoom controls.

Overrides:
onDetachedFromWindow in class android.view.View

computeScroll

public void computeScroll()
Captures scroll events and uses them to pan the map.

Overrides:
computeScroll in class android.view.View

isOpaque

public boolean isOpaque()
Overrides:
isOpaque in class android.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 class android.view.View

onMeasure

protected final void onMeasure(int widthMeasureSpec,
                               int heightMeasureSpec)
Overrides:
onMeasure in class android.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 class android.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 class android.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 interface android.view.KeyEvent.Callback
Overrides:
onKeyDown in class android.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 interface android.view.KeyEvent.Callback
Overrides:
onKeyUp in class android.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 class android.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 not View.isClickable().

Overrides:
onTouchEvent in class android.view.View

onVisibilityChanged

protected void onVisibilityChanged(android.view.View changedView,
                                   int visibility)
Overrides:
onVisibilityChanged in class android.view.View

generateDefaultLayoutParams

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).

Overrides:
generateDefaultLayoutParams in class android.view.ViewGroup

onLayout

protected void onLayout(boolean changed,
                        int left,
                        int top,
                        int right,
                        int bottom)
Specified by:
onLayout in class android.view.ViewGroup

generateLayoutParams

public android.view.ViewGroup.LayoutParams generateLayoutParams(android.util.AttributeSet attrs)
Overrides:
generateLayoutParams in class android.view.ViewGroup

checkLayoutParams

protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams p)
Just checks if p instanceof MapView.LayoutParams.

Overrides:
checkLayoutParams in class android.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 class android.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

@Deprecated
public void setStreetView(boolean on)
Deprecated. Street view availability highlighting is no longer supported. This method operates as a no-op.

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 Overlays 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 call View.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.

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.

getZoomButtonsController

public android.widget.ZoomButtonsController getZoomButtonsController()
Gets the ZoomButtonsController which can be used to add additional buttons to the zoom controls window.

Returns:
The instance of ZoomButtonsController used by this class, or null if it is unavailable.

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.