我正在使用MapControl在地图上绘制路线(使用GMapsUWPSDK)。它使用一组位置绘制路线。现在,我想在这条路线上移动车辆。为此,我已经完成了以下操作。
Image vehicleImg = new Image
{
Width = 40,
Source = VehicleIconSource
};
MyMap.Children.Add(vehicleImg);
AddLocationsOfVehicle() //location of vehicle change when calling this function
{
BasicGeoposition geoposition = new BasicGeoposition();
geoposition.Latitude = AppGlobals._VehicleDetailsList[0].VLat;
geoposition.Longitude = AppGlobals._VehicleDetailsList[0].VLng;
Geopoint mypoint = new Geopoint(geoposition);
MapControl.SetLocation(vehicleImg , mypoint);
}
现在车辆正在从一个位置跳到另一位置,而不是如何将车辆从一个位置移动到另一个位置?这是在路线上添加车辆的正确方法吗?有没有有用的链接可以完成此任务?另外,现在车辆未按照Google地图中的说明正确放置在路线上。图片被视为仅在路线外。当转弯时,我该如何旋转/转弯车辆?
答案 0 :(得分:1)
您可以为此添加图钉(标记),并在 Image属性 参见this
这是示例代码
public void AddSpaceNeedleIcon()
{
var MyLandmarks = new List<MapElement>();
BasicGeoposition snPosition = new BasicGeoposition { Latitude = 47.620, Longitude = -122.349 };
Geopoint snPoint = new Geopoint(snPosition);
var spaceNeedleIcon = new MapIcon
{
Location = snPoint,
NormalizedAnchorPoint = new Point(0.5, 1.0),
ZIndex = 0,
Title = "Space Needle"
};
MyLandmarks.Add(spaceNeedleIcon);
var LandmarksLayer = new MapElementsLayer
{
ZIndex = 1,
MapElements = MyLandmarks
};
myMap.Layers.Add(LandmarksLayer);
myMap.Center = snPoint;
myMap.ZoomLevel = 14;
}