Google지도에 손가락으로 그림을 그려야합니다. 나는 그 선이 그려진 것을 이미 성취했다. .. 그러나지도가 또한 움직일 때 나는 손가락 주위에 작은 원을 그릴 수 있기 때문에지도가 나의 손가락과 함께 또한 움직인다. 그래서 나는 잘 그려진다. ...android지도가 운동을 사용 중지합니다.
지도의 이동 (드래그)을 비활성화하고 손가락으로 오버레이를 그릴 수 있습니까?
나의 현재 코드는 다음과 같습니다
public class OverlayMap extends Overlay {
private List<MapGeoLine> geoLines = new ArrayList<MapGeoLine>();
private List<GeoPoint> geoPoints;
private boolean isTouched = false;
@Override
public boolean onTouchEvent(MotionEvent motionEvent, MapView mapView) {
if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
geoPoints = new ArrayList<GeoPoint>();
geoPoints.add(mapView.getProjection().fromPixels((int)motionEvent.getX(),(int)motionEvent.getY()));
isTouched = true;
}
if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){
if(isTouched){
geoPoints.add(mapView.getProjection().fromPixels((int)motionEvent.getX(),(int)motionEvent.getY()));
}
}
if(motionEvent.getAction() == MotionEvent.ACTION_UP){
if(isTouched){
geoPoints.add(mapView.getProjection().fromPixels((int)motionEvent.getX(),(int)motionEvent.getY()));
}
isTouched = false;
}
return super.onTouchEvent(motionEvent, mapView);
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
if(geoPoints != null && geoPoints.size() > 1 && !isTouched){
Paint mPaint = new Paint();
mPaint.setStrokeWidth(2);
mPaint.setStyle(Paint.Style.STROKE);
mPaint.setAntiAlias(true);
Projection projection = mapView.getProjection();
Point from = new Point();
Point to = new Point();
Path p = new Path();
projection.toPixels(geoPoints.get(0), from);
for(int i = 1; i < geoPoints.size(); i++){
projection.toPixels(geoPoints.get(i), to);
p.moveTo(from.x, from.y);
p.lineTo(to.x, to.y);
from.set(to.x, to.y);
}
canvas.drawPath(p, mPaint);
mapView.invalidate();
}
super.draw(canvas, mapView, shadow);
}
}
이 질문은 Google Maps API V3에 관한 것이 아닙니다. (태그 제거) – Marcelo