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

Consider pixel density in coordinate<->point conversion (Android) #2390

Merged
merged 1 commit into from
Sep 9, 2018

Conversation

danielgindi
Copy link
Contributor

Does any other open PR do the same thing?

Nope

What issue is this PR fixing?

pointForCoordinate and coordinateForPoint use raw pixel values, which is inconsistent with other functions and with iOS implementation.

How did you test this PR?

This affects Android code only, and was tested locally in a sample app.

@@ -142,12 +142,14 @@ public void onSnapshotReady(@Nullable Bitmap snapshot) {

@ReactMethod
public void pointForCoordinate(final int tag, ReadableMap coordinate, final Promise promise) {
final ReactApplicationContext context = getReactApplicationContext();
double density = (double) context.getResources().getDisplayMetrics().density;

Choose a reason for hiding this comment

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

I applied these changes to my local node module and was unable to build for android.

I believe this line needs read final double density = (double) [context.getResources().getDisplayMetrics().density;

Once I made this change to the local file, I was able to build. I can also confirm that the PR's code does fix the issue described for android.

Copy link

@jamiesonbates jamiesonbates left a comment

Choose a reason for hiding this comment

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

Line 146 needs to be declared with "final" otherwise the build fails with a scope error.

@danielgindi
Copy link
Contributor Author

Thanks, fixed!

Copy link

@jamiesonbates jamiesonbates left a comment

Choose a reason for hiding this comment

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

I can validate that this PR solves the inaccuracy problem on Android, and does not affect IOS. Everything works as expected. We are using this updated coordinateForPoint in production now. (we have pinned a master version and added critical bug fixes like this).

@danielgindi
Copy link
Contributor Author

danielgindi commented Aug 20, 2018

There are no releases since April, seems like the guys are busy :-)

@rborn
Copy link
Collaborator

rborn commented Sep 9, 2018

LGTM @alvelig 🐽

@alvelig
Copy link
Contributor

alvelig commented Sep 9, 2018

LGTM

@alvelig alvelig merged commit 8124808 into react-native-maps:master Sep 9, 2018
@danielgindi danielgindi deleted the patch-2 branch September 11, 2018 19:03
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

Successfully merging this pull request may close these issues.

4 participants