I believe that your square radius is much smaller than the radius of the earth (6371 km) so that you can safely ignore the curvature of the earth.
Then the math is pretty simple:
// center of square double latitudeCenter = ...; // in degrees double longitudeCenter = ...; // in degrees double radius = ...; // in km double RADIUS_EARTH = 6371; // in km // north-east corner of square double latitudeNE = latitudeCenter + Math.toDegrees(radius / RADIUS_EARTH); double longitudeNE = longitudeCenter + Math.toDegrees(radius / RADIUS_EARTH / Math.cos(Math.toRadians(latitudeCenter))); // south-west corner of square double latitudeSW = latitudeCenter - Math.toDegrees(radius / RADIUS_EARTH); double longitudeSW = longitudeCenter - Math.toDegrees(radius / RADIUS_EARTH / Math.cos(Math.toRadians(latitudeCenter)));
Example:
Center (lat, bosom) at 48.00,11.00 and a radius of 10 km
will give the NE-angle (lat, lon) at 48.09,11.13 and the SW-angle (lat, lon) at 47.91,10.87 .
And here's how to do it using LatLng and the Bounds API google-maps-services-java :
public static final double RADIUS_EARTH = 6371; public static Bounds boundsOfCircle(LatLng center, double radius) { Bounds bounds = new Bounds(); double deltaLat = Math.toDegrees(radius / RADIUS_EARTH); double deltaLng = Math.toDegrees(radius / RADIUS_EARTH / Math.cos(Math.toRadians(center.lat))); bounds.northeast = new LatLng(center.lat + deltaLat, center.lng + deltaLng); bounds.southwest = new LatLng(center.lat - deltaLat, center.lng - deltaLng); return bounds; }
source share