2012-01-27 100 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