【发布时间】:2010-12-06 12:14:17
【问题描述】:
我一直在使用本教程尝试在地图上显示图钉: http://compiledexperience.com/windows-phone-7/tutorials/quake
下面的各位,我已经快到了,但是
如果我用原始位替换我的位(注释掉的部分) 然后执行“开始调试”,我得到一个未处理的异常。如果我继续调试,我会在一瞬间看到地图和图钉,然后退出。 我放回原来的注释代码和它的罚款...... 如果您需要更多信息,请告诉我。我对此感到非常沮丧:(再次感谢。
调用栈:
QuakeML.dll!QuakeML.App.OnUnhandledException(object sender = {QuakeML.App}, System.Windows.ApplicationUnhandledExceptionEventArgs e = {System.Windows.ApplicationUnhandledExceptionEventArgs}) 第 37 行 + 0x5 字节 C# System.Windows.dll!MS.Internal.Error.CallApplicationUEHandler(System.Exception e = {"UIElement.Arrange(finalRect) 不能在 finalRect 中使用 Infinite 或 NaN 值调用。"}) + 0x30 字节
System.Windows.dll!MS.Internal.Error.CallAUEHandler(uint hr = 2148474880, out uint bIsHandled = 0) + 0x6 bytes
[本机到托管转换]
当前代码:
namespace QuakeML
{
public partial class MainPage
{
public MainPage()
{
InitializeComponent();
Loaded += OnLoaded;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
LoadQuakes();
}
private void LoadQuakes()
{
var webClient = new WebClient();
webClient.OpenReadCompleted += OnOpenReadCompleted;
var uri = "http://www.tfl.gov.uk/tfl/businessandpartners/syndication/feed.aspx?email=mycomputer@clara.co.uk&feedId=3";
// var uri = "http://magma.geonet.org.nz/services/quake/quakeml/1.0.1/query?startDate=2010-09-03&endDate=2010-09-05&magnitudeLower={0:0.0}&magnitudeUpper=8";
webClient.OpenReadAsync(new Uri(uri, UriKind.Absolute));
}
private void OnOpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
var document = XDocument.Load(e.Result);
if(document.Root == null)
return;
var xmlns = XNamespace.Get("http://www.tfl.gov.uk/tfl/syndication/namespaces/geo");
//var xmlns = XNamespace.Get("http://quakeml.org/xmlns/quakeml/1.0");
var events = from ev in document.Descendants("item")
select new
{
Latitude = Convert.ToDouble(ev.Element(xmlns + "Point").Element(xmlns + "lat").Value),
Longitude = Convert.ToDouble(ev.Element(xmlns + "Point").Element(xmlns + "long").Value),
};
//var events = from ev in document.Descendants(xmlns + "event")
// select new
// {
// Latitude = Convert.ToDouble(ev.Element(xmlns + "origin").Element(xmlns + "latitude").Element(xmlns + "value").Value),
// Longitude = Convert.ToDouble(ev.Element(xmlns + "origin").Element(xmlns + "longitude").Element(xmlns + "value").Value),
// };
QuakeLayer.Children.Clear();
foreach(var ev in events)
{
var accentBrush = (Brush)Application.Current.Resources["PhoneAccentBrush"];
var pin = new Pushpin
{
Location = new GeoCoordinate
{
Latitude = ev.Latitude,
Longitude = ev.Longitude
},
Background = accentBrush,
};
QuakeLayer.AddChild(pin, pin.Location);
}
}
private void OnRefresh(object sender, RoutedEventArgs e)
{
LoadQuakes();
}
}
}
主页上的地图项:
【问题讨论】:
-
以上代码中哪几行是第37行?
-
PS:app.xaml.cs 中的第 37 行:Debugger.Break();在:私有静态无效OnUnhandledException(对象发件人,ApplicationUnhandledExceptionEventArgs e){if(Debugger.IsAttached)Debugger.Break(); }
标签: c# xml silverlight windows-phone-7