Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在谷歌地图中找到多边形的中心板条(Android,Java)_Java_Android_Google Maps_Google Maps Api 3 - Fatal编程技术网

如何在谷歌地图中找到多边形的中心板条(Android,Java)

如何在谷歌地图中找到多边形的中心板条(Android,Java),java,android,google-maps,google-maps-api-3,Java,Android,Google Maps,Google Maps Api 3,我正在使用下面的代码查找多边形的中心,以便在多边形上打印一些文本,但它不适用于末尾的pictureimage链接中显示的多边形 private LatLng getPolygonCenterPoint(ArrayList<LatLng> polygonPointsList){ LatLng centerLatLng = null; LatLngBounds.Builder builder = new LatLngBounds.Builder(); for(in

我正在使用下面的代码查找多边形的中心,以便在多边形上打印一些文本,但它不适用于末尾的pictureimage链接中显示的多边形

private LatLng getPolygonCenterPoint(ArrayList<LatLng> polygonPointsList){
    LatLng centerLatLng = null;
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    for(int i = 0 ; i < polygonPointsList.size() ; i++)
    {
        builder.include(polygonPointsList.get(i));
    }
    LatLngBounds bounds = builder.build();
    centerLatLng =  bounds.getCenter();

    return centerLatLng;
}
如何找到图片下方多边形的中心板条,板条应位于多边形内部。

不,中心不应该在多边形中。中心是包含所有点的边界的中心。 此中心对于居中视图很有用


你所说的多边形的中心到底是什么意思?你如何定义它

可能的重复不是重复,但由于多边形是凹面的,您可以查看以下内容:LatLngBounds.getCenter被很好地定义为点的平均值;你的第一个任务是正确地定义你所说的中心,它将始终如一地得到你想要的。也许在你的图片上放一个点来帮助解释。我需要找到应该在多边形内部的几乎中心坐标,因为我需要在中心放一些文本