【问题标题】:Specifying PropertyPath for a MapIcon Latitude value in UWP Bing Maps在 UWP Bing 地图中为 MapIcon 纬度值指定 PropertyPath
【发布时间】:2019-02-06 00:09:54
【问题描述】:

我正在尝试在 UWP 版本的 Bing 地图中为 MapIcon 的位置设置动画。我在为用作图标中心值的GeoPointLatitude 组件(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)",但没有运气。

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

【问题讨论】:

  • 嗨!您找到任何可行的解决方案了吗?请您介意与我们分享一下吗?
  • @DmitryBoyko 正如下面的答案所示,这在当时是不可能的,我放弃并继续前进。不知道从那以后它是否改变了。谢谢。

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


【解决方案1】:

Storyboard.SetTargetProperty 以应用动画的依赖属性为目标。所以,你想对“纬度”应用动画是不可能的。

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

【讨论】:

  • 谢谢。为了清楚起见,您是说纬度不是依赖属性吗?文档说 LocationProperty 是一个依赖属性。谢谢。
  • BasicGeoposition 是结构体。
  • 您是否介意建议为 MapIcon 设置动画的具体方法?我们是否应该定期更新 Location 属性以便我们看到平滑运动?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-04-14
  • 1970-01-01
  • 1970-01-01
  • 2016-03-06
  • 1970-01-01
  • 1970-01-01
  • 2012-10-09
相关资源
最近更新 更多