Android
com.google.android.maps
public final class

com.google.android.maps.MapController

java.lang.Object
com.google.android.maps.MapController View.OnKeyListener

A utility class to manage panning and zooming of a map.

Summary

Public Methods

          void  animateTo(GeoPoint point, Runnable runnable)
Start animating the map towards the given point.
          void  animateTo(GeoPoint point)
Start animating the map towards the given point.
          void  animateTo(GeoPoint point, Message message)
Start animating the map towards the given point.
          boolean  onKey(View v, int keyCode, KeyEvent event)
Processes key events and translates them into appropriate panning of the map.
          void  scrollBy(int x, int y)
Scroll by a given amount, in pixels.
          void  setCenter(GeoPoint point)
Set the map view to the given center.
          int  setZoom(int zoomLevel)
Sets the zoomlevel of the map.
          void  stopAnimation(boolean jumpToFinish)
Stops any animation that may be in progress, and conditionally update the map center to whatever offset the partial animation had achieved.
          void  stopPanning()
Resets the pan state to make the map stationary.
          boolean  zoomIn()
Zoom in by one zoom level.
          boolean  zoomInFixing(int xPixel, int yPixel)
Zoom in by one zoom level.
          boolean  zoomOut()
Zoom out by one zoom level.
          boolean  zoomOutFixing(int xPixel, int yPixel)
Zoom out by one zoom level.
          void  zoomToSpan(int latSpanE6, int lonSpanE6)
Attempts to adjust the zoom of the map so that the given span of latitude and longitude will be displayed.
Methods inherited from class java.lang.Object
Methods inherited from interface android.view.View.OnKeyListener

Details

Public Methods

public void animateTo(GeoPoint point, Runnable runnable)

Start animating the map towards the given point.

Parameters

point Where to animate the map towards.
runnable If and when the animation reaches its natural conclusion, this callback will be run on the UI thread. The callback will not be run if the animation is aborted.

public void animateTo(GeoPoint point)

Start animating the map towards the given point.

public void animateTo(GeoPoint point, Message message)

Start animating the map towards the given point. If and when the animation reaches its natural conclusion, dispatch the given message (if non-null). The message will not be dispatched if the animation is aborted.

public boolean onKey(View v, int keyCode, KeyEvent event)

Processes key events and translates them into appropriate panning of the map. Defined in View.OnKeyListener.

public void scrollBy(int x, int y)

Scroll by a given amount, in pixels. There will be no animation.

Parameters

x the horizontal scroll amount in pixels.
y the vertical scroll amount in pixels.

public void setCenter(GeoPoint point)

Set the map view to the given center. There will be no animation.

public int setZoom(int zoomLevel)

Sets the zoomlevel of the map. The value will be clamped to be between 1 and 21 inclusive, though not all areas have tiles at higher zoom levels. This just sets the level of the zoom directly; for a step-by-step zoom with fancy interstitial animations, use zoomIn() or zoomOut().

Parameters

zoomLevel At zoomLevel 1, the equator of the earth is 256 pixels long. Each successive zoom level is magnified by a factor of 2.

Returns

  • the new zoom level, between 1 and 21 inclusive.

public void stopAnimation(boolean jumpToFinish)

Stops any animation that may be in progress, and conditionally update the map center to whatever offset the partial animation had achieved.

Parameters

jumpToFinish if true, we'll shortcut the animation to its endpoint. if false, we'll cut it off where it stands.

public void stopPanning()

Resets the pan state to make the map stationary. This could be necessary if we receive a key-down event but will never receive the corresponding key-up.

public boolean zoomIn()

Zoom in by one zoom level. This begins an animated zoom step. If you have added the ZoomControls View (from getZoomControls()), then this will also call through to displayZoomControls(boolean) causing the ZoomControls to appear briefly, but they will not take focus.

Returns

  • true if we managed to zoom in, false if we hit the limit.

public boolean zoomInFixing(int xPixel, int yPixel)

Zoom in by one zoom level. This begins an animated zoom step. If you have added the ZoomControls View (from getZoomControls()), then this will also call through to displayZoomControls(boolean) causing the ZoomControls to appear briefly, but they will not take focus.

This zoom will also pan the map to keep a single point fixed on the screen. Specify the point you want fixed by giving its pixel coordinates.

Parameters

xPixel offset, in pixels from the left of the map, where the fixed point of our zoom will be.
yPixel offset, in pixels from the top of the map, where the fixed point of our zoom will be.

Returns

  • true if we managed to zoom in, false if we hit the limit.

public boolean zoomOut()

Zoom out by one zoom level. This begins an animated zoom step. If you have added the ZoomControls View (from getZoomControls()), then this will also call through to displayZoomControls(boolean) causing the ZoomControls to appear briefly, but they will not take focus.

Returns

  • true if we managed to zoom out, false if we hit the limit.

public boolean zoomOutFixing(int xPixel, int yPixel)

Zoom out by one zoom level. This begins an animated zoom step. If you have added the ZoomControls View (from getZoomControls()), then this will also call through to displayZoomControls(boolean) causing the ZoomControls to appear briefly, but they will not take focus.

This zoom will also pan the map to keep a single point fixed on the screen. Specify the point you want fixed by giving its pixel coordinates.

Parameters

xPixel offset, in pixels from the left of the map, where the fixed point of our zoom will be.
yPixel offset, in pixels from the top of the map, where the fixed point of our zoom will be.

Returns

  • true if we managed to zoom out, false if we hit the limit.

public void zoomToSpan(int latSpanE6, int lonSpanE6)

Attempts to adjust the zoom of the map so that the given span of latitude and longitude will be displayed. Because the zoom can only achieve discrete levels, and because the aspect ratio of the map may not match the ratio given, the quality of the fit may vary. The only thing we guarantee is that, after the zoom, at least one of the new latitude or the new longitude will be within a factor of 2 from the corresponding parameter.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56