【问题标题】:How to remove marker on map如何去除地图上的标记
【发布时间】:2019-04-07 06:57:38
【问题描述】:

我在我的活动中创建了如下标记。

public async void OnMapReady(GoogleMap googleMap)
    {

        MarkerList = new List<Marker>();

        LatLng latLng = new LatLng(16.022,40.3033);

        CameraUpdate cameraUpdate = CameraUpdateFactory.NewLatLngZoom(latLng, 10);
        googleMap.MoveCamera(cameraUpdate);

        MarkerOptions markerOptions = new MarkerOptions();
        markerOptions.Draggable(false);
        markerOptions.SetPosition(latLng);
        googleMap.AddMarker(markerOptions);
        Marker M = googleMap.AddMarker(markerOptions);
        MarkerList.Add(M);

        googleMap.MarkerDragEnd += GoogleMap_MarkerDragEnd;

       // googleMap.SetInfoWindowAdapter(this);
       // googleMap.UiSettings.ZoomControlsEnabled = true;
       // googleMap.UiSettings.CompassEnabled = true;
        googleMap.MoveCamera(CameraUpdateFactory.ZoomTo(150));

    }

在其他事件中,我需要删除那些我编码如下的标记。

foreach(Marker marker in MarkerList)
{
   marker.Remove();
   marker.Visible=false;//this is also not working
}

但地图上没有变化。如何去除地图上的那些标记?

【问题讨论】:

标签: google-maps xamarin.android


【解决方案1】:

我得到了它的小变化

这样的:

googleMap.AddMarker(markerOptions);
Marker M = googleMap.AddMarker(markerOptions);

我放置如下:

Marker M = googleMap.AddMarker(markerOptions);

它成功了。

【讨论】:

    猜你喜欢
    • 2011-01-28
    • 1970-01-01
    • 2014-09-02
    • 1970-01-01
    • 1970-01-01
    • 2018-11-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多