高德已知圆心,半径,计算圆弧坐标

xiaoxiao2021-02-28  59

public void addPolylinescircle(LatLng centerpoint, int radius) { double r = 6371000.79; PolylineOptions options = new PolylineOptions(); int numpoints = 360; double phase = 2 * Math.PI / numpoints; //画图 for (int i = 0; i < numpoints; i++) { /** * 计算坐标点 */ double dx = (radius * Math.cos(i * phase)); double dy = (radius * Math.sin(i * phase));//乘以1.6 椭圆比例 /** * 转换成经纬度 */ double dlng = dx / (r * Math.cos(centerpoint.latitude * Math.PI / 180) * Math.PI / 180); double dlat = dy / (r * Math.PI / 180); double newlng = centerpoint.longitude + dlng; options.add(new LatLng(centerpoint.latitude + dlat, newlng)); } aMap.addPolyline(options.width(10).useGradient(true).setDottedLine(true)); }

转载请注明原文地址: https://www.6miu.com/read-35821.html

最新回复(0)