如何根据地图上的圆形绘制找到缩放级别 [英] How to find zoom level based on circle draw on map
问题描述
我正在指定半径的情况下在地图上绘制圆,它将成功绘制圆.但是,当我使用搜寻栏更改圆的大小时,我需要将圆放置在屏幕上并缩放该级别的地图,对此我一无所知,需要您的指导原则.
I am drawing the circle on map with specifying the radius and it'll draw the circle successfully. But when I change the size of circle using seekbar I need to feet the circle in screen and zoom the map of that level, I have not idea about this, need your guideline thank you.
推荐答案
很长一段时间后,我从某个地方找到了解决方案.
After long time I found the solution from somewhere.
这是给我最小lat/lng和最大lat/lng的方法.基于此,我得到了latspan和longspan.
here is the method which was giving me the min lat/lng and max lat/lng. Based on this I have getting the latspan and longspan.
public void boundingCoordinates(double distance, double radius) {
if (radius < 0d || distance < 0d)
throw new IllegalArgumentException();
// angular distance in radians on a great circle
double radDist = distance / radius;
double radLat = Math.toRadians(gp.getLatitudeE6()/1e6); // here is your single point latitude gp.getLatitude
double radLon = Math.toRadians(gp.getLongitudeE6()/1e6); // here is your single point longitude gp.getlongitude
double minLat = radLat - radDist;
double maxLat = radLat + radDist;
double minLon, maxLon;
if (minLat > MIN_LAT && maxLat < MAX_LAT) {
double deltaLon = Math.asin(Math.sin(radDist) /Math.cos(radLat));
minLon = radLon - deltaLon;
if (minLon < MIN_LON)
minLon += 2d * Math.PI;
maxLon = radLon + deltaLon;
if (maxLon > MAX_LON)
maxLon -= 2d * Math.PI;
} else {
// a pole is within the distance
minLat = Math.max(minLat, MIN_LAT);
maxLat = Math.min(maxLat, MAX_LAT);
minLon = MIN_LON;
maxLon = MAX_LON;
}
minLat = Math.toDegrees(minLat);
minLon = Math.toDegrees(minLon);
maxLat = Math.toDegrees(maxLat);
maxLon = Math.toDegrees(maxLon);
minGeo = new GeoPoint((int)(minLat*1e6),(int)(minLon*1e6));
maxGeo = new GeoPoint((int)(maxLat*1e6),(int)(maxLon*1e6));
}
现在您按照必须通过地球半径的任何单位传递距离,例如,如果通过 2 km
,则地球半径以km为单位,则说 6370.997
.
now you pass the distance in any unit as per that you have to pass the radius of earth for example if you pass 2 km
then the radius of earth is in km say 6370.997
.
您可以尝试一下,它很酷的东西
you can try it, its cool thing
这篇关于如何根据地图上的圆形绘制找到缩放级别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!