Android Question GoogleMap library, loop throught markers

marcick

Well-Known Member
Licensed User
Longtime User
Hi,
is it possible to query the map and obtain a list of all markers that have been placed and know the title and coordinate of each one ?
Or, again, is it possible to know if a marker with a certain title exist on the map ?
Marco
 

marcick

Well-Known Member
Licensed User
Longtime User
I'm still confused on the correct approach to this library.
Suppose I have to place on the map 50 markers, each one has a different icon, position and a unique title.
Non I want to change something on the marker that has the title "bob".
Do I have to clear all the map and redraw all 50 markers, using the method of the list that you suggest ?
Do I have to create each marker with its own global variable ? (Dim Marker1, Marker2 .....Marker50 As Marker)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
(Dim Marker1, Marker2 .....Marker50 As Marker)
It is never a good idea to create such variables.

You can use a Map to map between the marker "name" and the marker.

For example:
B4X:
Sub AddMarker(Name As String, Text, ...)
  Dim m As Marker = gmap.AddMarker(...)
  MapOfMarkers.Put(Name, m) 'global variable
End Sub

Now you can get any marker you like.
 
Upvote 0
Top