我想在我的地圖中使用MapPolyLine來顯示實時路線,希望它會移動/縮放this time。事情是在地圖上之所以未行了,我找不到任何編程錯誤: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
}
編輯:新信息。仿真器顯示錯誤嘗試使用XAML添加它時,和仿真器顯示在地圖上作爲圖形毛刺的頂部類的名稱:
我也看到了XAML錯誤,但它仍在建立,當我在XAML中定義路徑時,折線顯示出來。 – user8709