android arcgis 绘制圆_ArcGIS For Android 定位绘图工具 [中心点,误差圆]
/**
* 定位繪圖
*
* @author wuxin
* @time 10:29
*/
public class DrawLocate {
private static Graphic graphicCenterPoint;
private static Graphic graphicErrorRound;
/**
* 繪制定位
* @param center 中心點(diǎn)
* @param radius 誤差圓半徑(單位:米)
* @param graphicsLayer 繪制圖層
* @param centerImage 中心點(diǎn)圖片
* @param errorRoundColorFill 誤差圓顏色
* @param errorRoundColorLine 誤差圓邊線顏色
*/
public static void drawPoint(Point center, double radius,
GraphicsLayer graphicsLayer, Drawable centerImage,
int errorRoundColorFill, int errorRoundColorLine) {
/* 清除圖層 */
if(graphicsLayer != null){
graphicsLayer.removeAll();
}
/* 繪制中心點(diǎn) */
PictureMarkerSymbol symbol = new PictureMarkerSymbol(centerImage);
symbol.setOffsetY(10.0f);
graphicCenterPoint = new Graphic(center, symbol);
/* 繪制誤差圓 */
if(radius > 0){
Polygon polygon = new Polygon();
getCircle(center, radius, polygon);
FillSymbol fillSymbol = new SimpleFillSymbol(errorRoundColorFill);
fillSymbol.setAlpha(10);
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(errorRoundColorLine, 2.0f, SimpleLineSymbol.STYLE.SOLID);
fillSymbol.setOutline(lineSymbol);
graphicErrorRound = new Graphic(polygon, fillSymbol);
}
/* 繪制上圖 */
graphicsLayer.addGraphics(new Graphic[]{graphicCenterPoint, graphicErrorRound});
}
/**
* 獲取圓的圖形對(duì)象
*
* @param center
* @param radius
* @return
*/
public static Polygon getCircle(Point center, double radius) {
Polygon polygon = new Polygon();
getCircle(center, radius, polygon);
return polygon;
}
/**
*
* @param center
* 中心點(diǎn)
* @param radius
* 半徑(米)
* @param circle
* 圓的圖形對(duì)象
*/
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]);
}
/**
* 通過(guò)中心點(diǎn)和半徑計(jì)算得出圓形的邊線點(diǎn)集合
*
* @param center
* @param radius
* @return
*/
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;
}
}
引用方式:
DrawLocate.drawPoint(point, location.getRadius(), baiduLayer, image, Color.parseColor("#0099FF"), Color.parseColor("#0099FF"));
總結(jié)
以上是生活随笔為你收集整理的android arcgis 绘制圆_ArcGIS For Android 定位绘图工具 [中心点,误差圆]的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java web 跨域_java web
- 下一篇: java aes密钥生成_如何在Java