欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

android arcgis 绘制圆_arcgis for android 定位 圆

发布时间:2023/12/9 编程问答 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 android arcgis 绘制圆_arcgis for android 定位 圆 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

不多说直接代码 ,群里人共享的

方法一: /**

* 绘制圆,配合 cleargraphicLayer()清除

*

* @param center 圆心

* @param radius 半径

* @param alpha 填充的透明度 0-100

* @param fillColor 填充的颜色

*/

public void DrawCircle(Point center, double radius, int alpha, int fillColor) {

if (graphicLayer == null) { //是否已添加绘制图层

graphicLayer = new GraphicsLayer();

mapView.addLayer(graphicLayer);

}

Polygon polygon = new Polygon();

getCircle(center, radius, polygon);

FillSymbol symbol = new SimpleFillSymbol(fillColor);

SimpleLineSymbol simplelinesymbol = new SimpleLineSymbol(Color.BLUE, (float) 0.5);

symbol.setOutline(simplelinesymbol);

symbol.setAlpha(alpha);

Graphic g = new Graphic(polygon,symbol);

graphicLayer.addGraphic(g);

}

/**

* 获取圆的图形对象

*

* @param center

* @param radius

* @return

*/

public static Polygon getCircle(Point center, double radius) {

Polygon polygon = new Polygon();

getCircle(center, radius, polygon);

return polygon;

}

private static void getCircle(Point center, double radius, Polygon circle) {

circle.setEmpty();

Point[] points = getPoints(center, radius);

circle.startPath(points[0]);

for (int i = 1; i < points.length; i++)

circle.lineTo(points[i]);

}

private static Point[] getPoints(Point center, double radius) {

Point[] points = new Point[50];

double sin;

double cos;

double x;

double y;

for (double i = 0; i < 50; i++) {

sin = Math.sin(Math.PI * 2 * i / 50);

cos = Math.cos(Math.PI * 2 * i / 50);

x = center.getX() + radius * sin;

y = center.getY() + radius * cos;

points[(int) i] = new Point(x, y);

}

return points;

}

方法二:

Polygon polygon = GeometryEngine.buffer(mapPoint,mapView.getSpatialReference(), 100, null); FillSymbol symbol = new SimpleFillSymbol(Color.BLUE); SimpleLineSymbol simplelinesymbol = new SimpleLineSymbol(Color.BLUE,(float) 0.5); symbol.setOutline(simplelinesymbol); symbol.setAlpha(30); Graphic g = new Graphic(polygon, symbol); graphicLayer.addGraphic(g);

总结

以上是生活随笔为你收集整理的android arcgis 绘制圆_arcgis for android 定位 圆的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。