getSquaredDistanceToClosestEdge method

Future<num?> getSquaredDistanceToClosestEdge(
  1. MPPoint point
)

Calculates the squared distance from the point to the closest edge in the polygon.

The unit is 0.25 x squared metres on both platforms, which is what the native SDKs return rather than a metre value. A distance in metres is 2 * sqrt(result).

Returns -1 when point lies outside the polygon's bounding box. That is a sentinel rather than a very small distance, so code that ranks locations by proximity has to filter it out instead of sorting on it. Geometry the platform cannot read throws a PlatformException rather than returning a value.

Implementation

Future<num?> getSquaredDistanceToClosestEdge(MPPoint point) async =>
    await UtilPlatform.instance
        .geometryGetSquaredDistanceToClosestEdge(this, point);