Bing Maps for WPF, ZIndex MapLayers / Pushpins?

Just a preface that I understand that I am executing my decision in a friendly format other than WPF. in an ideal world, I would use MapItemsControl.

Ok, so I use Bing Maps for WPF. Here are my XAML Bing Cards

<m:Map CredentialsProvider="12345" x:Name="myMap" UseInertia="True" Loaded="Map_Loaded" Width="1920" Height="990" Canvas.Top="110" ZoomLevel="5" Center="39.8282,-98.5795"> <m:MapLayer x:Name="MyPushPinLayer"> <Canvas x:Name="ContentPopup" Visibility="Collapsed" Width="250"> <Border Background="White" BorderThickness="1" BorderBrush="Gray" Width="250" Padding="5"> <StackPanel Canvas.Left="20" Canvas.Top="10"> <TextBlock x:Name="ContentPopupText" FontSize="18" FontWeight="Bold" Foreground="#CF0000" Width="240" TextWrapping="Wrap"> </TextBlock> <TextBlock x:Name="ContentAddress" FontSize="13" Foreground="Black" Width="240" TextWrapping="Wrap"/> <TextBlock x:Name="ContentQuestions" FontSize="13" Foreground="Black" Width="240" TextWrapping="Wrap" /> </StackPanel> </Border> </Canvas> </m:MapLayer> </m:Map> 

Basically, this draws a map, and I have a maplayer that will hold the tooltip information when clicked. In my code behind, I retrieve data from the service and add buttons on the server in the same way:

 Pushpin pin = new Pushpin(); pin.Location = new Microsoft.Maps.MapControl.WPF.Location(location.latitude, location.longitude); pin.Content = location.name; pin.Template = LGPushPinTemplate; pin.MouseDown += new MouseButtonEventHandler(pin_MouseDown); myMap.Children.Add(pin); 

Pretty simple. However, since I define the pop-up layer in XAML and children after loading the map, the buttons appear last in the child structure of the map, and therefore the modal info boxes are displayed under any buttons. Is there a way to reorder the z-order of these elements without adding / removing everything from the child map collection? |

+4
source share
1 answer

This problem is solvable. I found several possible solutions during the search. See below. Hope you find something that works with your code / situation.

  • Could you dynamically create a popup at the end? Similar to how you generate push pins.
  • Set the Canvas.ZIndex pop-ups to a large number. Here are some more solutions with ZIndex: silverlight control: how to manage ZIndex?

    Zindex is an attached property of the parent canvas.

    For example, we created an โ€œadvanced MapLayerโ€ for Bing Maps Silverlight at http://deepearth.codeplex.com and added zindex as a property:

     public int ZIndex { get { return zIndex; } set { zIndex = value; if (Parent != null) { SetValue(Canvas.ZIndexProperty, zIndex); } } } 

    In our class infogeometry (provides labels, balloons for all OGC geometry type, point, linear, polygon, polygon, etc.), When we launch the balloon, we do this:

      var layer = (EnhancedMapLayer) Parent; if (layer != null) { //set to top z-order prevZIndex = layer.ZIndex; layer.ZIndex = 1000; SetValue(Canvas.ZIndexProperty, 1000); applyTranslations(); balloonShowStoryboard.Begin(); balloonContainer.Visibility = Visibility.Visible; OnBalloon(new BalloonEventArgs { LayerID = layer.ID, ItemID = ItemID }); } 

    Keeping the previous ZIndex layer, we can restore it to the correct order to hide the balloon.

    To communicate between the layers, we used the command template for Silverlight, so we just call:

    Commands.ClosePopupCommand.Execute();

    To close all other points, subscribe to this event: Commands.ClosePopupCommand.Executed += ClosePopupCommand_Executed;

  • fooobar.com/questions/1454265 / ... provides a good approach, including mentioning the Microsoft Interactive Map SDK . Basically, try to separate the layers.

      <m:Map CredentialsProvider="Your Key"> <m:MapLayer> <m:MapItemsControl x:Name="ListOfItems" ItemTemplate="{StaticResource LogoTemplate}" ItemsSource="{Binding MyLocalizedEntities}"> </m:MapItemsControl> </m:MapLayer> <m:MapLayer> <!-- You can have content in multiple layers: Latter layers are infront of former ones. --> </m:MapLayer> </m:Map> 
  • Other similar stackoverflow issues that might help.

+3
source

All Articles