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

Accurately determine if the user's location is within the visible map region #102

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ekigamba
Copy link
Contributor

@ekigamba ekigamba commented Feb 8, 2018

This was achieved by:

  1. Getting the actual visible region bounds
  2. Using a better point-in-polygon check algorithm

Fixes #43

1. Get map bounds from mapView size
2. Implement better point-in-polygon checking algorithm
&& positionInQuestion.getLatitude() >= latSouth
&& positionInQuestion.getLongitude() <= lonEast
&& positionInQuestion.getLongitude() >= lonWest);
public static boolean contains(Point[] bounds, Point needle) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use LatLngBounds.contains()? Less code to maintain.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

com.mapbox.mapboxsdk.geometry.LatLngBounds is also available, if you'd rather go the MapBox way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to test this & read up on it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both contains method are the same and inaccurate. They are not comparable

@ekigamba ekigamba changed the title Accurately determine if the user's location in within the visible map region Accurately determine if the user's location is within the visible map region Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accurately determine if the user's location is out-of-view in the map
2 participants