Я хочу получить радиус круга, вписанного в прямоугольник, который является видимой областью на экране ... Google Map SDK предоставляет только nearLeft, farLeft, nearRight и farRight ... С этим я могу получитьэто следующее:
![enter image description here](https://i.stack.imgur.com/e8YSO.png)
Но мне нужно:
.
Я использовал следующий код:
public static double getMapVisibleRadius(GoogleMap map) {
VisibleRegion visibleBounds = map.getProjection().getVisibleRegion();
LatLng center = visibleBounds.latLngBounds.getCenter();
LatLng northEast = visibleBounds.nearLeft;
// r = radius of the earth in km
double r = 6378.8;
// degrees to radians (divide by 57.2958)
double ne_lat = northEast.latitude / 57.2958;
double ne_lng = northEast.longitude / 57.2958;
double c_lat = center.latitude / 57.2958;
double c_lng = center.longitude / 57.2958;
// distance = circle radius from center to Northeast corner of bounds
double r_km = r * Math.acos(
Math.sin(c_lat) * Math.sin(ne_lat) +
Math.cos(c_lat) * Math.cos(ne_lat) * Math.cos(ne_lng - c_lng)
);
return r_km; // radius in meters
}
, который обеспечивает радиус окружности на первом изображении.
Я также пытался использовать расстояние до места, чтобы найти среднюю точкуиз левого и ближнего левого ... Я планировал найти расстояние между центром карты и, следовательно, найти среднюю точку.Однако я не смог получить Latlng этого пункта .. Таким образом, я не смог продолжить ..
VisibleRegion visibleBounds = mGoogleMap.getProjection().getVisibleRegion();
float[] distanceBetweentopAndBottomLeftCorners = new float[1];
float[] distanceBetweenMiddleOfLeftAndCenterOfVisibleRegion = new float[1];
LatLng topLeftCorner = visibleBounds.farLeft;
LatLng bottomLeftCorner = visibleBounds.nearLeft;
Location.distanceBetween(topLeftCorner.latitude, topLeftCorner.longitude, bottomLeftCorner.latitude, bottomLeftCorner.longitude, distanceBetweentopAndBottomLeftCorners );
float centerOfVisibleRegionLeftToScreen = distanceBetweentopAndBottomLeftCorners [0]/2;
// Here I am unable to proceed since the above calculated value is a float and not Latlng. My idea was to find the distance between this value and center of visible bound;
Любая помощь приветствуется.