Android Question [SOLVED] Google map and truck icon for my position

yfleury

Active Member
Licensed User
Longtime User
Hi every body
I need to show on google map a truck icon for my position right on the blue dot and follow it.

I try that
B4X:
Public Sub LocationChanged(Location1 As Location)
    gmap.AddMarker3(gmap.MyLocation.Latitude, gmap.MyLocation.Longitude,"", LoadBitmap( File.DirAssets, "truck.png"))

End Sub

But the truck icon is duplicate as infinite.

Can you help me to the right way?
 

yfleury

Active Member
Licensed User
Longtime User
You are adding a new marker on each locationchange. What do you expect?
Create one marker and change the position of this marker in the location changed event
I do some research
I find that but is not working

in sub Globals
B4X:
    Private MapAdresses As MapFragment
    Private gmap As GoogleMap
    Public TracteurIcon As Marker

in Public Sub LocationChanged(Location1 As Location)
B4X:
        Dim latLnt As LatLng
        latLnt.Initialize(Location1.Latitude, Location1.Longitude)
        TracteurIcon.Position=latLnt

in Sub MapAdresses_Ready
B4X:
    Dim LatLng1 As LatLng
    LatLng1.Initialize(40,-71)
    TracteurIcon = gmap.AddMarker3(LatLng1.Latitude, LatLng1.Longitude,"", (LoadBitmap( File.DirAssets, "tracteur-vert1.png")))

The tracteurIcon is not show
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Is it visible if you comment the code in LocationChanged sub?
Before I comment the code in LocationChanged sub, I change the refresh in gps1.start
B4X:
Public Sub StartGps
    If gpsStarted = False Then
        GPS1.Start( 0,0)
        gpsStarted = True
    End If
End Sub

I comment TracteurIcon = gmap.........
and is not visible

Some where in my code I have a gmap.clear after a TracteurIcon is set. Is it right I need to add a marker (TracteurIcon) again?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…