MLP*_*CiM 3 c# bing-maps windows-phone-8
我试图用一个MapPolyLine在我的地图,以显示实时路线,希望这将移动/规模这段时间.事情是地图上没有显示该行,我找不到任何编程错误:
C#
MapLayer pathLayer;
//Constructor
pathLayer = new MapLayer();
MapPolyline line = new MapPolyline();
line.StrokeColor = Colors.Red;
line.StrokeThickness = 10;
//line.Path.Add(several points); Tested, no effect
MapOverlay overlay = new MapOverlay();
overlay.Content = line;
//overlay.GeoCoordinate = new GeoCoordinate(0,0); Tested, no effect
//overlay.PositionOrigin = new Point(0.0, 1.0); Tested, no effect
pathLayer.Add(overlay);
MyMap.Layers.Add(pathLayer);
void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
MapPolyline line = pathLayer.First(TrackPath).Content as MapPolyline;
line.Path.Add(args.Position.Coordinate); // Checked values, line.Path adds them correctly
}
Run Code Online (Sandbox Code Playgroud)
编辑:新信息.尝试使用XAML添加模拟器时,模拟器显示错误,模拟器将地图顶部的类名称显示为图形故障:

MapPolylines并且MapPolygons应该被添加到MapElements集合中......不是a MapLayer或a MapOverlay.
您应该能够使此示例适合您.
MapPolyline line = new MapPolyline();
line.StrokeColor = Colors.Red;
line.StrokeThickness = 10;
line.Path.Add(new GeoCoordinate(47.6602, -122.098358));
line.Path.Add(new GeoCoordinate(47.561482, -122.071544));
MyMap.MapElements.Add(line);
Run Code Online (Sandbox Code Playgroud)
在你的GeoCoord观察者中,你必须从地图MapElements集合中获取该行,并将新位置添加到行的路径而不是像我那样预定义.这应该是可行的.