谷歌地图Android:圆圈上方的标记

谷歌地图Android:圆圈上方的标记,android,google-maps,marker,Android,Google Maps,Marker,我想在我的应用程序中实现这一点,我知道要画一个圆,但我需要在下图中显示圆右上方的标记 如果有人知道这个plz,我想在圆圈上方10公里处显示请帮助我 我知道,但我能找到解决办法 如果您知道圆的横向(外边缘)绘制,这对我也有帮助。在onMapReady()方法中添加以下代码: 在onMapReady()方法中添加以下代码: @Adny是正确的,我也在使用SphereCalutil类来解决这类问题 您可以在此git中使用这个SphereCalutil类 您可以使用此方法绘制10Km的标记 /**

我想在我的应用程序中实现这一点,我知道要画一个圆,但我需要在下图中显示圆右上方的标记

如果有人知道这个plz,我想在圆圈上方10公里处显示请帮助我

我知道,但我能找到解决办法


如果您知道圆的横向(外边缘)绘制,这对我也有帮助。

onMapReady()方法中添加以下代码:


onMapReady()方法中添加以下代码:


@Adny是正确的,我也在使用SphereCalutil类来解决这类问题

您可以在此git中使用这个SphereCalutil

您可以使用此方法绘制10Km的标记

/**
 * Returns the location of origin when provided with a LatLng destination,
 * meters travelled and original heading. Headings are expressed in degrees
 * clockwise from North. This function returns null when no solution is
 * available.
 * @param to       The destination LatLng.
 * @param distance The distance travelled, in meters.
 * @param heading  The heading in degrees clockwise from north.
 */
public static LatLng computeOffsetOrigin(LatLng to, double distance, double heading) {
    heading = toRadians(heading);
    distance /= EARTH_RADIUS;
    // http://lists.maptools.org/pipermail/proj/2008-October/003939.html
    double n1 = cos(distance);
    double n2 = sin(distance) * cos(heading);
    double n3 = sin(distance) * sin(heading);
    double n4 = sin(toRadians(to.latitude));
    // There are two solutions for b. b = n2 * n4 +/- sqrt(), one solution results
    // in the latitude outside the [-90, 90] range. We first try one solution and
    // back off to the other if we are outside that range.
    double n12 = n1 * n1;
    double discriminant = n2 * n2 * n12 + n12 * n12 - n12 * n4 * n4;
    if (discriminant < 0) {
        // No real solution which would make sense in LatLng-space.
        return null;
    }
    double b = n2 * n4 + sqrt(discriminant);
    b /= n1 * n1 + n2 * n2;
    double a = (n4 - n2 * b) / n1;
    double fromLatRadians = atan2(a, b);
    if (fromLatRadians < -PI / 2 || fromLatRadians > PI / 2) {
        b = n2 * n4 - sqrt(discriminant);
        b /= n1 * n1 + n2 * n2;
        fromLatRadians = atan2(a, b);
    }
    if (fromLatRadians < -PI / 2 || fromLatRadians > PI / 2) {
        // No solution which would make sense in LatLng-space.
        return null;
    }
    double fromLngRadians = toRadians(to.longitude) -
            atan2(n3, n1 * cos(fromLatRadians) - n2 * sin(fromLatRadians));
    return new LatLng(toDegrees(fromLatRadians), toDegrees(fromLngRadians));
}
/**
*当提供LatLng目的地时,返回起始位置,
*米和原航向。标题以度表示
*从北顺时针方向。当未找到解决方案时,此函数返回null
*可用。
*@param到目的地LatLng。
*@param distance行驶的距离,单位为米。
*@param航向从北顺时针方向以度为单位的航向。
*/
公共静态LatLng computeOffsetOrigin(LatLng to,双距离,双航向){
航向=环面(航向);
距离/=接地半径;
// http://lists.maptools.org/pipermail/proj/2008-October/003939.html
双n1=cos(距离);
双n2=sin(距离)*cos(航向);
双n3=sin(距离)*sin(航向);
双n4=sin(环面(至纬度));
//b有两种解决方案。b=n2*n4+/-sqrt(),一种解决方案产生结果
//在[-90,90]范围之外的纬度。我们首先尝试一种解决方案,然后
//如果我们在那个范围之外,就退后一步。
双n12=n1*n1;
双判别式=n2*n2*n12+n12*n12-n12*n4*n4;
if(判别式<0){
//没有真正的解决方案,这将是有意义的LatLng空间。
返回null;
}
双b=n2*n4+sqrt(判别式);
b/=n1*n1+n2*n2;
双a=(n4-n2*b)/n1;
双弧度=atan2(a,b);
如果(从纬度<-PI/2 | |从纬度>PI/2){
b=n2*n4-sqrt(判别式);
b/=n1*n1+n2*n2;
fromLatRadians=atan2(a,b);
}
如果(从纬度<-PI/2 | |从纬度>PI/2){
//在拉丁空间中没有合理的解决方案。
返回null;
}
双fromLngRadians=toRadians(至经度)-
atan2(n3,n1*cos(fromLatRadians)-n2*sin(fromLatRadians));
返回新板条(toDegrees(从板条弧度)、toDegrees(从梯度));
}

