在UWP Bing地图中为MapIcon纬度值指定PropertyPath

时间:2019-02-06 00:09:54

标签: c# animation uwp bing-maps uwp-maps

我正在尝试在Bing地图的UWP版本中为MapIcon的位置设置动画。我在为PropertyPath的{​​{1}}组件(Latitude值)(图标的中心值)指定double时遇到问题:

GeoPoint

所有已注释掉的陈述均无效;它们都会导致“无法在指定对象上解析TargetProperty”错误。我对第一次尝试 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(); 充满希望,但没有运气。

(我能够成功为MapIcon的Color属性设置动画。)

1 个答案:

答案 0 :(得分:2)

Storyboard.SetTargetProperty定位动画应用到的依赖项属性。因此,将动画应用于“纬度”是不可能的。

您必须自己做。例如,使用DispatcherTimer。