如何在地图上拖动标记? 如何在onTouchEvent()中处理它?</ p>
我写了一个实际拖延的代码。但感觉就像地图正在移动而不是标记。该代码如下:
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
/*Action to be taken on ACTION_UP(value=1) and ACTION_DOWN(value=0)*/
if(event.getAction() == 0 || event.getAction() == 1){
mapView.displayZoomControls(true);
}
/*Action to be taken on ACTION_MOVE(value=2)*/
if(event.getAction() == 2){
for(int i = 0; i < mOverlays.size() ; i++){
mOverlays.remove(i);
}
GeoPoint point = mapView.getProjection().fromPixels((int) event.getX(),(int)
event.getY());
OverlayItem overlayItem = new OverlayItem(point, "", "");
addOverlay(overlayItem);
mapView.getController().setCenter(point);
}
return true;
}
有没有解决方案?