Pra*_*tik 6 android google-maps
我在地图上绘制圆圈并指定半径,它将成功绘制圆圈.但是当我使用搜索栏更改圆圈的大小时,我需要在屏幕上放置圆圈并缩放该级别的地图,我不知道这个,需要你的指南谢谢你.
Ana*_*ari 15
我们还可以从绘制的圆圈中获取地图的缩放级别
Circle circle = googleMap.addCircle(circleOptions);
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(
circleOptions.getCenter(), getZoomLevel(circle)
Run Code Online (Sandbox Code Playgroud)
// Methode for zoomlevel
public int getZoomLevel(Circle circle) {
int zoomLevel = 11;
if (circle != null) {
double radius = circle.getRadius() + circle.getRadius() / 2;
double scale = radius / 500;
zoomLevel = (int) (16 - Math.log(scale) / Math.log(2));
}
return zoomLevel;
}
Run Code Online (Sandbox Code Playgroud)
经过很长时间我从某处找到了解决方案。
这是给我最小纬度/经度和最大纬度/经度的方法。基于此我得到了经度和经度。
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));
}
Run Code Online (Sandbox Code Playgroud)
现在您通过任何单位的距离,因为您必须通过地球半径,例如,如果您通过,2 km则地球半径以公里为单位6370.997。
你可以尝试一下,这很酷
| 归档时间: |
|
| 查看次数: |
4288 次 |
| 最近记录: |