微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法更改MapView [Xamarin]的大小

如何解决无法更改MapView [Xamarin]的大小

我的自定义viewRenderer中有一个MapView。我正在尝试将其尺寸设置为:

        public CustomMapRenderer()
        {
            var camera = CameraPosition.FromCamera(47.497913,19.040236,15);
           
            mapView = new MapView(new CGRect(0,414,200),camera);  //also tried with this: mapView = MapView.FromCamera(new CGRect(0,camera);

            this.AddSubview(mapView);

            ...
         }

如果我在调试器中进行了检查,则该视图似乎仍保持全屏(414 * 896)。由于找不到太多文档,我问我是否正确设置了它?如果是这样,那是一个错误吗?我应该如何更改视图的大小?

编辑:也添加了相关的XAML代码

嵌入地图的XAML是:

<?xml version="1.0" encoding="UTF-8"?>
<attractionbase:AttractionContentListItemBase xmlns="http://xamarin.com/schemas/2014/forms" 
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 xmlns:d="http://xamarin.com/schemas/2014/forms/design"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:attractionbase="clr-namespace:AppTourism.CardView.ItemTypes.AttractionPage"
                 xmlns:map="clr-namespace:AppTourism.MapModule"
                 mc:Ignorable="d"
                 x:Class="AppTourism.CardView.ItemTypes.AttractionPage.AddressWithMapContentListItem">
        <Frame
            HasShadow="False"
            Padding="0"
            Margin="{Binding MainFrameMargin}"
            RelativeLayout.XConstraint="{ConstraintExpression Type=Constant,Property=X,Constant=0}"
            RelativeLayout.YConstraint="{ConstraintExpression Type=Constant,Property=Y,Constant=0}"
            RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativetoParent,Property=Width}">
            <StackLayout Orientation="Vertical" Spacing="0" Margin="0" >
                <StackLayout Orientation="Vertical" Margin="10" >
                    <StackLayout Orientation="Horizontal">
                        <Image Source="iMarkerSmall.png" HeightRequest="30"></Image>
                        <Label Text="{Binding Pin.Address}" FontSize="Medium" TextColor="Black"></Label>
                    </StackLayout>
                    <Frame Padding="0" HeightRequest="100" CornerRadius="20" HasShadow="False">
                        <Frame.GestureRecognizers>
                            <TapGestureRecognizer Tapped="Map_Tapped"></TapGestureRecognizer>
                        </Frame.GestureRecognizers>
                        <AbsoluteLayout>
                            <map:CustomMap x:Name="Map" IsEnabled="False"
                                           AbsoluteLayout.LayoutBounds="0,1,1" AbsoluteLayout.LayoutFlags="All" />
                            <Label Text="N/A" FontSize="Medium" FontAttributes="Bold" TextColor="Black" Margin="5,0" VerticalOptions="Center" x:Name="NALabel" IsVisible="False"
                                   AbsoluteLayout.LayoutBounds="0.5,0.5,AutoSize,AutoSize" AbsoluteLayout.LayoutFlags="PositionProportional" ></Label>
                        </AbsoluteLayout>
                    </Frame>
                </StackLayout>
                <BoxView HeightRequest="{Binding SEParaTOR_HEIGHT}"  Margin="{Binding SeparatorMargin}">
                    <BoxView.BackgroundColor>
                        <Color>#e6e6e6</Color>
                    </BoxView.BackgroundColor>
                </BoxView>
            </StackLayout>
        </Frame>
    </attractionbase:AttractionContentListItemBase>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。