我在MapLayer中显示大椭圆时遇到问题。椭圆被切断了。
在XAML中,我只添加一个带有图层和椭圆的地图。在后面的代码中,我在地图中找到了椭圆。当我将地图平移到北方时会出现问题。
<UserControl x:Class="PruebaEllipse.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<m:Map x:Name="Mapa" CredentialsProvider="AlT1xaWmg1CctI7..." Mode="Road" Grid.Column="0" Grid.Row="1" ZoomLevel="10" Center="-33,-54" >
<m:MapLayer x:Name="NewPolygonLayer">
</m:MapLayer>
<m:MapLayer x:Name="Layer1" Loaded="Layer1_Loaded" >
<m:MapLayer.Children>
<Ellipse Height="1500" HorizontalAlignment="Left" Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="900" Fill="#FF895D5D" />
</m:MapLayer.Children>
</m:MapLayer>
</m:Map>
</Grid>
</UserControl>
这是背后的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Maps.MapControl;
namespace PruebaEllipse
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void Layer1_Loaded(object sender, RoutedEventArgs e)
{
Location trkLoc2 = new Location(-32.5, -54.0);
MapLayer.SetPosition(ellipse1, trkLoc2);
}
}
}
答案 0 :(得分:0)
这是Silverlight的限制。如果您创建的任何控件的大小都大于您的视图端口窗口,那么它将被剪裁。如果您想在Bing地图上绘制一个圆,您可以使用MapPolyon类并计算构成圆的一堆点。这将为您提供一个圆形,可以在缩放地图时进行缩放,并且不会被视口窗口剪切。以下是有关如何执行此操作的博文:http://silverlightfoundry.blogspot.co.uk/2009/06/bing-live-maps-silverlight-control-part.html