Public Sub LatLonToXY(ll As LatLng) As Double()
Dim mapJO As JavaObject = gmap
mapJO = mapJO.GetFieldJO("map")
Dim projection As JavaObject = mapJO.RunMethod("getProjection", Null)
Dim bounds As JavaObject = mapJO.RunMethod("getBounds", Null)
Dim ne As LatLng = bounds.RunMethod("getNorthEast", Null)
Dim sw As LatLng = bounds.RunMethod("getSouthWest", Null)
Dim topRight As JavaObject = projection.RunMethod("fromLatLngToPoint", Array(ne))
Dim bottomLeft As JavaObject = projection.RunMethod("fromLatLngToPoint", Array(sw))
'PrintPoint(topRight, "TopRight")
'PrintPoint(bottomLeft, "BottomLeft")
Dim scale As Double = Power(2, gmap.CameraPosition.Zoom)
Dim worldPoint As JavaObject = projection.RunMethod("fromLatLngToPoint", Array(ll))
'PrintPoint(worldPoint, "WorldPoint")
Return Array As Double((worldPoint.RunMethod("getX", Null) - bottomLeft.RunMethod("getX", Null)) * scale, _
(worldPoint.RunMethod("getY", Null) - topRight.RunMethod("getY", Null)) * scale)
End Sub
Sub PrintPoint(p As JavaObject, s As String) 'ignore
Log($"${s}: $1.2{p.RunMethod("getX", Null)} x $1.2{p.RunMethod("getY", Null)}"$)
End Sub