2
votes

I'm generating map makers on a Bing Map. If I use the design-time Map Layer, which is added in XAML:

<bm:Map.Children>
    <!-- Data Layer-->
    <bm:MapLayer Name="DataLayer"/>

...it works great. However, I decided if I were plopping multiple different sets of markers on the map, I should put each set on its own map layer. So I added code like this:

private async void Gener8MapMarkers(List<PhotraxBaseData> _pbd, bool Cre8DynamicMapLayer)
{
    . . .
    if (Cre8DynamicMapLayer)
    {
        MapLayer newLayer = new MapLayer();
        photraxMap.Children.Add(newLayer);
        AddPushpin(loc, stuff, newLayer);
    }
    else
    {
        AddPushpin(loc, stuff, DataLayer);
    }
    . . .

But note how the pushpins show through the popup when I do this (only if I dynamically create MapLayer[s]):

enter image description here

Was adding subsequent sets to its own MapLayer a bad idea (should I just add everything to "DataLayer")?

If not, how can I use multiple MapLayers without having the pushpins show through the popup?

UPDATE

Yes, Marvin Smit's suggestion works, namely:

if (Cre8DynamicMapLayer)    
{
    MapLayer newLayer = new MapLayer();
    //photraxMap.Children.Add(newLayer);
    photraxMap.Children.Insert(0, newLayer);
    AddPushpin(loc, stuff, newLayer);
}

His brother Rik is probably the better hoopster, but I doubt Rik can program his way out of a layup.

1
Shot in the dark: Since some pins are behind the popup, it seems to have to do with "layer ordering". Have you tried putting your new layer in another order?Marvin Smit
Change photraxMap.Children.Add(newLayer); -> photraxMap.Children.Insert(newLayer, ...); (sorry, donno correct syntax from top of my head)Marvin Smit
I would consider it a correct "grouping". Allowing you to quickly manipulate "save-restore/show-hide/etc" per "group of pins". Whether that is needed as functionality is something you only know :)Marvin Smit
Okay, that seems to work fine (see Update); if you want to, make it an Answer instead of just a comment, and I'll mark it as such.B. Clay Shannon
@MarvinSmit Please make your suggestion an answer so that we can give you internet points... also so that this question doesn't look like an unanswered question :PChris Cirefice

1 Answers

1
votes

You are stacking the layers you are using for the pins you create on top of the popup layer.

By changing the order you add the layer into the stack you can have the behavior you desire.

Instead of the

photraxMap.Children.Add(newLayer);

Use

photraxMap.Children.Insert(0, newLayer);

Which will cause the new layer to be inserted at the 'bottom' of the layers instead of the 'top' (if you consider the 'top' layer to be the closest to you)