如何使用 XamarinFormsMaps 在自定义地图上更改和标记/固定图标?

问题描述

我需要自定义我的图钉/标记,我已经添加了所有需要的渲染器和类,但我仍然不知道如何更改标记和放置图像。

我遵循了 Microsoft https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/map-pin#consuming-the-custom-map

的步骤

我的问题是地图实现

CustomPin pin = new CustomPin
        {
            Type = PinType.Place,Label = "Test pin",Position = new Position(37.79752,-122.40183)
        };
        map.CustomPins = new List<CustomPin> { pin };
        map.Pins.Add(pin);

我需要添加/更改什么才能放置资源中已有的图像作为此图钉的标记

现在它只需要一个名为 pin.png 的图像,我作为一个 pin,但有时也需要使用不同的图像

渲染器有这个:

protected override MarkerOptions CreateMarker(Pin pin)
        {
            var marker = new MarkerOptions();
            marker.SetPosition(new LatLng(pin.Position.Latitude,pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Address);
            marker.SetIcon(BitmapDescriptorFactory.Fromresource(Resource.Drawable.pin));
            return marker;
        }

直接选择Resource.Drawable.pin,也许可以调用并更改它,但我不知道如何使用它。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)