我正在尝试在UWP版本的必应地图中对MapIcon的位置进行动画处理。 我在指定用作图标中心值的GeoPoint
Latitude
组件(double
值(的PropertyPath
时遇到问题:
MapIcon mapIcon1 = new MapIcon();
mapIcon1.Location = myMap.Center;
mapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
mapIcon1.Title = "My Friend";
mapIcon1.Image = mapIconStreamReference;
mapIcon1.ZIndex = 0;
myMap.MapElements.Add(mapIcon1);
double centerLatitude = myMap.Center.Position.Latitude;
double centerLongitude = myMap.Center.Position.Longitude;
Storyboard storyboard = new Storyboard();
DoubleAnimation animation = new DoubleAnimation();
animation.From = centerLatitude;
animation.To = centerLatitude + 100f;
animation.Duration = new Duration(new TimeSpan(0, 0, 0, 5));
animation.EnableDependentAnimation = true;
storyboard.Children.Add(animation);
//Storyboard.SetTargetProperty(animation, "(MapIcon.Location)(Geopoint.Position)(BasicGeoposition.Latitude)");
//Storyboard.SetTargetProperty(animation, "(MapIcon.Location)(MapControl.Center)(Geopoint.Position)(BasicGeoposition.Latitude)");
//Storyboard.SetTargetProperty(animation, "(MapIcon.Location)(BasicGeoposition.Latitude)");
//Storyboard.SetTargetProperty(animation, "(MapIcon.Location.Latitude)");
Storyboard.SetTarget(storyboard, mapIcon1);
storyboard.Begin();
注释掉的语句都不起作用;它们都会导致"无法解析指定对象上的 TargetProperty"错误。 我对"(MapIcon.Location)(Geopoint.Position)(BasicGeoposition.Latitude)"
第一次尝试特别有希望,但没有运气。
(我能够成功地对地图图标的颜色属性进行动画处理。
>Storyboard.SetTargetProperty
以应用动画的依赖项属性为目标。因此,要将动画应用于"纬度"是不可能的。
你必须自己做。例如,使用调度程序计时器。