如何使用Kotlin删除Google Maps中的标记?

问题描述 投票:0回答:1

如何删除其他标记,我只希望看到currentLocation标记

val currentLocation = LatLng(location!!.latitude,location.longitude)

  mMap!!.addMarker(MarkerOptions().position(currentLocation).title(Common.trackUser!!.email)
                .snippet(Common.getDateFormatted(Common.convertTimeStampToDate(location.time))))
                .setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))
google-maps kotlin marker
1个回答
0
投票

这应删除所有标记:

mMap.clear();

创建标记时,您应该执行以下操作:

newMarker = mMap!!.addMarker(....)

然后您可以将标记添加到列表中:

markerList.add(newMarker)

这可以通过使用markerList数组来进一步控制地图上的标记。

© www.soinside.com 2019 - 2024. All rights reserved.