简体   繁体   English

在mapview上绘制带有图像的圆

[英]Draw circle with image inside it on mapview

I have to draw a circle and one small .png image inside it on the google mapview, can anyone suggest how to achieve it? 我必须在Google Mapview上画一个圆圈和一个小的.png图像,有人可以建议如何实现吗?

It should display circle on provided latitude and longitude and .png image should be there inside the circle. 它应在提供的经度和纬度上显示圆圈,并且.png图像应在圆圈内。

I tried below code to draw a circle: 我尝试下面的代码画一个圆:

GeoPoint point = new GeoPoint((int) lattitude,

                            (int) longitude);


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

              paint1 = new Paint();
              paint1.setARGB(128,0 , 0, 250);
              paint1.setStrokeWidth(2);
              paint1.setStrokeCap(Paint.Cap.ROUND);
              paint1.setAntiAlias(true);
              paint1.setDither(false);  
              paint1.setStyle(Paint.Style.FILL);
              paint1.setColor(Color.argb(128, 250, 135, 143));

              this.radius = 5000;

              Point pt = mapView.getProjection().toPixels(point, null);
              float projectedRadius =    mapView.getProjection().metersToEquatorPixels(radius);

              canvas.drawCircle(pt.x, pt.y, projectedRadius, paint1);

   }

I am able to draw a circle using above code on provided latitude and longitude but couldn't find a way to draw .png image inside the circle. 我可以在提供的纬度和经度上使用上述代码绘制一个圆,但是找不到在该圆内绘制.png图像的方法。 So idea is to draw circle with .png image inside it on provided latitude and longitude on the mapview. 因此,想法是在地图视图上提供的经度和纬度下绘制带有.png图像的圆。

Please help me to resolve this. 请帮助我解决此问题。

Personally, I would start by visualizing what the png-in-circle would look like and just make an image out of that. 就个人而言,我将从可视化png圆圈的外观开始,然后从中制作图像。 As in, make a png image of a circle with the png you wanted to show in it. 如图所示,用要显示的png制作一个圆形的png图像。 Then, simply place an overlay at the desired lat/lon. 然后,只需在所需的纬度/经度处放置一个覆盖层即可。 See Part 2 of this resource . 请参阅本资源的第2部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM