javascript GeoJSON 多边形的中心

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15235911/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 23:59:55  来源:igfitidea点击:

Center of a GeoJSON Polygon

javascriptgoogle-mapsleafletgeojson

提问by adm

I'm looking to reposition a JavaScript map based on GeoJSONdata. Can I calculate the center point of a Polygonfrom its array of coordinates? e.g. with:

我希望根据GeoJSON数据重新定位 JavaScript 地图。我可以从其数组计算多边形的中心点coordinates吗?例如:

{
    "data": {
        "type": "Polygon",
        "coordinates": [
            [
                [
                    -9.31640625,
                    43.83452678223682
                ],
                /* etc */
            ]
        ]
    }
}

回答by Rafe

I think this question has been asked before.

我想这个问题以前有人问过。

Have a look at this question. There is an idea that might work for you.

看看这个问题。有一个想法可能对你有用。