B4J Question How to display the mouse position lat/long like in Google Earth

bvonlaar

Member
Licensed User
Longtime User
Hi,
when I move the mouse over google maps I want to display the changing position lat/long in 2 label fields like in Google Earth. How can I grab the mouse position and realize it?

Regards,
Benedikt
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4X:
'in gmap_Ready  
Dim jo As JavaObject = gmap
   Dim event As Object = jo.CreateEventFromUI("com.lynden.gmapsfx.javascript.event.UIEventHandler", "MouseMove", Null)
   jo.GetFieldJO("map").RunMethod("addUIEventHandler", Array("mousemove", event))

Sub MouseMove_Event (MethodName As String, Args() As Object) As Object
   Dim jo As JavaObject = Args(0)
   jo = jo.RunMethod("getMember", Array("latLng"))
   Dim ll As LatLng = jo.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.LatLong", Array(jo))
   Log(ll)
   Return Null
End Sub
 
Upvote 0

bvonlaar

Member
Licensed User
Longtime User
B4X:
'in gmap_Ready 
Dim jo As JavaObject = gmap
   Dim event As Object = jo.CreateEventFromUI("com.lynden.gmapsfx.javascript.event.UIEventHandler", "MouseMove", Null)
   jo.GetFieldJO("map").RunMethod("addUIEventHandler", Array("mousemove", event))

Sub MouseMove_Event (MethodName As String, Args() As Object) As Object
   Dim jo As JavaObject = Args(0)
   jo = jo.RunMethod("getMember", Array("latLng"))
   Dim ll As LatLng = jo.InitializeNewInstance("com.lynden.gmapsfx.javascript.object.LatLong", Array(jo))
   Log(ll)
   Return Null
End Sub


Cool !!!! Was a great help!!

Much thanks,
Benedikt
 
Upvote 0
Top