Sub GetLatLngAt25PercentFromBottom(markerPos As LatLng, zoom As Float, bearing As Float) As ResumableSub
' Step 1: center the invisible map on the marker with the given bearing and zoom
Dim cp As CameraPosition
cp.Initialize2(markerPos.Latitude, markerPos.Longitude, zoom, bearing, 0)
gmapcalc.MoveCamera(cp)
' Step 2: wait until the invisible map has finished moving
Wait For (WaitMapIdle) Complete (ok As Boolean)
' Step 3: calculate the screen coordinates of the point at 25% from the bottom
Dim mapWidth As Int = PnlMapCalc.Width ' panels containing the invisible map
Dim mapHeight As Int = PnlMapCalc.Height
Dim screenX As Int = mapWidth / 2
Dim screenY As Int = mapHeight * 0.25
Dim joMap As JavaObject = gmapcalc
Dim projection As JavaObject = joMap.RunMethod("getProjection", Null)
Dim pointClass As JavaObject
pointClass.InitializeNewInstance("android.graphics.Point", Array(screenX, screenY))
Dim targetLatLng As JavaObject = projection.RunMethod("fromScreenLocation", Array(pointClass))
Dim result As LatLng
result.Initialize(targetLatLng.GetField("latitude"), targetLatLng.GetField("longitude"))
Return result
End Sub