Share via


A concise history of the Bing Maps Windows 8 Map control.

The Windows 8 Bing map XAML control (as opposed to the javascript control which is an entirely different beast) has a slightly different API when compared to earlier Bing Map XAML controls. Previous XAML controls have all been written in managed code whereas the Windows 8 map control is written in native code. Written in mostly cross platform C++ it originally shipped inside the Bing iPhone app. It was later branched and shipped as an iPhone map control without functional parity with the script and XAML map controls. With some more work we shipped it as part of the Bing Android app and now as a separate control for Windows 8. The Windows 8 version has had adjustments to make it behave as a native Windows 8 XAML control allowing data binding, native XAML child elements and all the good stuff you would expect from a XAML control.

Since we do our own Direct3D rendering we can get better performance with polygons and polylines on our map by managing the vertices ourselves and just adjusting the camera per frame instead of pushing across new vertices. As a side effect of this MapPolygon and MapPolyline do not descend from UIElement and can't be placed just anywhere in the UI tree but instead need to be children of the separate Map.ShapeLayers property to differentiate them from XAML overlay controls. XAML children still go on the Children property like you would expect.

<bm:Map x:Name="map" Width="800" Height="600" Credentials="INSERT_YOUR_BING_MAPS_KEY">
<!-- UIElements go under Map.Children -->
<bm:Map.Children>
<bm:Pushpin bm:MapLayer.PositionAnchor="11,11">
<bm:MapLayer.Position>
<bm:Location Latitude="0" Longitude="0" />
</bm:MapLayer.Position>
</bm:Pushpin>
</bm:Map.Children>
<!-- MapPolygon and MapPolyline go under Map.ShapeLayers -->
<bm:Map.ShapeLayers>
<bm:MapShapeLayer>
<bm:MapShapeLayer.Shapes>
<bm:MapPolygon>
<bm:MapPolygon.Locations>
<bm:Location Latitude="-10" Longitude="-10" />
<bm:Location Latitude="-10" Longitude="10" />
<bm:Location Latitude="10" Longitude="10" />
<bm:Location Latitude="10" Longitude="-10" />
</bm:MapPolygon.Locations>
</bm:MapPolygon>
</bm:MapShapeLayer.Shapes>
</bm:MapShapeLayer>
</bm:Map.ShapeLayers>
</bm:Map>

Side note: there's a XAML compiler bug in the consumer preview that prevents setting FillColor on MapPolygon but you can set it via code fine or wait until the final release where it can be set from XAML as well.

Side note 2: We're already hard at work creating the final version of the Map control with tons of tweaks and fixes. As an example Pushpin no longer requires setting PositionAnchor on it as it will default to the center of the pushpin.