This article describes how to get the total map size in pixels depending on the actual zoom level.
The formula should be:
map width = map height = 256 * 2^level pixels
Unfortunately this doesn't seem to work for the MapControl for universal apps. First thing is, the ZoomLevel property is of type double not integer (as needed in the sample in the article). But also with a whole number ZoomLevel of i.e. 4.0 (int --> 4) the formula doesn't work.
Now, I tried to get the map size in pixel with help of the MapControl.GetOffsetFromLocation method:
private double GetMapSize()
{
Point pW, pE;
myMap.GetOffsetFromLocation(new Geopoint(new BasicGeoposition()
{ Longitude = -90, Latitude = 0 }), out pW);
myMap.GetOffsetFromLocation(new Geopoint(new BasicGeoposition()
{ Longitude = 90, Latitude = 0 }), out pE);
return (pE.X - pW.X) * 2;
}
This works with a discrepancy of some pixels, but this issue is actually not important.
I get on my Surface Pro 3 the following results (ZoomLevel is 4.0):
Surface screen (scale 1.5): 3654px
Surface external screen (scale 1.0): 3274px
None of these results is 4096px like described in the article. The results are correct and I can work with that. But for me it's just a workaround and also if the ZoomLevel is higher than approx 13 the GetOffsetFromLocation method returns -1 for pE.X and pW.X (for -90 and 90). For nearer longitudes to the actual center it works. It seems that GetOffsetFromLocation has a maximum of distance. So I would need to use nearer longitude values when having a higher ZoomLevel.
That all is not really a clear solution. So my question is: Is there a save method to get the exact map size in pixels for the UWP MapControl?
Thanks!
Maas