在android中的地图视图中绘制某个半径的圆

前端之家收集整理的这篇文章主要介绍了在android中的地图视图中绘制某个半径的圆前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在地图视图上画一个圆.我想要用户输入半径,对于那个半径,我必须在地图上显示圆.之后,我必须在该圈子的某些位置显示标记.

我知道如何在地图视图上显示标记.

请帮助我在地图视图上绘制圆形,并在该圆形边界上显示标记.

这对我来说非常重要,我试图在互联网上找到提示,但我无法做到这一点.请帮助我……..

提前致谢..

解决方法

在ItemizedOverlay的实现中,从onDraw方法中执行类似于drawCircle的方法
  1. protected void drawCircle(Canvas canvas,Point curScreenCoords) {
  2. curScreenCoords = toScreenPoint(curScreenCoords);
  3. int CIRCLE_RADIUS = 50;
  4. // Draw inner info window
  5. canvas.drawCircle((float) curScreenCoords.x,(float) curScreenCoords.y,CIRCLE_RADIUS,getInnerPaint());
  6. // if needed,draw a border for info window
  7. canvas.drawCircle(curScreenCoords.x,curScreenCoordsy,getBorderPaint());
  8. }
  9.  
  10. private Paint innerPaint,borderPaint;
  11.  
  12. public Paint getInnerPaint() {
  13. if (innerPaint == null) {
  14. innerPaint = new Paint();
  15. innerPaint.setARGB(225,68,89,82); // gray
  16. innerPaint.setAntiAlias(true);
  17. }
  18. return innerPaint;
  19. }
  20.  
  21. public Paint getBorderPaint() {
  22. if (borderPaint == null) {
  23. borderPaint = new Paint();
  24. borderPaint.setARGB(255,82);
  25. borderPaint.setAntiAlias(true);
  26. borderPaint.setStyle(Style.STROKE);
  27. borderPaint.setStrokeWidth(2);
  28. }
  29. return borderPaint;
  30. }
  31.  
  32. @Override
  33. protected void onDraw(Canvas canvas) {
  34. Point p = new Point();
  35. for(OverlayItem item : items) {
  36. drawCircle(canvas,getProjection().toPixels(item.getPoint(),p));
  37. }
  38. }

猜你在找的Android相关文章