Center map arround GeoPoints to set visible all them

234 Views Asked by At

I'm using a MapControl to show some GeoPoints

XAML

<maps:MapControl x:Name="myMap">
...
</maps:MapControl>

C#

foreach (MapIcon icon in mapsIcons)
{
  myMap.MapElements.Add(icon);
}

I need to center and zoom the map automatically (or programatically) around all GeoPoints in the map in order to all the MapIcons are visible. Some way to do that?

Thx!

1

There are 1 best solutions below

0
On BEST ANSWER

Create a list or array of BasicGeoposition's from your data and then pass them into the GeoboundingBox class:

var geoboundingBox = Windows.Devices.Geolocation.GeoboundingBox.tryCompute(positions);

Then use this bounding box with the TrySetViewBounds of the map:

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn637065.aspx

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn607971.aspx?cs-save-lang=1&cs-lang=javascript#code-snippet-1