English | Site Directory

Android - An Open Handset Alliance Project

com.google.android.maps
public abstract class

com.google.android.maps.Overlay

java.lang.Object
com.google.android.maps.Overlay

Base class representing an overlay which may be displayed on top of a map. To add an overlay, create an implemention of this class and then pass it to add(Overlay, boolean) on the controller obtained from createOverlayController().

Nested Classes
Overlay.PixelCalculator An object capable of converting latitude, longitude into an on-screen pixel coordinate. 
Known Direct Subclasses

Summary

Constants

      Value  
float  SHADOW_X_SKEW  X Skew value for creating a marker shadow in perspective.  -0.9 
float  SHADOW_Y_SCALE  Y Scale value for creating a marker shadow in perspective.  0.5 
int[]  sXYCoords  Coordinate pair for temporary use.     

Public Constructors

          Overlay()

Public Methods

        boolean  draw(Canvas canvas, PixelCalculator calculator, boolean shadow, long when)
Draw call for animated overlays.
        void  draw(Canvas canvas, PixelCalculator calculator, boolean shadow)
Draw the overlay over the map.
        Point  getCenter()
The overlay may suggest a new map center when it is loaded by overriding this method and returning a non-null Point.
        int  getLatSpanE6()
        int  getLonSpanE6()
        String  getTitle()
If the overlay has a title, it can override this method to be listed in the overlay-switcher menu.
    final    boolean  isActive()
        void  onDeactivate()
This will be called before the overlay is deactivated or removed.
        boolean  onTap(DeviceType deviceType, Point p, PixelCalculator calculator)
Handle a tap event.

Protected Methods

      static  void  drawAt(Canvas canvas, Drawable drawable, int x, int y, boolean shadow)
Convenience method to draw a Drawable at an offset.
Methods inherited from class java.lang.Object

Details

Constants

protected static final float SHADOW_X_SKEW

X Skew value for creating a marker shadow in perspective.
Constant Value: -0.9

protected static final float SHADOW_Y_SCALE

Y Scale value for creating a marker shadow in perspective.
Constant Value: 0.5

protected static final int[] sXYCoords

Coordinate pair for temporary use.

Public Constructors

public Overlay()

Public Methods

public boolean draw(Canvas canvas, PixelCalculator calculator, boolean shadow, long when)

Draw call for animated overlays. By default, calls through to draw(Canvas, PixelCalculator, boolean) and returns false.

Parameters

when the timestamp of the draw

Returns

  • true if you need to be drawn again right away; false otherwise. Default implementation returns false.

public void draw(Canvas canvas, PixelCalculator calculator, boolean shadow)

Draw the overlay over the map. This will be called on all active overlays with shadow=true, to lay down the shadow layer, and then again on all overlays with shadow=false. By default, draws nothing.

public Point getCenter()

The overlay may suggest a new map center when it is loaded by overriding this method and returning a non-null Point.

public int getLatSpanE6()

Returns

  • a suggested latidunial map-span for optimal viewing of the overlay. By default, returns -1 to decline to request a span.

public int getLonSpanE6()

Returns

  • a suggested longitudinal map-span for optimal viewing of the overlay. By default, returns -1 to decline to request a span.

public String getTitle()

If the overlay has a title, it can override this method to be listed in the overlay-switcher menu.

public final boolean isActive()

public void onDeactivate()

This will be called before the overlay is deactivated or removed.

public boolean onTap(DeviceType deviceType, Point p, PixelCalculator calculator)

Handle a tap event. By default does nothing and returns false.

Parameters

deviceType the type of the device that generated the tap
p the point that has been tapped
calculator maps lat/lon to screen coordinates.

Returns

  • true if the tap was handled by this overlay.

Protected Methods

protected static void drawAt(Canvas canvas, Drawable drawable, int x, int y, boolean shadow)

Convenience method to draw a Drawable at an offset. x and y are pixel coordinates. You can find appropriate coordinates from latitude/longitude using the object in {@link #draw to call getPointXY(Point, int[]).

Parameters

shadow if true, draw only the drawable's shadow. Otherwise, draw the drawable itself.
Build m5-rc15i - 10 Jun 2008 13:54