如何相对于西方旋转图钉?

How to rotate pins relative to the west?

我在地图上有别针。如何相对于西方旋转这些引脚? 我尝试用 SetRotation() 命令旋转引脚,但引脚相对于父元素旋转。并且当您转动卡时,引脚不会旋转。所以我需要相对于西方转动别针

protected override MarkerOptions CreateMarker(Pin pin)
        {
            string[] words = pin.Address.Split(new char[] { ' ' });
            var marker = new MarkerOptions();
            marker.SetPosition(new LatLng(pin.Position.Latitude, pin.Position.Longitude));
            marker.SetTitle(pin.Label);
            marker.SetSnippet(pin.Type.ToString());
            if (words[0] != "my")
            {
                if (words[0] == "Red")

                    marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.red));
                else marker.SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.white));
            }
            RotatePinWithAngle(marker, words[1]);
            return marker;
        }
        void RotatePinWithAngle(MarkerOptions marker, string angle)
        {
            switch (angle)
            {
                case "left":
                    { 
                        marker.SetRotation(0);
                        break;
                    }
                case "up":
                    {
                        marker.SetRotation(90);
                        break;
                    }
                case "right":
                    {
                        marker.SetRotation(180);
                        break;
                    }
                case "down":
                    {
                        marker.SetRotation(270);
                        break;
                    }
                default:
                    break;
            }
        }

我使用 CustomMap 并且这段代码展示了我尝试旋转汽车图标。 它工作正常,但图标相对于父容器旋转,当我旋转地图时,图标不旋转

您可以旋转地图并保持您的图标不动。 用于旋转地图。你可以使用这个Google Maps API。它支持轴承

  private async void Button_Clicked(object sender, EventArgs e)
        {
            await map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(
                new CameraPosition(
                     new Position(35.71d, 139.81d), // center
                     17d, // zoom
                     45d, // bearing(rotation)
                     60d)), // tilt
                     TimeSpan.FromSeconds(1));
        }

这是运行 GIF。

Here is my demo。如果要测试,请替换AndroidManifest.xml

中的com.google.android.geo.API_KEY
<meta-data android:name="com.google.android.geo.API_KEY" android:value="AIzaSyA2xxxxxxxxxxxxxxxByV1jK5Lzdo" />