I'm developing a Windows Phone 8.1 app that works with Bing Maps.
During the rendering of this map I use the TrySetViewBoundsAsync
to set correctly my custom view. But now I want to get this information (after the user changes the view by zooming/moving the map) but I don't find any method that helps me.
How can I get the view bounds?
Note that rbrundritt's solution will not work for oblique (tilted) views. In that case, the visible region resembles more an inverted trapezoid than a bounding box. Also the top-left corner might not be a valid location if the horizon is visible.
For Windows 10 Anniversary Update (version 1607), the
MapControl
supports a new methodGetVisibleRegion()
to help you with this.The following should return you the view bounds of the map:
See the MapControl documentation for more details.
There isn't a built in method for this, however it can be done fairly easily. Here is a bit of code for this which I pulled from the Microsoft Maps Spatial Toolbox project: