2012-01-27 93 views
1

我有在MapLayer中显示大椭圆的问题。椭圆被切断。Silverlight 4,Bing地图,椭圆大小

在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

你有想过吗? :) – 2012-11-30 15:29:18

回答

0

这是Silverlight中的限制。如果您创建的任何控件的大小大于您的视图端口窗口,它将被剪裁。如果您想在Bing地图上绘制一个圆圈,则可以使用MapPolyon类并计算构成该圆圈的一组点。这将为您提供一个缩放地图时缩放的圆,并且不会被视口窗口剪切。这里是一个关于如何做到这一点的博客文章:http://silverlightfoundry.blogspot.co.uk/2009/06/bing-live-maps-silverlight-control-part.html