@Adny在这方面是正确的,我也在使用SphereCalutil类来解决这类问题

您可以在此git中使用这个SphereCalutil

您可以使用此方法绘制10Km的标记

/**
 * Returns the location of origin when provided with a LatLng destination,
 * meters travelled and original heading. Headings are expressed in degrees
 * clockwise from North. This function returns null when no solution is
 * available.
 * @param to       The destination LatLng.
 * @param distance The distance travelled, in meters.
 * @param heading  The heading in degrees clockwise from north.
 */
public static LatLng computeOffsetOrigin(LatLng to, double distance, double heading) {
    heading = toRadians(heading);
    distance /= EARTH_RADIUS;
    // http://lists.maptools.org/pipermail/proj/2008-October/003939.html
    double n1 = cos(distance);
    double n2 = sin(distance) * cos(heading);
    double n3 = sin(distance) * sin(heading);
    double n4 = sin(toRadians(to.latitude));
    // There are two solutions for b. b = n2 * n4 +/- sqrt(), one solution results
    // in the latitude outside the [-90, 90] range. We first try one solution and
    // back off to the other if we are outside that range.
    double n12 = n1 * n1;
    double discriminant = n2 * n2 * n12 + n12 * n12 - n12 * n4 * n4;
    if (discriminant < 0) {
        // No real solution which would make sense in LatLng-space.
        return null;
    }
    double b = n2 * n4 + sqrt(discriminant);
    b /= n1 * n1 + n2 * n2;
    double a = (n4 - n2 * b) / n1;
    double fromLatRadians = atan2(a, b);
    if (fromLatRadians < -PI / 2 || fromLatRadians > PI / 2) {
        b = n2 * n4 - sqrt(discriminant);
        b /= n1 * n1 + n2 * n2;
        fromLatRadians = atan2(a, b);
    }
    if (fromLatRadians < -PI / 2 || fromLatRadians > PI / 2) {
        // No solution which would make sense in LatLng-space.
        return null;
    }
    double fromLngRadians = toRadians(to.longitude) -
            atan2(n3, n1 * cos(fromLatRadians) - n2 * sin(fromLatRadians));
    return new LatLng(toDegrees(fromLatRadians), toDegrees(fromLngRadians));
}
/**
*当提供LatLng目的地时,返回起始位置,
*米和原航向。标题以度表示
*从北顺时针方向。当未找到解决方案时,此函数返回null
*可用。
*@param到目的地LatLng。
*@param distance行驶的距离,单位为米。
*@param航向从北顺时针方向以度为单位的航向。
*/
公共静态LatLng computeOffsetOrigin(LatLng to,双距离,双航向){
航向=环面(航向);
距离/=接地半径;
// http://lists.maptools.org/pipermail/proj/2008-October/003939.html
双n1=cos(距离);
双n2=sin(距离)*cos(航向);
双n3=sin(距离)*sin(航向);
双n4=sin(环面(至纬度));
//b有两种解决方案。b=n2*n4+/-sqrt(),一种解决方案产生结果
//在[-90,90]范围之外的纬度。我们首先尝试一种解决方案,然后
//如果我们在那个范围之外,就退后一步。
双n12=n1*n1;
双判别式=n2*n2*n12+n12*n12-n12*n4*n4;
if(判别式<0){
//没有真正的解决方案,这将是有意义的LatLng空间。
返回null;
}
双b=n2*n4+sqrt(判别式);
b/=n1*n1+n2*n2;
双a=(n4-n2*b)/n1;
双弧度=atan2(a,b);
如果(从纬度<-PI/2 | |从纬度>PI/2){
b=n2*n4-sqrt(判别式);
b/=n1*n1+n2*n2;
fromLatRadians=atan2(a,b);
}
如果(从纬度<-PI/2 | |从纬度>PI/2){
//在拉丁空间中没有合理的解决方案。
返回null;
}
双fromLngRadians=toRadians(至经度)-
atan2(n3,n1*cos(fromLatRadians)-n2*sin(fromLatRadians));
返回新板条(toDegrees(从板条弧度)、toDegrees(从梯度));
}

在回答您发布的问题时,您可以清楚地看到步骤2中圆圈各个点的纬度和经度。我认为SphereCalutil.computeOffset(from、distance、heading)是您想要的-给定您选择的圆心(from)、圆半径(distance)和方向,然后您可以在返回的位置添加标记。请看-。@Andy谢谢你的评论,让我查一查it@Greggz在第2步中,给定的纬度长度非常不同在你发布的问题的答案中,你可以在第2步中清楚地看到圆的各个点的纬度和经度。我认为SphereCalutil。computeOffset(起点、距离、航向)是你想要的-给定圆心(起点),圆半径(距离)和您选择的方向,然后您可以在返回的位置添加标记。请看-。@Andy谢谢你的评论,让我查一查it@Greggz在步骤2中,给定的lat long非常不同