Android Question MapFragment with CustomListView

Multiverse app

Active Member
Licensed User
Longtime User
The Goal is to Add MapFragment with Customlistview while using LazyLoading. After the mapfragment is ready, add a marker to all of the maps.


The Problem is that at VisibleRangeChanged, mfclvorders_Ready is called for only the last MapFragment. Therefore, All the maps except the last are left blank.

The Following code populates the customlistview by looping through a map 'mapor':
                            For j = 0 To mapor.Size - 1
                                Dim CLI As CreateListItemClvOrders:CLI.Initialize
                                Dim IncomingMapnext As Map=mapor.GetValueAt(j)

                                    Dim xui As XUI
                                    Dim p As B4XView = xui.CreatePanel("")
                                    p.SetLayoutAnimated(300, 0, 0, clvorders.AsView.Width, 50%y)
                                    clvorders.Add(p, CLI)


Code for VisibleRangeChanged:
    Dim ExtraSize As Int = 1
    For i = 0 To clvorders.GetSize-1
        Dim p As B4XView = clvorders.GetPanel(i)
        If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
            If p.NumberOfViews = 0 Then
                Dim CLI As CreateListItemClvOrders = clvorders.GetValue(i)

                Wait For mfclvorders_Ready
                Dim maptemp As Map=CLI.maporders
                mfclvorders.GetMap.AddMarker(maptemp.Get("latitude"), bllon=maptemp.Get("longitude"), "Pickup Point").Snippet="Pickup Point"
                Dim cp As CameraPosition:cp.Initialize(maptemp.Get("latitude"), bllon=maptemp.Get("longitude"), 10)

            End If
           'not visible
           If p.NumberOfViews > 0 Then
               p.RemoveAllViews '<--- remove the layout
           End If
        End If

MapFragment is not a view(does not return a base panel). So, calling clvorders.GetItemFromView(mfclvorders) outside the VisibleRangeChanged is also not possible.
How to solve this problem?
Last edited:

Multiverse app

Active Member
Licensed User
Longtime User
It doesn't sound like a good approach. How many maps do you need? You should reuse the same one or two maps.
the number of maps is unsure. That is why we are trying to use lazy loading.
I don't see how using 2 maps is possible. The goal is to make a list of all the 'orders' posted by users and set the location marker on each location of the order.
Upvote 0