Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android]getMetersPerPixelAtLatitude in DP #16587

Open
IlyaChizhanov opened this issue Feb 12, 2021 · 1 comment
Open

[android]getMetersPerPixelAtLatitude in DP #16587

IlyaChizhanov opened this issue Feb 12, 2021 · 1 comment

Comments

@IlyaChizhanov
Copy link

I checked it. It is really in DP.

Platform: Android
Mapbox SDK version: 9.5.0

val countPx = 100f
val pointA: LatLng = mapboxMap.projection.fromScreenLocation(PointF(0f, 0f))
val pointB: LatLng = mapboxMap.projection.fromScreenLocation(PointF(countPx, 0f))
val metersInPixel = mapboxMap.projection.getMetersPerPixelAtLatitude(radiusPoint.latitude)

val distance = pointA.distanceTo(pointB)
val distanceOnScreen = metersInPixel * countPx
val distanceOnScreenInDp = metersInPixel * context.pxToDp(countPx)

assertEquals(distance, distanceOnScreen) // assert
assertEquals(distance, distanceOnScreenInDp) // good
@oseiskar
Copy link

This is a semi-recent regression. The value was correct (in pixels, not dp) in Mapbox 8.0.0

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

No branches or pull requests

2 participants