// in meterval radius = 30.0// optional: to get distance to circle radius, not the edgeval distance = radius * sqrt(2.0)val center = LatLng(3.1412, 101.68653)val ne = SphericalUtil.computeOffset(center, distance, 45.0)val sw = SphericalUtil.computeOffset(center, distance, 225.0)val bounds = RectangularBounds.newInstance(sw, ne)
Dependencies
dependencies {
implementation 'com.google.maps.android:android-maps-utils:0.5'
}
Kotlin extensions
fun LatLng.toBounds(distance: Double): RectangularBounds { val center = this val ne = SphericalUtil.computeOffset(center, distance, 45.0) val sw = SphericalUtil.computeOffset(center, distance, 225.0) return RectangularBounds.newInstance(sw, ne)}
References: