Android Question why marker properties does not change ?

marcick

Well-Known Member
Licensed User
Longtime User
In this code, I see the changes in the log, but nothing happens on the map.
Also Marker1.remove or any other action on the marker has not effect
Where I'm wrong ?

B4X:
Sub Mapfragment1_MarkerClick (Marker1 As Marker) As Boolean
      
    Log(Marker1.Snippet)
    Marker1.Snippet="new snippet"
    Log(Marker1.Snippet)
 ''   Marker1.remove 
   
   Return True
  
End Sub
 

marcick

Well-Known Member
Licensed User
Longtime User
....
the MarkerClick event already contains the selected marker, you can call it "marker1", "selectedmarker", there is no difference
Am I wrong ?
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
I have tried your example. It works as it should...
B4X:
Sub Activity_Create(FirstTime As Boolean)
   MapPanel.Initialize("")
   Activity.AddView(MapPanel, 0, 0, 100%x, 100%y)
   If mFragment.IsGooglePlayServicesAvailable = False Then
      ToastMessageShow("Google Play services not available.", True)
   Else
      mFragment.Initialize("Map", MapPanel)
   End If
End Sub

Sub Map_Ready
   Log("map ready")
   gmap = mFragment.GetMap
   If gmap.IsInitialized = False Then
        ToastMessageShow("Error initializing map.", True)
   Else 
        Dim MarkerOptions1 As MarkerOptions
        MarkerOptions1.Initialize

        Dim Marker1 As Marker
        Dim Marker2 As Marker
        Marker1= gmap.AddMarker( 64.47619, 18.3980,"pkt1") ',LoadBitmap(File.DirAssets, "icon1.png")) ' Ok so far
        Marker1.Snippet= "pkt1"
        MarkerOptions1.Position2(64.99619, 17.3980).Snippet("pkt2").Title("pkt2")
        Marker2=GoogleMapsExtras1.AddMarker(gmap, MarkerOptions1)    
 
        Dim cp As CameraPosition
        cp.Initialize(64, 18, gmap.CameraPosition.Zoom)
        gmap.AnimateCamera(cp)
   End If
End Sub
Sub Map_MarkerClick (SelectedMarker As Marker) As Boolean 'Return True to consume the click
    Log(SelectedMarker.Snippet)
    SelectedMarker.Snippet="new snippet"
    Log(SelectedMarker.Snippet)
    'Return True
End Sub
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
It works ...
After changing the snippet, there was another wrong part of code that restored the old snippet, so I didn't see the difference.
ANyway you can call it "SeelectedMarker" or "MyMarker" that it works.
Thanks Croid and Eurojam, bye
 
Upvote 0
Top