hyarion
hyarion

Reputation: 2251

How to get coordinates of corners of visible bing map?

I'm using Bing Maps in a windows 8 app and I need to display pushpins at numerous locations.

Is there any way to get the GPS coordinates of the corners of the visible map?

Or alternatively a way to get the distance of the visible map? (e.g. 40km width, 60km height)

I need this in order to limit the number of pushpins I attach to the map to just being the ones on the visible part of the map.

Upvotes: 2

Views: 1859

Answers (2)

Alastair Aitchison
Alastair Aitchison

Reputation: 3532

You can get this information directly from the Bounds property of the map instance, which returns a LocationRect defined by the Northwest and Southeast lat/lng locations shown in the current view. http://msdn.microsoft.com/en-us/library/hh846504.aspx

Upvotes: 1

ZombieSheep
ZombieSheep

Reputation: 29963

Try using the TryPixelToLocation method.

Location locationOfPixel
if(MyMap.TryPixelToLocation(ThePointToLookUp, out locationOfPixel))
{
    //locationOfPixelshould contain the lat/long of the give point on the map.
}

Obviously, you will need to work out what the pixel locations of the top left, top right, bottom left and bottom right of your map control are and pass them in accordingly.

Upvotes: 0

Related Questions