javascript 在地图上以米为单位绘制半径指定的圆

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17303320/
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-27 07:48:25  来源:igfitidea点击:

drawing circle with radius specified in meters on a map

javascriptd3.jsleafletmapbox

提问by Bala

Any pointers on how to draw a circle of radius, specified in meters, on top of a geographical map using D3 would be pretty helpful.

关于如何使用 D3 在地理地图上绘制以米为单位的半径圆的任何指示都会非常有帮助。

I tried to use Leaflet and it's Circle(or CircleMarker) that accepts radius in meters, but I need more flexibility to play with my data. D3 seems to be pretty helpful, but am not sure how to draw a circle of given radius on top of a map, such the circle covers an area corresponding to the given radius (and adapts to zoom and change in projection).

我尝试使用 Leaflet,它的 Circle(或 CircleMarker)接受以米为单位的半径,但我需要更大的灵活性来处理我的数据。D3 似乎很有帮助,但我不确定如何在地图顶部绘制给定半径的圆,这样的圆覆盖了与给定半径对应的区域(并适应缩放和投影变化)。

回答by geraldarthur

You can pass these radii in meters using the latest version of Leaflet. The radius will change relative to zoom levels.

您可以使用最新版本的 Leaflet 以米为单位传递这些半径。半径将相对于缩放级别而变化。

Here's some more information via Leaflet's documentation

以下是Leaflet 文档中的更多信息

L.circle([lat,lng], radius).addTo(map);