C# 滚动bing地图时不显示数据
我在Bing地图上根据站点的位置显示我的网络数据。 当向上或向下/向左或向右滚动时,当滚动期间到达相同位置时,地图上先前显示的相同网络数据不会显示 无法解决问题 我已经在地图上设定了边界:C# 滚动bing地图时不显示数据,c#,silverlight,bing-maps,C#,Silverlight,Bing Maps,我在Bing地图上根据站点的位置显示我的网络数据。 当向上或向下/向左或向右滚动时,当滚动期间到达相同位置时,地图上先前显示的相同网络数据不会显示 无法解决问题 我已经在地图上设定了边界: private static Location _startPoint = new Location { Longitude = -175, Latitude = -65 };// defines the boundary of Map. A rectangle. private static Loc
private static Location _startPoint = new Location { Longitude = -175, Latitude = -65 };// defines the boundary of Map. A rectangle.
private static Location _endPoint = new Location { Longitude = 168, Latitude = 82 };//botttom left is Origin, top Right is Max.
可能此边界设置导致再次显示数据时出现问题
这是我在用户每次滚动并验证区域时使用的函数。。。。筛选器是我在地图上显示的KPI筛选器
public static KpiFilter ValidateSelectedAreaFilter(KpiFilter filter)
{
if (filter.LocationFilters.RectangleAreaFilters != null && filter.LocationFilters.RectangleAreaFilters.Count() > 0)
{
if (filter.LocationFilters.RectangleAreaFilters.ToArray()[0].BottomRight.Longitude < filter.LocationFilters.RectangleAreaFilters.ToArray()[0].TopLeft.Longitude)
filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Longitude = _endPoint.Longitude;
}
if (filter.LocationFilters.RectangleAreaFilters != null && filter.LocationFilters.RectangleAreaFilters.Count() > 0)
{
//Check if points are inside the map area. If all points are outside then don't do anything, just return empty object.
if (filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Longitude < _startPoint.Longitude &&
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Latitude < _startPoint.Latitude &&
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Longitude > _endPoint.Longitude &&
filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Latitude > _endPoint.Latitude)
{
return null;
}
// checks if the selected area intersects with Japan boundary.
// If some part of the selection is outside boundary, the selection is cropped so as to fit it within limits.
//if some selection from left side is outside boundary, then topLeft(long) is set to Start Point Origin.
if (filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Longitude < _startPoint.Longitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Longitude = _startPoint.Longitude;
}
//if some selection from bottom is outside boundary, then bottomRight(lat) is set to Start Point Origin
if (filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Latitude < _startPoint.Latitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Latitude = _startPoint.Latitude;
}
//if some selection from right is outside boundary, then bottomRight(long) is set to End Point Max.
if (filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Longitude > _endPoint.Longitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Longitude = _endPoint.Longitude;
}
//if some selection from top is outside boundary, then topLeft(long) is set to End Point Max.
if (filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Latitude > _endPoint.Latitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Latitude = _endPoint.Latitude;
}
}
else
return null;
return filter;
}
公共静态KpiFilter验证选定区域筛选器(KpiFilter筛选器)
{
if(filter.LocationFilters.RectangleAreaFilters!=null&&filter.LocationFilters.RectangleAreaFilters.Count()>0)
{
if(filter.LocationFilters.RectangleAreaFilters.ToArray()[0]。BottomRight.Longitude0)
{
//检查点是否在地图区域内。如果所有点都在地图区域外,则不执行任何操作,只返回空对象。
if(filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Longitude<\u startPoint.Longitude&&
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Latitude<\u startPoint.Latitude&&
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Longitude>\U endPoint.Longitude&&
filter.LocationFilters.RectangleAreaFilters.ToList()[0]。BottomRight.Latitude>\u endPoint.Latitude)
{
返回null;
}
//检查选定区域是否与边界相交。
//如果选择的某个部分位于边界之外,则会对选择进行裁剪,以便在限制范围内进行拟合。
//如果左侧的某些选择位于边界外,则“左上角(长)”设置为起点原点。
if(filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Longitude<\u startPoint.Longitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Longitude=\u startPoint.Longitude;
}
//如果底部的某些选择位于边界外,则底部右侧(lat)设置为起点原点
if(filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Latitude<\u startPoint.Latitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Latitude=\u startPoint.Latitude;
}
//如果右侧的某些选择位于边界外,则底部右侧(长)设置为“终点最大值”。
if(filter.LocationFilters.RectangleAreaFilters.ToList()[0].BottomRight.Longitude>\u endPoint.Longitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0]。BottomRight.Longitude=\u endPoint.Longitude;
}
//如果顶部的某些选择位于边界外,则“左上角(长)”设置为“终点最大值”。
if(filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Latitude>\u endPoint.Latitude)
{
filter.LocationFilters.RectangleAreaFilters.ToList()[0].TopLeft.Latitude=\u endPoint.Latitude;
}
}
其他的
返回null;
回流过滤器;
}
XAML代码:
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
<m:Map
x:Name="map"
MouseWheel="map_MouseWheel"
AnimationLevel="None"
MouseDoubleClick="map_MouseDoubleClick"
CredentialsProvider="your key"
Mode="Road"
ZoomLevel="5"
Center="40.50,139.40"
Grid.Row = "1"
Grid.RowSpan="2">
<m:MapLayer
x:Name="binLayer"
CacheMode="BitmapCache"
Visibility="Visible" />
<m:MapLayer
x:Name="pointDataLayer"
Visibility="Visible" >
<Canvas
x:Name="canvasPointData"
MouseRightButtonDown="canvasPointData_MouseRightButtonDown"/>
<Grid
x:Name="messageGrid"
Visibility="Collapsed">
<Grid
Background="White"
Width="Auto"
Height="Auto" Opacity=".7">
</Grid>
<TextBlock
x:Name="txbMessage"
VerticalAlignment="Center"
FontWeight="Bold"
HorizontalAlignment="Center"
Margin="0"/>
</Grid>
<StackPanel
x:Name="grdShowLabel"
HorizontalAlignment="Right"
Height="20"
Width="Auto"
Margin="5,4"
Background="LightGray"
Visibility="Collapsed"
VerticalAlignment="top">
</StackPanel>
</m:MapLayer>
<m:MapLayer
x:Name="dropCallLayer"
Visibility="Visible" >
<Canvas
x:Name="canvasdropCall" MouseRightButtonDown="canvasdropCall_MouseRightButtonDown"/>
</m:MapLayer>
</m:Map>
xmlns:m=“clr命名空间:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl”
是的,也许。。。没有人知道这一点,因为您还没有展示如何实际显示数据。显示更多代码和XAML,但仅显示相关部分。您正在使用MapItemsControl吗?@Clemens我已经编辑了代码并粘贴了它。@Clemens已经在上面添加了XAML代码。。请检查它。……对不起,我不理解您的代码。但是,我非常确定,您不应该在MapLayer内的画布中显示数据。改用MapItemsControl。@Clemens显示的数据是正确的,没有问题。。。但只有当地图被滚动并且世界地图再次开始重复时,问题才会出现。