Geometry Utilities
The Android Map SDK provides a set of utility methods for common geospatial calculations, including calculating the straight-line distance between two points, computing the area of a rectangle, converting coordinates, and determining whether a point lies inside a circle or polygon. This guide introduces the key calculation methods.
Calculate the Straight-Line Distance Between Two Points
Calculate the straight-line distance (in meters) between two geographic coordinates specified by latitude and longitude.
float distance = AMapUtils.calculateLineDistance(latLng1, latLng2);Calculate the Area of a Rectangle
The SDK supports calculating the area of a rectangle defined by its top-left and bottom-right coordinates.
float area = AMapUtils.calculateArea(leftTopLatlng, rightBottomLatlng);