1
현재 Google지도에 일련의 아이콘이 있습니다. 어디에서나 위도와 경도를 얻을 수 있기를 원하며, 마커를 빠르게 클릭하면 메시지 상자 대화 상자를 열고 싶습니다. 내 문제는 긴 프레스를 작동 시켜서 작동하도록 만들어서 onclock 함수가 longclick 일 때만 호출되도록 만든다. 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());
}
onTouchEvent()를 재정의하고 있지만 GestureDetector를 설정하는 것입니다. onTap 이벤트를 자연스럽게 발생시키는 방법이 있습니까? 이것은 모두 ItemizedOverlay를 기반으로합니다. 더 나은 개념을 위해 초 단위로 코드를 게시합니다. – Geeklat
LongPress를 그냥 누르면 누른 좌표를 표시하는 것처럼 보이기 때문에 LongPress를 처리하는 다른 오버레이로 이동하는 방법은 어떻습니까? 한 번에 둘 이상의 오버레이를 가질 수 있습니다. GestureDetector.SimpleOnGestureListener를 사용하면됩니다. LongPress 메서드 만 구현하면 ItemizedOverlay에서 GestureDetector를 제거 할 수 있습니다. – dbryson