iOS Question iterate over markers

Tomeu Payeras

New Member
Licensed User
Longtime User
Hi,

when I try to iterate over markers in a GoogleMap I got this error message during compilation:
use of undeclared identifier 'GMSMarker'; did you mean 'B4IMarker'?

my code is something like this
B4X:
Public gmap as GoogleMap
gmap.Initialize("gmap",ApiKey)

'some markers added (and correctly displayed)

For Each m As Marker in gmap   '<---this is the line with the compilation error
...
Next

Any help?
 

Tomeu Payeras

New Member
Licensed User
Longtime User
Thank you. I have tested with a List and the error messages is the same:
B4i line: 55
For Each mk As Marker In mlist
use of undeclared identifier 'GMSMarker'; did you mean 'B4IMarker'?
This is the code, based on GoogleMaps tutorial sample:
B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4i Example
    #Version: 1.0.0 
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #PlistExtra:<key>NSLocationWhenInUseUsageDescription</key><string>Used to display the current navigation data.</string>
    #PlistExtra:<key>NSLocationUsageDescription</key><string>Used to display the current navigation data.</string>
#End Region

Sub Process_Globals
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Private gmap As GoogleMap
    Private ApiKey As String = "**********"
    Public mlist As List
End Sub

Private Sub Application_Start (Nav As NavigationController)
    NavControl = Nav
    Page1.Initialize("Page1")
    Page1.Title = "Page 1"
    Page1.RootPanel.Color = Colors.White
    NavControl.ShowPage(Page1)
    AddMap
    removeMarkers
End Sub


Private Sub AddMap
    gmap.Initialize("gmap", ApiKey)
    Page1.RootPanel.AddView(gmap, 0, 0, 100%X, 100%y)
    gmap.MapType = gmap.MAP_TYPE_TERRAIN
   
    mlist.Initialize    
   
    'add three markers
    Dim m As Marker = gmap.AddMarker(40, 30, "test")
    m.Snippet = "Marker 1"
    m.Opacity = 0.5
    mlist.Add(m)
    m = gmap.AddMarker2(40, 31, "Marker 2", Colors.Green)
    mlist.Add(m)
    gmap.AddMarker3(20, 20, "ddd", LoadBitmap(File.DirAssets, "up76.png"))
    mlist.Add(m)
End Sub

Private Sub Page1_Resize(Width As Int, Height As Int)
    If gmap.IsInitialized Then gmap.SetLayoutAnimated(0, 1, 0, 0, Width, Height)
End Sub

Sub removeMarkers
    For Each mk As Marker In mlist
        mk.Remove
    Next
End Sub
 
Upvote 0
Top