0
지도를 오래 터치 할 때 새 장소를 추가하고 싶습니다.하지만 문제는지도를 이동할 수없는 오버레이를 추가 할 때입니다. 코드는 다음과 같습니다.지도에서 내 항목 별 오버레이를 제어하는 방법은 무엇입니까?
public class CustomPinPointOverlay extends ItemizedOverlay<OverlayItem> {
private GeoPoint newMarkerLocation;
public CustomPinPointOverlay(GeoPoint newMarkerLocation,
Drawable defaultMarker) {
super(boundCenterBottom(defaultMarker));
this.newMarkerLocation = newMarkerLocation;
populate();
}
@Override
protected OverlayItem createItem(int i) {
return new OverlayItem(this.newMarkerLocation, null, null);
}
public void draw(android.graphics.Canvas canvas, MapView mapView,
boolean shadow) {
super.draw(canvas, mapView, false);
}
@Override
public int size() {
return 1;
}
}
이것은 itemizedoverlay를 확장하는 오버레이 클래스입니다. 코드의 다른 부분은;
public PMapView(Context context, AttributeSet attrs) {
super(context, attrs);
setOnTouchListener(new OnTouchListener() {
int x, y;
long start, stop;
@Override
public boolean onTouch(View v, MotionEvent e) {
if (e.getAction() == MotionEvent.ACTION_DOWN) {
start = e.getEventTime();
x = (int) e.getX();
y = (int) e.getY();
touchedPoint = map.getProjection().fromPixels(x, y);
}
if (e.getAction() == MotionEvent.ACTION_UP) {
stop = e.getEventTime();
}
if (stop - start > 1000) {
setEnabled(true);
Drawable myMarker = getResources().getDrawable(
R.drawable.yeni_pin);
getOverlays().add(
new CustomPinPointOverlay(touchedPoint, myMarker));
return false;
}
return true;
}
});
}
이 코드에는 어떤 문제가 있습니까?
문제는 내 setOnTouchListener라고 생각합니다. 내 의견으로는 setontouch 리스너는 길게 누르기 전까지 내 터치를 듣고 있습니다. 나는 stop-start> 1000을 제외하고는 아무 것도하지 않으면 내 setontouchlistener는 내가 할 때까지 계속 듣고있다. 내가 맞습니까? – sharp