Skip to content

Getting the corners of a square gives mixed results #12

@kaciula

Description

@kaciula

Hi.

I am trying to draw several square polygons on Google Maps and I am getting mixed results. For some coordinates it's drawing a perfect square and for others it's clearly a rectangle. I'm just computing the 4 corners and passing them to Google Maps to draw the polygons. What could be the cause? Am I missing something? The coordinates are very close together in the same neighbourhood in Bucharest, Romania.

List<sp.LatLng> getMiniSquarePolygon(int position) {
    const double latLen = 1; // metres
    final sp.LatLng topLeftCorner = <INITIAL COORDINATES>;
    final sp.LatLng topRightCorner = sp.SphericalUtil.computeOffset(
        topLeftCorner, latLen / cos(topLeftCorner.latitude), 90);
    final sp.LatLng bottomRightCorner =
        sp.SphericalUtil.computeOffset(topRightCorner, latLen, 180);
    final sp.LatLng bottomLeftCorner = sp.SphericalUtil.computeOffset(
        bottomRightCorner, latLen / cos(bottomRightCorner.latitude), 270);
    return <LatLng>[
      topLeftCorner,
      topRightCorner,
      bottomRightCorner,
      bottomLeftCorner,
      topLeftCorner,
    ];
  }

flutter_3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions