2016-08-13 58 views
1

我正在使用GoogleMap片段使用标记显示一些位置数据。我想要做的是,在地图上绘制一个具有特定距离半径的圆,以便该圆将近似地覆盖地图上的某个区域。我不知道从哪里开始,我已经有一个地图显示位置数据,从位置数据我可以找出这些点距离中心位置的距离。如何在地图上绘制一个覆盖特定距离的圆圈

任何帮助将是伟大的。

回答

1

使用GoogleMap Circle API。您只需要通过必需的输入并完成。从示例中关注链接。 e.g从文档,简单的代码结构看起来像这样

Circle circle = map.addCircle(new CircleOptions() 
    .center(new LatLng(-33.87365, 151.20689)) // center point of map 
    .radius(10000) // radius of circle to cover on map 
    .strokeColor(Color.RED) //color of circle boundary 
    .fillColor(Color.BLUE)); //color of circle to fill , 
           // make sure choose the light color close to transparent 
1

使用此功能,你需要通过LatLngparamater,当你调用它。

private void drawCircle(LatLng point){ 

    CircleOptions circleOptions = new CircleOptions(); 

    // Specifying the center of the circle 
    circleOptions.center(point); 

    // Radius of the circle 
    circleOptions.radius(20); 

    // Border color of the circle 
    circleOptions.strokeColor(Color.BLACK); 

    // Fill color of the circle 
    circleOptions.fillColor(0x30ff0000); 

    // Border width of the circle 
    circleOptions.strokeWidth(2); 

    // Adding the circle to the GoogleMap 
    googleMap.addCircle(circleOptions); 

}