B4J Question Close Googlemaps Info Window

tufanv

Expert
Licensed User
Longtime User
Hello,

I want to programmaticaly close the info screen when clicked on a marker after 5 seconds. I added:

B4X:
Private Sub HideInfoWindow (Marker As Marker, Map As GoogleMap)
    If MarkerInfos.ContainsKey(Marker) Then
        Dim info As JavaObject = MarkerInfos.Get(Marker)
        Dim jMap As JavaObject = Map
        jMap = jMap.GetField("map")
        
        info.RunMethod("close", Array (jMap, Marker))
        
    End If
End Sub

So below code displays info screen but after 5 seconds I get an error.

B4X:
Sub gmap_MarkerClick (SelectedMarker As Marker)
'    For i=0 To listemarker.Size-1
'        HideInfoWindow(listemarker.Get(i),gmap)
'    Next
    ShowInfoWindow(SelectedMarker, gmap)
    Sleep(5000)
    HideInfoWindow(SelectedMarker,gmap)
End Sub

Error is :

B4X:
Error occurred on line: 71 (Main)
java.lang.RuntimeException: Method: close not matched.
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:130)
    at b4j.example.main._hideinfowindow(main.java:306)
    at b4j.example.main$ResumableSub_gmap_MarkerClick.resume(main.java:243)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
    at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$9(PlatformImpl.java:418)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:417)
    at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:175)
    at java.base/java.lang.Thread.run(Thread.java:844)

methos name is close() so It should work. What Am I missing ?
 

Mark Read

Well-Known Member
Licensed User
Longtime User
According to the info, here, there are no parameters in the close function. Have you tried ?

B4X:
info.RunMethod("close", Array ())
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…