简体   繁体   中英

Terrible performance of MapControl with multiple children in Windows Phone 8.1 Runtime

I have a MapControl which is supposed to be filled with multiple objects (500+). These objects represent some kind of POI. When the user taps on the object (pushpin) I display more info about the POI. So, I need:

  1. A MapControl capable of handling high amount of child objects
  2. Intercept Tapped event of the child object

In order to achieve the second goal I decided to define my own pushpin template:

  <maps:MapControl x:Name="Map">
    <maps:MapItemsControl ItemsSource="{Binding Pushpins}">
      <maps:MapItemsControl.ItemTemplate>
        <DataTemplate>
          <Image Width="40"
                 Height="40"
                 Source="{ ... }"
                 Tapped="OnPushpinTappedAsync"
                 maps:MapControl.Location="{Binding Location}"
                 maps:MapControl.NormalizedAnchorPoint="{Binding AnchorPoint}" />
        </DataTemplate>
      </maps:MapItemsControl.ItemTemplate>
    </maps:MapItemsControl>
  </maps:MapControl>

This works great except for the fact that.. the visual out of such approach is AWFULL. Every time I move a map, every Pushpin flickers a lot. It's like they are not, I don't know, bound to the position. They are also lagging. It looks really bad. Rendering of those objects is really poor.

The alternative is to add elements to the MapControl 's MapElements property. It makes rendering of those objects really nice. But then I loose binding ability and will have to workaround it - I'm not a big fan of that. There's also a second problem - from what I've read, rendering objects of the MapElements collection is a best effort deal. So it does not guarantee that it will succeed. And that is not an option for me, as in the future I plan to add clustering functionality, so I need to have a full control over what is being rendered on the map and what is not.

Do you have any idea why these MapControl 's elements flickers so much? What can I do to prevent it? Thanks in advance for any hint or answer.

I'm facing the exact same problem. Seems to me, that the MapControl is completely broken. There are many more bugs besides performance :(

You cannot really solve the problem, but you can create a "oldschool" WP8.0 Silverlight application and use something like this:

        <Page xmlns:map="clr-namespace:Microsoft.Phone.Maps.Controls;assembly=Microsoft.Phone.Maps">
            <map:Map Grid.Row="1" x:Name="myMap">
                <tool:MapExtensions.Children>
                    <tool:MapItemsControl>
                       ... and so on ...

This performs great but of course you have to change everything from Win(P)RT to Silverlight...

I too faced this problem, but I find this library to be usefull.

Hopefully Microsoft updates the MapControl for Windows 10.

Try this:

Tag="{Binding index_of_collection}"

and this:

OnPushpinTappedAsync()

int index = (int)(sender as Image).Tag;  //index_of_collection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM