locked
How to switch from Bing's Map control to the Windows 10 MapControl

    Question

  • Hi, I'm struggling to understand how one might go about 'upgrading' an existing Windows app that uses the Bing Map control to a Windows 10 app that uses the Windows Phone 8.1/Windows 10 MapControl.

    Bing's Map control has good support for databinding, pushpins that are guaranteed to be visible at all times, and XAML elements that feel like they are part of the map (i.e not sliding drunkenly on top of the map as you pan). None of these positive traits appear to be evident with the Windows.UI.Xaml.Controls.Maps.MapControl. 

    The Bing Map control was so easy to work with and met mine and my users basic needs. See below for a taste of how easy it is to layout a current location marker, an ObservableCollection bound to always visible pushpins (defined using XAML), and an info box (popup) that sits above the map and pushpins but is still positioned using geo-coordinates:

    <bm:Map x:Name="WorldMap"...
     <bm:Pushpin x:Name="CurrentLocation"...
     <bm:MapItemsControl x:Name="FlyingPigSightings" ItemsSource="{Binding FlyingPigSightings}">
      <bm:MapItemsControl.ItemTemplate>
       <DataTemplate>
        <bm:Pushpin
         ...
        </bm:Pushpin>
       </DataTemplate>
      </bm:MapItemsControl.ItemTemplate>
     </bm:MapItemsControl>
     <bm:MapLayer x:Name="InfoboxLayer" Visibility="Collapsed" Tapped="InfoboxLayer_Tapped">
      <Grid x:Name="Infobox" ...
     </bm:MapLayer>
    </bm:Map>

    How is a developer expected to work with the new control to reproduce the same smooth behaviour that the Win8.1 Bing Map control achieves? What kind of XAML mark-up would be equivalent to the above?

    Regards

    Jared

    Sunday, April 12, 2015 2:37 AM

All replies

  • Hi,

    The code below has been taken from https://github.com/Microsoft/Windows-universal-samples/tree/master/mapcontrolsample

        <maps:MapControl x:Name="myMap" HorizontalAlignment="Left">
            <maps:MapItemsControl x:Name="MapItems">
                <maps:MapItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Button  x:Name="mapItemButton" Click="mapItemButton_Click" Background="Transparent">
                            <StackPanel>
                                <Border Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
                                    <TextBlock Text="{Binding DisplayName}"/>
                                </Border>
                                <Image Source="{Binding ImageSourceUri}"
                                                   maps:MapControl.Location="{Binding Location}" 
                                                   >
                                    <Image.Transitions>
                                        <TransitionCollection>
                                            <EntranceThemeTransition/>
                                        </TransitionCollection>
                                    </Image.Transitions>
                                </Image>
                            </StackPanel>
                        </Button>
                    </DataTemplate>
                </maps:MapItemsControl.ItemTemplate>
            </maps:MapItemsControl>
        </maps:MapControl>

    And these are useful links about MapControl:

    Monday, April 13, 2015 2:24 PM
  • Thanks Nuran, I've had already read the links but hadn't seen the sample. The documentation looks to be the same as last year when I parked the phone portion of my universal app, hoping for something of higher quality than the new MapControl in the future.

    The XAML you listed shows how to bind one collection of 'map items'. Given I want to show more than just a collection of pushpins on the map, it looks like I would need to change my view model to have a combined list of generic items containing an object representing a location marker, all the objects to be represented as pushpins, plus an object representing the popup info-box. I'd then need a data template selector to guide the items control on how to render the mess of object types. Every time the user filtered the objects representing the pushpins I'd need to recreate the whole list since there'd be no other way to maintain the required z-index.

    As ugly as the above is (especially when compared to the elegance of the Bing Map control), I guess it may work. The biggest problem I see is the underlying problem with XAML elements and the map control. XAML elements aren't really part of the map. Unlike the Bing Map control, XAML elements float around on a higher layer that's only loosely connected to the map. I/my users could put up with the poor experience if it was just the info-box/pushpin popup for example, but not the pushpins as well.

    I'm not going to mark your response as an answer just yet as I still fail to see how I can use the MapControl to meet my simple requirements at the quality users would expect. I need to do more testing on Windows 10 though I am finding VS2015 CTP6 too buggy for comprehensive testing. My initial tests seemed to indicate that all the problems forcing me to suspend work on the Windows Phone 8.1 project last year are still present in the Windows 10 version. This is hugely depressing.

    Tuesday, April 14, 2015 1:07 AM
  • Hi,

    The code below has been taken from https://github.com/Microsoft/Windows-universal-samples/tree/master/mapcontrolsample

    Hi, I've tried the sample app and it crashes when adding xaml elements to the map. The map elements section doesn't crash, however it does demonstrate how useless MapIcons are for pushpins since they're hidden at more zoom levels than they're visible.
    Saturday, April 25, 2015 3:46 AM