0

Similar to this question but for a Bing Map SDK embedded in a C#/XAML Windows Store app.

How do I offset the where 'center' is for e.g. double tapping to zoom and other behaviours?

Community
  • 1
  • 1
Brendan
  • 18,771
  • 17
  • 83
  • 114

1 Answers1

1

If creating a Windows Store app (Windows 8/8.1) using the Bing Maps SDK you can offset the center of the map by first grabbing the center location of the map, converting the location into a pixel coordinate. Apply an offset to the pixel coordinate and then convert the pixel back into a location and set the maps center using that location. Here is a code sample:

//Convert the center location of the map into a pixel value.
Point centerPixel;
myMap.TryLocationToPixel(myMap.Center, out centerPixel);

//Apply an offset to the pixel value.
centerPixel.X += [offset value];
centerPixel.Y += [offset value];

//Convert pixel coordinate back into location object.
Location center;
myMap.TryPixelToLocation(centerPixel, out center);

//Center the map using the offset value.
myMap.Center = center;

All that said, I would recommend developing for Windows 10 rather than Windows 8. Windows 10 already exceeds Windows 8 in marketshare and there is a brand new Bing Maps control built right into the Windows 10 SDK. Here is some documentation: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn642089.aspx

rbrundritt
  • 16,570
  • 2
  • 21
  • 46
  • I wish I could develop for Windows 10 but we are targeting LOB devices with Windows 8.1 installed. I'm finding searches on MSDN point to Windows 10 samples/examples/tutorials with a token non-deep link to the Windows 8 version, sometimes the Windows 8 version does not even seem to be on the site ... – Brendan Apr 14 '16 at 20:22