天天看点

android arcgis 绘制圆_arcgis for android 定位 圆

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

方法一: 

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);

}

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);