Skip to content

Commit 283012e

Browse files
authored
Fix getPointInView function return wrong point position on Android (#3997)
1 parent b1784c5 commit 283012e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

android/src/main/java/com/rnmapbox/rnmbx/components/mapview/RNMBXMapView.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -901,11 +901,13 @@ open class RNMBXMapView(private val mContext: Context, var mManager: RNMBXMapVie
901901

902902
fun getPointInView(coordinate: Point, response: CommandResponse) {
903903
val point = mMap!!.pixelForCoordinate(coordinate)
904+
val density = getDisplayDensity()
905+
val pointInView = PointF((point.x / density).toFloat(), (point.y / density).toFloat())
904906

905907
response.success {
906908
val array: WritableArray = WritableNativeArray()
907-
array.pushDouble(point.x)
908-
array.pushDouble(point.y)
909+
array.pushDouble(pointInView.x.toDouble())
910+
array.pushDouble(pointInView.y.toDouble())
909911
it.putArray("pointInView", array)
910912
}
911913
}

0 commit comments

Comments
 (0)