getCoordinateRange(lat, lng) {
let that = this;
const distance = 3; // 3公里
const radLatitude = that.degreesToRadians(lat);
const radLongitude = that.degreesToRadians(lng);
const radDistance = distance / 6371;
// 计算圆的边界经纬度
const minLatitude = radLatitude - radDistance;
const maxLatitude = radLatitude + radDistance;
const minLongitude = radLongitude - Math.asin(Math.sin(radDistance) / Math.cos(radLatitude));
const maxLongitude = radLongitude + Math.asin(Math.sin(radDistance) / Math.cos(radLatitude));
// 将其转换为角度并输出结果
const minLatitudeDeg = minLatitude * 180 / Math.PI;
const maxLatitudeDeg = maxLatitude * 180 / Math.PI;
const minLongitudeDeg = minLongitude * 180 / Math.PI;
const maxLongitudeDeg = maxLongitude * 180 / Math.PI;
}
degreesToRadians(degrees) {
return degrees * Math.PI / 180;
},
根据一个坐标点获取距离3公里最大、最小的经度和维度
猜你喜欢
转载自blog.csdn.net/weirdo_world/article/details/131091882
今日推荐
周排行