我试图将地图切割成许多矩形部分,并在中心显示椭圆,如下所示:
但结果如下:
XAML:
<Maps:MapControl x:Name="BingMap" Loaded="BingMap_Loaded">
<Maps:MapItemsControl x:Name="MapPins">
<Maps:MapItemsControl.ItemTemplate>
<DataTemplate>
<Grid>
<Ellipse Fill="Red" Width="20" Height="20"></Ellipse>
<TextBlock Maps:MapControl.Location="{Binding Point}" Text="{Binding Count}" FontSize="20" Margin="5"/>
</Grid>
</DataTemplate>
</Maps:MapItemsControl.ItemTemplate>
</Maps:MapItemsControl>
</Maps:MapControl>
C#:
public async Task<List<Location>> ClusterCenters(double x)
{
List<Location> locations = new List<Location>();
for (double i = -85; i <= 85; i+=x)
{
for (double j = -170; j <= 170; j+=x*2)
{
locations.Add(new Location()
{
Count = 1,
Title = String.Format("{0},{1}", i, j),
Point = new Geopoint(new BasicGeoposition() {
Latitude = i,
Longitude = j
})
});
}
}
return locations;
}
private async void BingMap_Loaded(object sender, RoutedEventArgs e)
{
MapPins.ItemsSource = await ClusterCenters(10);
}
答案 0 :(得分:3)
你必须记住,地球并不平坦:)地图总是使用一些projection来绘制地球到2D地图。因此,你的观点似乎并不合适。
Bing地图使用Mercator projection。您可以从here找到有关Bings mapping system的更多信息。有从屏幕坐标到纬度和经度计算的示例代码(PixelXYToLatLong函数)。