Can I do onTap that doesn't require a longpress, but still have longpress enabled for other events?
Currently I have a series of markers on a google map. I want to be able to get the latitude and longitu开发者_开发问答de from anywhere I longclick on the map and I want to open a message box dialog when I quick click on a marker. My issue is that by setting up longpress to work it makes it so my onTap function only gets called when I longclick. Is it possible for longlick to work only when I'm not clicking on a marker?
@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());
}
Here's something similar here that might be helpful. You can also override the onTouchEvent()
of the Overlay to handle each.
精彩评论