Android Question How to put multiple markers on google map - all at once?

Aries Abedes

Member
Licensed User
I am trying to create a route overview on a map by reading a Latitude and Longitude coordinates from MSSQL DB and trying to plot markers for every coordinates. After looping to the records using cursor and adding it using AddMarker on the Map_ready event, only one marker is visible with 0,0 coordinates. Using same method for a single record, the marker is plotted fine.

Thank you.
 

DonManfred

Expert
Licensed User
Longtime User
After looping to the records using cursor and adding it using AddMarker on the Map_ready event, only one marker is visible with 0,0 coordinates.
So i guess you are only adding ONE instance of a Marker. But without seeing your code it is just fishing.
Show us your code which you are using in your loop.
 
Upvote 0

Aries Abedes

Member
Licensed User
You are right :)

B4X:
Sub mapExplodeAddress_Ready
    Dim query As String
    Dim curCoordinates As Cursor
    Dim marker As Marker
    gmap = mapExplodeAddress.GetMap
   
   
    query = $"
                    select SUBSCRIBER, LONGITUDE, LATITUDE
                        from tblSqliteReleasedPod
                            where RECEIVEDBY is null                   
                "$
   
    curCoordinates = Starter.SQl1.ExecQuery(query)
   
   
   
    For i = 0 To curCoordinates.RowCount - 1
           
        curCoordinates.Position = i
        Subscriber = curCoordinates.GetString("SUBSCRIBER")
        Latitude = curCoordinates.GetDouble("LONGITUDE")
        Longitude = curCoordinates.GetDouble("LATITUDE")
       
        marker = gmap.AddMarker(Latitude, Longitude, "SUBSCRIBER")
        marker.Snippet = Subscriber
    Next   
   
       
   
End Sub
[code]
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
Sub mapExplodeAddress_Ready
    Dim query As String
    Dim curCoordinates As Cursor
    gmap = mapExplodeAddress.GetMap
  
  
    query = $"
                    select SUBSCRIBER, LONGITUDE, LATITUDE
                        from tblSqliteReleasedPod
                            where RECEIVEDBY is null                   
                "$
  
    curCoordinates = Starter.SQl1.ExecQuery(query)
  
  
  
    For i = 0 To curCoordinates.RowCount - 1
          
        curCoordinates.Position = i
        Subscriber = curCoordinates.GetString("SUBSCRIBER")
        Latitude = curCoordinates.GetDouble("LONGITUDE")
        Longitude = curCoordinates.GetDouble("LATITUDE")
      
        Dim marker As Marker ' Moved the dim into the loop to create a new Instance each time
        marker = gmap.AddMarker(Latitude, Longitude, "SUBSCRIBER")
        marker.Snippet = Subscriber
    Next   
  
      
  
End Sub
 
Upvote 0

Aries Abedes

Member
Licensed User
Thanks DonManFred :)

I'm sorry I haven't also noticed this:

Latitude = curCoordinates.GetDouble("LONGITUDE")
Longitude = curCoordinates.GetDouble("LATITUDE")

I have interchanged the value so it's not picking up the right coordinates
 
Upvote 0
Top