2012-10-11 7 views
2

경도 및 위도 매개 변수를 올바르게 전달하여 현재 위치의 MapView을 얻고 있습니다. 하지만 나는 그 그림에 MapView 이미지에 자유로운 손 (즉, 이름이나 줄 등등 ...)처럼 페인트를 그려야합니다. 그것으로부터 나는 사용자에 의해 그 페인트에 MapView 이미지의 전체 이미지를 원합니다. 어떻게해야합니까? Android :지도 뷰에서 페인트를 얻으려면 어떻게해야하나요?

아래 그림과 같이 사용자가 다른 사용자에게 자신의 경로를 보내

...

+0

@Hesham 사이드에 유용 할 greate입니다 .. 나는 이미 사용 전체지도보기를 얻을 것과 페인트 옵션 – NagarjunaReddy

답변

2

사용 오버레이.

public class overlayGeoPoints extends Overlay { 

    private GeoPoint geoPoint; 
    private int radius = 20; 

    @Override 
    public boolean onTap(GeoPoint geoPoint, MapView mapView){ 
      this.geoPoint = geoPoint; 
    } 

    @Override 
    public void draw(Canvas canvas, MapView mapView, boolean shadow) { 

     // put your logic here to draw on the overlay 
     // ie draw a circle 
     Projection projection = mapView.getProjection(); 
     Point point = new Point(); 
     projection.toPixels(geoPoint, point); 

     int px = point.x; 
     int py = point.y; 
     Paint paint = new Paint(paintSecondary.ANTI_ALIAS_FLAG); 
     hl.setColor(intColor); 
     canvas.drawCircle(px, py, radius, paint); 
     canvas.save(); 

    } 
} 

그냥지도에이 오버레이를 추가 See this example Overlays

다음은 예제 코드입니다. 원하는지도 객체 내가 제대로 질문을 이해하면

// get a handle to the map overlays 
List<Overlay> overlays = mapView.getOverlays(); 

// reset overlays as necessary 
//overlays.clear(); 

// create your custom overly class 
overlayGeoPoints olay = new overlayGeoPoints(); 

// append overlay to map overlays 
overlays.add(olay); 

// tell the map object to redraw 
mapView.postInvalidate(); 
+0

을 사용하려면 항목 별 오버레이 ... 그 그림에서 그 그림을 그려야합니다. – NagarjunaReddy

+0

안녕하세요! 이걸로 우리는 확신 할 수 있니? 경로와 텍스트가 좋아? 도와주세요 ... –

+0

지도보기에서 직접 그릴 수는 없습니다. 당신은지도를 오버레이 할 수 있습니다 - 사진, 점, 텍스트 등을 원하는대로 그릴 수 있습니다 ... –

1

를 작성 (지도) AFTER

: 여기에 편집

는 (일반적인) 단계에 의해 단계 drwaing 움직임을 캡처하고지도 위에 표시하십시오.

단계 :

  • 는, 위치 (x, y)의 사용자 탭을 얻을에 손가락을 이동하는 오버레이
  • 재정 onTouchEvent()을 확장하는 새로운 클래스를 생성 GeoPoint의로 변환하고 geopoints 추가 Path 객체에 전달합니다. invalidate()로 전화하면 redrwan지도를 볼 수 있습니다.
  • 무시 onDraw()이 오버레이를 보장하기 위해, mapView.getOverlays()의 끝 부분에 오버레이를 추가, 마지막으로 canvas.drawPath()
  • 위에서 경로 빌드를 그리는 첫 점점 터치 이벤트입니다합니다.

행운을 빕니다.

0
// This file is MapViewDemoActivity.java 
    import android.os.Bundle; 
    import android.view.View; 

    import com.google.android.maps.MapActivity; 
    import com.google.android.maps.MapView; 

     public class MapViewDemoActivity extends MapActivity { 
     private MapView mapView; 

     @Override 
      protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.mapview); 

     mapView = (MapView)findViewById(R.id.mapview); 
     mapView.setBuiltInZoomControls(true); //display zoom controls 
    } 

     @Override 
     protected boolean isLocationDisplayed() { 
      return false; 
    } 

이런 내가뿐만 아니라 경로 단지 이름 등 원하는 모든 http://n3vrax.wordpress.com/2011/08/13/drawing-overlays-on-android-map-view/

관련 문제