Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting the corners of a square gives mixed results #12

Open
kaciula opened this issue May 28, 2021 · 0 comments
Open

Getting the corners of a square gives mixed results #12

kaciula opened this issue May 28, 2021 · 0 comments

Comments

@kaciula
Copy link

kaciula commented May 28, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant