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

How can I get the LatLon coordinates by tap on earth? #9

Closed
take2make opened this issue Apr 27, 2022 · 1 comment
Closed

How can I get the LatLon coordinates by tap on earth? #9

take2make opened this issue Apr 27, 2022 · 1 comment

Comments

@take2make
Copy link

I tried to get coordinates by using the following code:

 void _handleTap(TapUpDetails details) {
    final Vector3 focalCoord = canvasPointToVector3(_lastFocalPoint);
    final Vector3 tapCoord = canvasPointToVector3(details.localPosition);
    Quaternion q = quaternionFromTwoVectors(focalCoord, tapCoord);
    if (_lastQuaternion != null) {
      final _quaternion =
          _lastQuaternion! * q * Quaternion.axisAngle(Vector3(0, 0, 1), 0.0);
      print("ON HANDLE TAP = ${quaternionToLatLon(_quaternion)}");
    }
  }

But it seems that the coordinate calculates from the previous rotation. Do you have any idea or suggestions how can I achieve coordinates on the earth?

@take2make
Copy link
Author

take2make commented Apr 28, 2022

I found the solution:

 void _handleTap(TapUpDetails details) async {
    final Vector3 focalCoord =
        canvasPointToVector3(Offset(width / 2, height / 2));
    final Vector3 tapCoord = canvasPointToVector3(details.localPosition);
    Quaternion q = quaternionFromTwoVectors(focalCoord, tapCoord);
    q *= Quaternion.axisAngle(Vector3(0, 0, 1.0), 0.0);
    if (_lastQuaternion != null) {
      final _quaternion = _lastQuaternion! * q;
      print("ON HANDLE TAP = ${quaternionToLatLon(_quaternion)}");
    }
  }

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