如何绘制折线Bing地图Silverlight控制
本文关键字:Bing 地图 Silverlight 控制 折线 何绘制 绘制 | 更新日期: 2023-09-27 18:19:17
我正在使用Windows phone 7的bing地图控件,我的折线仅在模拟器中绘制。当我在设备上运行时,什么也没有发生…
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);
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);
}