Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 - Bing Maps - How do I handle multiple pushpins on a MapItemsControl? - currently crashing application
    text
    copied!<p>My bing map application eventually crashes when I drag or zoom. Tested on emulator and device.</p> <p>I have installed the October update.</p> <p>MapItemsControl binding to ObservableCollection. When application starts, pins have been loaded and are visible. </p> <p>While troubleshooting, I determine the app will not crash if the pushpins on the map are in the same general area. Example,</p> <pre><code>addPin("40.78184126814031", "-73.97712707519532"); addPin("40.74569634433956", "-73.96717071533204"); addPin("40.7117682299881", "-74.0125322341919"); addPin("40.75777392583087", "-73.96950960159302"); </code></pre> <p>But if the pins are spread out - the application crashes when the user zooms into one specific pin and/or dragging the map. Example,</p> <pre><code>addPin("42.35960626034072", "-71.09212160110473"); addPin("51.388066116760086", "30.098590850830067"); addPin("48.17972265679143", "11.54910385608672"); addPin("40.28802528051879", "-76.65668606758117"); </code></pre> <p>Not sure if the project code is necessary - I am assuming there is some concept that I just do not know about.</p> <p>Any suggestions - I am all ears. Stack trace below.</p> <p>Thanks</p> <pre><code>Unspecified error at MS.Internal.XcpImports.CheckHResult(UInt32 hr) at MS.Internal.XcpImports.UIElement_HitTestPoint(UIElement element, Point ptHit) at System.Windows.UIElement.HitTest(Point point) at System.Windows.Media.VisualTreeHelper.FindElementsInHostCoordinates(Point intersectingPoint, UIElement subtree) at Microsoft.Phone.Controls.Maps.Core.TouchHelper.&lt;InputHitTest&gt;d__0.MoveNext() at Microsoft.Phone.Controls.Maps.Core.TouchHelper.HitTestAndRaiseDownEvent(UIElement root, TouchPoint touchPoint) at Microsoft.Phone.Controls.Maps.Core.TouchHelper.TouchFrameReported(Object sender, TouchFrameEventArgs e) at System.Windows.Input.Touch.OnTouch(Object sender, TouchFrameEventArgs e) at MS.Internal.JoltHelper.RaiseEvent(IntPtr target, UInt32 eventId, IntPtr coreEventArgs, UInt32 eventArgsTypeIndex) </code></pre> <p>Thought it best to include the code - running this and zooming in crashes app - thanks</p> <p>PINDATA class</p> <pre><code>namespace BugCrash.models {public class PinData{public GeoCoordinate PinLocation { get;set; }}} </code></pre> <p>MAINPAGE.xaml.cs</p> <pre><code>namespace BugCrash { public partial class MainPage : PhoneApplicationPage { private ObservableCollection&lt;PinData&gt; _pinsA = new ObservableCollection&lt;PinData&gt;(); public ObservableCollection&lt;PinData&gt; PinsA { get { return this._pinsA; } } // Constructor public MainPage() { InitializeComponent(); this.DataContext = this; myMap.Center = new GeoCoordinate(40.74569634433956, -73.96717071533204); myMap.ZoomLevel = 4; MessageBox.Show(loadAPins_fromString()); } //ADD PIN TO COLLECTION private void addPin(String lat, String lon) { PinData tmpPin; tmpPin = new PinData() { PinLocation = new GeoCoordinate(System.Convert.ToDouble(lat), System.Convert.ToDouble(lon)) }; _pinsA.Add(tmpPin); } //LOAD PINS ONE BY ONE private string loadAPins_fromString() { //BAD addPin("42.35960626034072", "-71.09212160110473"); addPin("51.388066116760086", "30.098590850830067"); addPin("48.17972265679143", "11.54910385608672"); addPin("40.28802528051879", "-76.65668606758117"); return "A PINS LOADED - STRING"; } } } </code></pre> <p>MAINPAGE.xaml</p> <pre><code>&lt;phone:PhoneApplicationPage x:Class="BugCrash.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="False" xmlns:my="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"&gt; &lt;Grid x:Name="LayoutRoot" Background="Transparent"&gt; &lt;!--RESOURCES--&gt; &lt;Grid.Resources&gt; &lt;my:ApplicationIdCredentialsProvider ApplicationId="XX" x:Key="MyCredentials"/&gt; &lt;/Grid.Resources&gt; &lt;my:Map Height="768" Name="myMap" VerticalAlignment="Top" Width="480" CredentialsProvider="{StaticResource MyCredentials}"&gt; &lt;my:Map.Mode&gt; &lt;my:AerialMode ShouldDisplayLabels="True" /&gt; &lt;/my:Map.Mode&gt; &lt;my:MapItemsControl x:Name="GroupAPins" ItemsSource="{Binding PinsA}" &gt; &lt;my:MapItemsControl.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;my:Pushpin Location="{Binding PinLocation}" Width="60" Height="55" Content="PIN"&gt; &lt;/my:Pushpin&gt; &lt;/DataTemplate&gt; &lt;/my:MapItemsControl.ItemTemplate&gt; &lt;/my:MapItemsControl&gt; &lt;/my:Map&gt; &lt;/Grid&gt; &lt;/phone:PhoneApplicationPage&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload