public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
ItemizedOverlay是Overlay的一个基类,ItemizedOverlay包含了一个OverlayItem列表。
用于绘制、创建平移边界、为每个点绘制标记点,和维护一个焦点点中的item,同时负责把屏幕点击匹配到item上去,分发焦点改变事件给备选的监听器。 添加覆盖物的一般流程:
1.用OverlayItem准备Overlay数据信息;
2.继承ItemizedOverlay重写createItem()和size()方法;
3.调用Mapview.getOverlays().add()添加overlay到mapview中;
4.调用Mapview.refresh()使overlay生效。
限定符和类型 | 类和说明 |
---|---|
static interface |
ItemizedOverlay.OnClickListener
点击Overlay监听事件。
|
static interface |
ItemizedOverlay.OnFocusChangeListener
焦点在Overlay发生变化监听事件。
|
Overlay.OverlayTapListener, Overlay.OverlayTouchEventListener, Overlay.OverlayTrackballEventListener
tapListener, touchListener, trackballListener
构造器和说明 |
---|
ItemizedOverlay(Drawable marker)
构造函数。
|
ItemizedOverlay(Drawable marker, int alignment)
构造函数。
|
限定符和类型 | 方法和说明 |
---|---|
void |
clear()
清除所有覆盖物。
|
protected abstract Item |
createItem(int paramInt)
子类通过该方法创建实体item。
|
void |
destroy()
销毁覆盖物。
|
void |
draw(Canvas canvas, MapView mapView, boolean shadow)
绘制覆盖物。
|
BoundingBox |
getBoundingBox()
获取边界框。
|
Point2D |
getCenter()
获取中心点。
|
OverlayItem |
getFocus()
获取关注的焦点。
|
OverlayItem |
getItem(int position)
根据索引获取要绘制的item。
|
int |
getLastFocusedIndex()
获取上一个关注的焦点。
|
boolean |
onKeyUp(int keyCode, KeyEvent event, MapView mapView)
判断是否有相应按键抬起的操作。
|
boolean |
onSnapToItem(int x, int y, Point snapPoint, MapView mapView)
判断是否捕捉到了item。
|
boolean |
onTap(Point2D p, MapView mapView)
判断是否具有点击操作。
|
boolean |
onTouchEvent(MotionEvent evt, MapView mapView)
判断是否存在触屏操作。
|
boolean |
onTrackballEvent(MotionEvent evt, MapView mapView)
判断是否存在跟踪球事件发生。
|
void |
setDrawFocusedItem(boolean drawFocusedItem)
设置绘制的焦点item对象。
|
void |
setFocus(Item item)
设置绘图焦点。
|
protected void |
setLastFocusedIndex(int lastFocusedIndex)
设置最近(或当前)焦点选中的item的索引,如果没有item被选中则设置为-1。
|
void |
setOnClickListener(ItemizedOverlay.OnClickListener l)
设置点击Overlay监听器。
|
void |
setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)
设置焦点变化监听器。
|
abstract int |
size()
返回overlay的item的数目。
|
draw, drawAt, getKey, getZIndex, onKeyDown, setKey, setTapListener, setTouchEventListener, setTrackballEventListener, setZIndex
public ItemizedOverlay(Drawable marker)
构造函数。
marker
- 覆盖物标记。public ItemizedOverlay(Drawable marker, int alignment)
构造函数。
marker
- 覆盖物标记。alignment
-public void draw(Canvas canvas, MapView mapView, boolean shadow)
绘制覆盖物。
protected abstract Item createItem(int paramInt)
子类通过该方法创建实体item。
paramInt
-public abstract int size()
返回overlay的item的数目。
public final OverlayItem getItem(int position)
根据索引获取要绘制的item。
position
- 索引位置。public void clear()
清除所有覆盖物。
public Point2D getCenter()
获取中心点。
public BoundingBox getBoundingBox()
获取边界框。
public void setDrawFocusedItem(boolean drawFocusedItem)
设置绘制的焦点item对象。
drawFocusedItem
- 绘制的焦点item对象。public final int getLastFocusedIndex()
获取上一个关注的焦点。
public OverlayItem getFocus()
获取关注的焦点。
public boolean onKeyUp(int keyCode, KeyEvent event, MapView mapView)
判断是否有相应按键抬起的操作。
public boolean onSnapToItem(int x, int y, Point snapPoint, MapView mapView)
判断是否捕捉到了item。
x
-y
-snapPoint
- 捕捉点的屏幕像素坐标。mapView
- 捕捉点所在地图视图。public void setFocus(Item item)
设置绘图焦点。
item
-protected void setLastFocusedIndex(int lastFocusedIndex)
设置最近(或当前)焦点选中的item的索引,如果没有item被选中则设置为-1。
lastFocusedIndex
- 给定的最近(或当前)焦点选中的item的索引。public boolean onTouchEvent(MotionEvent evt, MapView mapView)
判断是否存在触屏操作。
onTouchEvent
在类中 Overlay
evt
- 触屏操作对象。mapView
- 操作所在的地图视图。public boolean onTrackballEvent(MotionEvent evt, MapView mapView)
判断是否存在跟踪球事件发生。
onTrackballEvent
在类中 Overlay
evt
- 触屏操作对象。mapView
- 操作所在的地图视图。public void setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)
设置焦点变化监听器。
l
- 焦点变化监听器。public void setOnClickListener(ItemizedOverlay.OnClickListener l)
设置点击Overlay监听器。
l
- 点击Overlay监听器。