目前我在谷歌地图上有一系列标记。我希望能够从我在地图上长按的任何地方获得纬度和经度,并且当我快速点击标记时我想打开一个消息框对话框。我的问题是,通过设置longpress工作,它使得我的onTap函数只有在我点击时才被调用。只有在我没有点击标记时才能使用longlick吗?
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView)
{
return gestureScanner.onTouchEvent(event);
//return false;
}
////////////////////////////////////
// Handle the clicking of a marker
//
////////////////////////////////////
@Override
protected boolean onTap(int index)
{
System.out.println("OnTap");
OverlayItem item = mOverlays.get(index);
int localLat = item.getPoint().getLatitudeE6();
int localLong = item.getPoint().getLongitudeE6();
AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
// Get the titles
dialog.setTitle(item.getTitle());
// Get the text for the message
//dialog.setMessage(item.getSnippet());
dialog.setMessage("Latitude: " + localLat + "\nLongitude: " + localLong);
dialog.setNeutralButton("Ok", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
// TODO Auto-generated method stub
}
});
dialog.show();
return true;
}
@Override
public void onLongPress(MotionEvent e)
{
long downTime = e.getDownTime();
System.out.println("Down time: " + downTime);
System.out.println("LongPress Registered");
GeoPoint p = localMapView.getProjection().fromPixels((int) e.getX(), (int) e.getY());
System.out.println("Latitude = " + p.getLatitudeE6() + " Longitude: " + p.getLongitudeE6());
}