Java 在地图上围绕当前位置绘制圆圈,并仅显示该圆圈中的标记,而不是android中的外部圆圈

Java 在地图上围绕当前位置绘制圆圈,并仅显示该圆圈中的标记,而不是android中的外部圆圈,java,android,Java,Android,我可以在地图上围绕当前位置绘制圆圈,但我只想显示圆圈内的标记,并从地图中隐藏其他标记。您需要首先绘制一个圆圈,然后使用此方法比较每个标记在圆圈内或圆圈外 private void checkCircle(){ float[] distance = new float[2]; Location.distanceBetween(marker_latitude, marker_longitude, circle.getCenter().latitude, ci

我可以在地图上围绕当前位置绘制圆圈,但我只想显示圆圈内的标记,并从地图中隐藏其他标记。

您需要首先绘制一个圆圈,然后使用此方法比较每个标记在圆圈内或圆圈外

private void checkCircle(){
    float[] distance = new float[2];

    Location.distanceBetween(marker_latitude, marker_longitude,
            circle.getCenter().latitude, circle.getCenter().longitude, distance);

    if(distance[0] > circle.getRadius()  ){
        Toast.makeText(getContext(), "Outside", Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(getContext(), "Inside", Toast.LENGTH_LONG).show();
    }
}

如果您的标记位于外部,则不需要添加地图。

您需要先绘制一个圆圈,然后使用此方法比较每个标记位于内部或外部

private void checkCircle(){
    float[] distance = new float[2];

    Location.distanceBetween(marker_latitude, marker_longitude,
            circle.getCenter().latitude, circle.getCenter().longitude, distance);

    if(distance[0] > circle.getRadius()  ){
        Toast.makeText(getContext(), "Outside", Toast.LENGTH_LONG).show();
    } else {
        Toast.makeText(getContext(), "Inside", Toast.LENGTH_LONG).show();
    }
}
如果您的标记位于外部,则无需添加地图