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);
}
}
}
I have problem displaying big Ellipses in a MapLayer. The Ellipse is cut off.
In the XAML, I just add a Map with a Layer and an ellipse. In the code behind I locate the ellipse in the map. The problem appears when I pan the map to the north.
<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>
This is the code behind:
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);
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Silverlight 的限制。如果您创建的任何控件的大小大于您的视口窗口,它将被剪裁。如果您想在 Bing 地图上绘制一个圆,您可以使用 MapPolyon 类并计算组成圆的一堆点。这将为您提供一个随着您缩放地图而缩放的圆圈,并且不会被视口窗口剪切。以下是有关如何执行此操作的博客文章: http://silverlightfoundry.blogspot.co.uk/2009/06/bing-live-maps-silverlight-control-part.html
This is a limitation of Silverlight. If you create any control that has a size that is larger than your view port window it will be clipped. If you want to draw a circle on Bing Maps you can use the MapPolyon class and calculate a bunch of points that make up the circle. This will give you a circle that scales as you zoom the map and that doesn't get clipped by the viewport window. Here is a blog post on how to do this: http://silverlightfoundry.blogspot.co.uk/2009/06/bing-live-maps-silverlight-control-part.html