import com.google.maps.android.SphericalUtilinline fun LatLng.toBounds(radius: Double): LatLngBounds { // radius is in meter val southwest = SphericalUtil.computeOffset(this, radius * Math.sqrt(2.0), 225.0) val northeast = SphericalUtil.computeOffset(this, radius * Math.sqrt(2.0), 45.0) return LatLngBounds(southwest, northeast)}
NOTE: Google Maps Android API Utility Library is used.
build.gradle
(Module)
dependencies {
implementation 'com.google.maps.android:android-maps-utils:0.5'
}