[英]How to find Center Latlng of a polygon in Google Map (Android, Java)
我正在使用以下代碼查找多邊形的中心,以便在多邊形上打印一些文本,但不適用於圖片中顯示的多邊形(末尾的圖像鏈接)
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;
}
如何找到多邊形的中心標簽(如下圖所示),並且該標簽應位於多邊形內。
不,中心不應該在多邊形中。 中心是包含所有點的邊界的中心 。
該中心可用於使視圖居中。
您所說的多邊形中心到底是什么意思? 您如何定義它?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.