use*_*858 1 javascript leaflet mapbox
有人知道mapbox或leaflet是否可以检测一个点是否位于L.Circle内?谢谢。
也许试试这个?所有的距离都以米为单位。
var radius = circle.getRadius(); //in meters
var circleCenterPoint = circle.getLatLng(); //gets the circle's center latlng
var isInCircleRadius = abs(circleCenterPoint.distanceTo(pointToTest)) <= radius;Run Code Online (Sandbox Code Playgroud)
解释:
你说的有道理。你有圆的中心点。你可以只测量点和圆之间的距离,取两者之间的绝对值,如果它小于圆的半径,那么它应该在圆内。
对?