Android Question Add marker again, after removing

schimanski

Well-Known Member
Licensed User
My sub checks, if a marker is inizialized or not. If not, the marker is add to the googlemap-card. If yes, i only change the position of the marker.
The problem I have, that after removing the marker with marker1().remove, the marker is no longer shown in the map, but it seems, that the removed marker is always inizialized. If I start my sub Marker_einzeichnen, the marker could not be add again to the map, I only can change the position of the 'removed' marker.
How can I set the removed marker to uninizialized?

B4X:
Sub Process_Globals
  Public Map1 As Map
  Public Marker1(150) As Marker
...
End Sub

Sub Marker_einzeichnen
   Dim Zaehler As Int=0
   
     For Each key As String In Map1.Keys
  Dim Liste As List
  Liste=Map1.Get(key)
   
  If Marker1(Zaehler).IsInitialized=True Then
  Dim ll As LatLng
  ll.Initialize(Liste.Get(4)/100000, Liste.Get(5)/100000)
  Marker1(Zaehler).Position=ll   
  Else
  Marker1(Zaehler)=GoogleMap1.AddMarker2(Liste.Get(4)/100000, Liste.Get(5)/100000, key, GoogleMap1.HUE_RED)
  End If
  Zaehler=Zaehler+1
  Next
End Sub

Sub Marker_loeschen
  For i=0 To Map1.size-1
  Marker1(i).Remove
  Next
End Sub
 
Top