2011-07-04 77 views
1

我正在使用Android Google地圖。我通過在Google地圖上的兩點之間繪製路徑

http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html

走了,我不能夠得出兩點之間的完整路徑,如果距離超過200公里。我如何繪製兩點之間的完整路徑?如果有任何許可證問題,是否有任何許可問題,我如何才能獲得許可證。

感謝

+0

使用Google導航URI與您的源和目標緯度/經度 – Sandy

回答

-1
/** Called when the activity is first created. */ 
private List<Overlay> mapOverlays; 

private Projection projection; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    linearLayout = (LinearLayout) findViewById(R.id.zoomview); 
    mapView = (MapView) findViewById(R.id.mapview); 
    mapView.setBuiltInZoomControls(true); 

    mapOverlays = mapView.getOverlays();   
    projection = mapView.getProjection(); 
    mapOverlays.add(new MyOverlay());   

} 

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

class MyOverlay extends Overlay{ 

    public MyOverlay(){ 

    } 

    public void draw(Canvas canvas, MapView mapv, boolean shadow){ 
     super.draw(canvas, mapv, shadow); 

    Paint mPaint = new Paint(); 
     mPaint.setDither(true); 
     mPaint.setColor(Color.RED); 
     mPaint.setStyle(Paint.Style.FILL_AND_STROKE); 
     mPaint.setStrokeJoin(Paint.Join.ROUND); 
     mPaint.setStrokeCap(Paint.Cap.ROUND); 
     mPaint.setStrokeWidth(2); 

     GeoPoint gP1 = new GeoPoint(19240000,-99120000); 
     GeoPoint gP2 = new GeoPoint(37423157, -122085008); 

     Point p1 = new Point(); 
     Point p2 = new Point(); 

    Path path = new Path(); 

    Projection projection.toPixels(gP1, p1); 
     projection.toPixels(gP2, p2); 

     path.moveTo(p2.x, p2.y); 
     path.lineTo(p1.x,p1.y); 

     canvas.drawPath(path, mPaint); 
    } 
+0

通過使用此可以繪製兩點之間的路徑。 – user824330

相關問題