Windows phone 7 使用WP7的Bing地图显示图钉
我尝试使用下面的方法在带有WP7的Bing地图中显示一个位置列表(来自xml文档:使用xml读取),但它不起作用。 当我试图查看我的函数正在读取的内容时,我发现它没有提取经度。问题出在哪里Windows phone 7 使用WP7的Bing地图显示图钉,windows-phone-7,xml-parsing,bing-maps,Windows Phone 7,Xml Parsing,Bing Maps,我尝试使用下面的方法在带有WP7的Bing地图中显示一个位置列表(来自xml文档:使用xml读取),但它不起作用。 当我试图查看我的函数正在读取的内容时,我发现它没有提取经度。问题出在哪里 void frloc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { if (e.Error == null) { ListBoxItem
void frloc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error == null)
{
ListBoxItem areaItem = null;
StringReader wkstream = new StringReader(e.Result);
XmlReader wkreader = XmlReader.Create(wkstream);
string areaName = String.Empty;
string Nom = String.Empty;
string Photo = String.Empty;
string Latitude = String.Empty;
string Longitude = String.Empty;
string Timing = String.Empty;
while (wkreader.Read())
{
if (wkreader.NodeType == XmlNodeType.Element)
{
switch (wkreader.Name)
{
case ("name"):
{
Nom = wkreader.ReadElementContentAsString();
areaItem = new ListBoxItem();
areaItem.Content = Nom;
} break;
case ("photo"):
{
Photo = wkreader.ReadElementContentAsString();
areaItem = new ListBoxItem();
areaItem.Content = Photo;
} break;
case ("latitude"):
{
Latitude = wkreader.ReadElementContentAsString();
areaItem = new ListBoxItem();
areaItem.Content = Latitude;
} break;
case ("longitude"):
{
Longitude = wkreader.ReadElementContentAsString();
areaItem = new ListBoxItem();
areaItem.Content = Longitude;
} break;
}
double lat, lon;
double.TryParse(Latitude, NumberStyles.Any, CultureInfo.InvariantCulture, out lat);
double.TryParse(Longitude, NumberStyles.Any, CultureInfo.InvariantCulture, out lon);
GeoCoordinate Loc = new GeoCoordinate(lat, lon);
Pushpin wkpin = new Pushpin();
Image wkpinImage = new Image();
wkpin.Content = Nom;
wkpinImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("http://weenek.com/markers/" + Photo, UriKind.Absolute));
wkpinImage.Opacity = 0.8;
wkpinImage.Stretch = System.Windows.Media.Stretch.None;
imageLayer.AddChild(wkpinImage, Loc);
map1.Children.Add(wkpin);
xml:
<resultat>
<ami>
<id>547</id>
<nom>Hakim</nom>
<prenom>Abidi</prenom>
<latitude>37.01406741589469</latitude>
<longitude>11.02375026562504</longitude>
<date>2011-12-02</date>
<time>01:09:35</time>
<image>175.jpg</image>
</ami>
</resultat>
547
哈基姆
阿比迪
37.01406741589469
11.02375026562504
2011-12-02
01:09:35
175.jpg
您的代码没有问题,只是您从未设置图钉的坐标
尝试添加
wkpin.Location = Loc;