我正在使用Windows Phone 7的bing maps控件,而我的折线仅在模拟器中绘制。 当我在设备上运行时没有任何事情发生......
XDocument doc = XDocument.Parse(getRoute1()); //private string getRoute1() return gpx file
var ns = doc.Root.GetDefaultNamespace();
var loc = doc.Descendants()
.Where(el => el.Name == ns + "wpt" || el.Name == ns + "trkpt")
.Select(trkpt =>
new Location
{
Latitude = double.Parse(trkpt.Attribute("lat").Value),
Longitude = double.Parse(trkpt.Attribute("lon").Value)
}).ToLocationCollection();
mapPolyline.Locations = loc;
maps.Children.Add(mapPolyline);
答案 0 :(得分:0)
public MainPage()
{
InitializeComponent();
double[] lattitudes = { 50.21934078740, 33.563511, 19.511719, 25.3125 };
double[] longitudes = { 23.0518068854053, 35.368259, -14.43468, 67.542167 };
this.DrawPolyLine(lattitudes, longitudes);
}
private void DrawPolyLine(double []lat, double[]longi)
{
MapPolyline line = new MapPolyline();
line.Stroke = new SolidColorBrush(Colors.Brown);
line.StrokeThickness = 3;
line.Locations = new LocationCollection();
for (int i=0;i<4;i++){
line.Locations.Add(new Location(lat[i], longi[i]));
Pushpin p = new Pushpin();
p.Location = new Location(lat[i], longi[i]);
map1.Children.Add(p);
}
map1.Children.Add(line);
}