B4J Question jGoogleMaps - Clear/Remove MapMarkers

Declan

Well-Known Member
Licensed User
Longtime User
I am using the following code to place a MapMarker on the Map:

B4X:
GMap.AddMarker2(sendLat, sendLon, markerTxt,File.GetUri(File.DirAssets, "othermark.png"))

How do I clear or remove all previous MapMarkers?
 

DonManfred

Expert
Licensed User
Longtime User
How do I clear or remove all previous MapMarkers?
Addmarker returns the markerobject. Remember it an use
B4X:
markerobj.visible = false
to hide it.

OR use
B4X:
gmap.RemoveMarker(markerobj)
to remove one.

I strongly suggest to check the properties and methods available from the gmap and markerobjects before asking.
 
Last edited:
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Many thanks.
I use the following code to place the marker on the map and add the marker to a list:
B4X:
            cp.Initialize(myLat, myLon, 16)
            mkr = GMap.AddMarker2(myLat, myLon, markerTxt,File.GetUri(File.DirAssets, "othermark.png"))
            lstMarkers.Add(mkr)
            GMap.MoveCamera(cp)
I then use the following code to remove all the markers from the Map:
B4X:
    Log("List of Markers: " & lstMarkers)
    For Each m As Marker In lstMarkers
        GMap.RemoveMarker(m)
    Next
The Log("List of Markers: " & lstMarkers) returns:
B4X:
List of Markers: (ArrayList) [com.lynden.gmapsfx.javascript.object.Marker@27ad97db, com.lynden.gmapsfx.javascript.object.Marker@4a6dde22, com.lynden.gmapsfx.javascript.object.Marker@1a26a8db, com.lynden.gmapsfx.javascript.object.Marker@53fd842, com.lynden.gmapsfx.javascript.object.Marker@4e9bb6f0, com.lynden.gmapsfx.javascript.object.Marker@51eb9bfd]
Is it possible to attach a name to the marker in the list?
For example, can I change "Marker@1a26a8db" to "Marker@INV001" where "INV001" is the unique ID of the device.
I will then be able to identify a marker in order to delete only that marker.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…