English | Site Directory

Android - An Open Handset Alliance Project

com.google.android.maps.MapView

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
com.google.android.maps.MapView

A View which displays a map. When focused, it will capture keypresses to pan and zoom the map. It can also be controlled programmatically () and can draw a number of Overlays on top of the map (). 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.

Nested Classes
MapView.DeviceType Distinguishes what type of device initiated an event. 
MapView.OnLongPressListener Interface definition for a callback to be invoked when the user has performed a longPress gesture in a MapView. 
MapView.ReticleDrawMode Allow the user to specify the mode in which the reticle is drawn  

Summary

XML Attributes inherited from class android.view.View
Constants inherited from class android.view.View
Fields inherited from class android.view.View

Public Constructors

          MapView(Context context)
Constructs a mapView object.
          MapView(Context context, AttributeSet attrs, Map inflateParams)
Constructs a mapView object.

Public Methods

        boolean  canCoverCenter()
        OverlayController  createOverlayController()
        void  displayZoomDialog(float x, float y)
Display a zoom dialog.
        void  freezeTo(Bundle state)
Saves the state of the MapView to a Bundle.
        MapController  getController()
        int  getLatitudeSpan()
        int  getLongitudeSpan()
        Point  getMapCenter()
        int  getMaxZoomLevel()
        int  getZoomLevel()
        boolean  isEdgeZooming()
Returns true if you can zoom the map by sliding your finger along the right edge of the screen.
        boolean  isSatellite()
        boolean  isShowMyLocation()
        boolean  isStreetView()
        boolean  isTraffic()
        void  onFocusChanged(boolean hasFocus, int direction, Rect unused)
Catch focus changed events to stop panning (since we might not get the keyUp anymore)
        boolean  onKeyDown(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform press of the view when KEYCODE_DPAD_CENTER or KEYCODE_NEWLINE is released, if the view is enabled and clickable.
        boolean  onKeyUp(int keyCode, KeyEvent event)
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_NEWLINE is released.
        boolean  onLongPress(float x, float y)
Call this view's OnLongPressListener, if it is defined.
        boolean  onTouchEvent(MotionEvent ev)
Dispatch a motion event.
        boolean  onTrackballEvent(MotionEvent event)
Implement this method to handle trackball motion events.
        void  onWindowFocusChanged(boolean hasFocus)
Catch focus changed events to stop panning (since we might not get the keyUp anymore)
        void  preLoad()
Preload the tiles at the map's current center.
        void  setOnLongPressListener(OnLongPressListener l)
Register a callback to be invoked when the user presses and holds on the view.
        void  setReticleDrawMode(ReticleDrawMode mode)
Specify how the reticle should be drawn.
        void  thawFrom(Bundle state)
Restores the state of the MapView to a Bundle.
        void  toggleEdgeZooming()
Toggles the current value for edge zooming and stores that as a preferences.
        void  toggleSatellite()
Toggles from satellite to map mode (and back).
        void  toggleShowMyLocation()
Toggles whether the user's current location is shown or not
        void  toggleStreetView()
Toggles whether the Street View overlay is shown.
        void  toggleTraffic()
Toggles whether traffic is shown on the map.

Protected Methods

        void  onDraw(Canvas canvas)
The main draw method.
        void  onSizeChanged(int w, int h, int oldw, int oldh)
This is called during layout when the size of this view has changed.
Methods inherited from class android.view.View