B4J Question [solved] jGoogleMaps - Can you Clear Infowindow programmatically?

aminoacid

Active Member
Licensed User
Longtime User
In the jGoogleMaps V2.00 example, you can create an info window programmatically when a marker is clicked using the following sub:

B4X:
Private Sub ShowInfoWindow (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("open", Array (jMap, Marker))
    End If
End Sub

To clear (delete/remove/hide) the info window you have to click on the "X" displayed in the window.

How can you do this programmatically, without having to click the "X" or having to delete the marker ?

Thanks!
 

aminoacid

Active Member
Licensed User
Longtime User
B4X:
info.RunMethod("close", Null)

Thanks! I knew it had to be something simple but not being familiar with JavaObject, I couldn't figure out the exact syntax.

Here's the complete sub:

B4X:
Private Sub CloseInfoWindow (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", Null)
    End If
End Sub
 
Upvote 0

aminoacid

Active Member
Licensed User
Longtime User

Yes, you are right. Don't need "jmap". Also, probably only need to pass one parameter "marker".
Thank you.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…