Android MyOverlay扩展覆盖

【Android MyOverlay扩展覆盖】少年乘勇气,百战过乌孙。这篇文章主要讲述Android MyOverlay扩展覆盖相关的知识,希望能为你提供帮助。

  1. private class MyOverlay extends Overlay {
  2. private GeoPoint center;
  3. private float radius;
  4. private Paint cPaint;
  5.  
  6. public MyOverlay( GeoPoint c) {
  7. center = c;
  8. radius = 20;
  9. cPaint = new Paint( ) ;
  10. }
  11.  
  12. @Override
  13. public void draw( Canvas canvas, MapView mapView, boolean shadow) {
  14. super.draw( canvas, mapView, shadow) ;
  15. if ( shadow == false) {
  16. // class exercise
  17. // Step 1: get pixel coordinate of center (in GeoPoint)
  18. Point screenPt = new Point( ) ;
  19. mapView.getProjection( ) .toPixels( center, screenPt) ;
  20.  
  21. // Step 2: draw a circle at the converted pixel coordinate
  22. cPaint.setColor( Color.RED) ;
  23. cPaint.setAlpha( 100) ;
  24. canvas.drawCircle( screenPt.x, screenPt.y, radius, cPaint) ;
  25. }
  26.  
  27. }
  28. }


    推荐阅读