Webサーバーからxmlを解析し、緯度/経度のニックネームや画像などのユーザー情報を取得し、それらをマップにバインドするタスクがありました。 。私は、WebClientとXDocumentを使って構文解析を行います。緯度/経度のタイプとそのマップへのバインディングの仕組みは何ですか?xmlからのマップへの緯度/経度のバインディングwp7
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
using (var reader = new StreamReader(e.Result))
{
// string[] _elements = { "one", "two", "three" };
int[] counter = { 1 };
string s = reader.ReadToEnd();
Stream str = e.Result;
str.Position = 0;
XDocument xdoc = XDocument.Load(str);
var data = from query in xdoc.Descendants("position")
select new mapping
{
// color = counter[0]++,
album = (string)query.Element("album"),
track = (string)query.Element("track"),
artist = (string)query.Element("artist"),
nickname = (string)query.Element("user_info").Element("nickname"),
pos_lat = (GeoCoordinate)query.Element("lat"),
};
// lb1.ItemsSource = data;
// listbox1.ItemsSource = data;
}
}
public class mapping
{
public int index { get; set; }
public string album { get; set; }
public string track { get; set; }
public string artist { get; set; }
public GeoCoordinate pos_lat { get; set; }
public GeoCoordinate pos_lon { get; set; }
public string nickname { get; set; }
}
<Microsoft_Phone_Controls_Maps:Map Height="427" HorizontalAlignment="Left" Margin="12,6,0,0" Name="map1" VerticalAlignment="Top" Width="438" />