I trying to cut the map to many rectangle parts and show ellipse in center like this:
But the result is this:
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);
}
You have to remember that earth isn't flat :) Maps use always some projection to draw earth to 2D map. Because of this your points don't seem to be in right places.
Bing maps uses Mercator projection. You can find more information about Bings mapping system from here. There is sample code to calculate from screen coordinates to latitude and longitude(PixelXYToLatLong function).