首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为UWP地图中的MapIcon纬度值指定PropertyPath

为UWP地图中的MapIcon纬度值指定PropertyPath
EN

Stack Overflow用户
提问于 2019-02-06 08:09:54
回答 1查看 61关注 0票数 1

我正在尝试在必应地图的UWP版本中动画显示MapIcon的位置。我在为用作图标中心值的GeoPointLatitude组件( double值)指定PropertyPath时遇到问题:

代码语言:javascript
复制
        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();

注释掉的语句都不起作用;它们都会导致"Cannot resolve TargetProperty on specified object“错误。我对第一次尝试"(MapIcon.Location)(Geopoint.Position)(BasicGeoposition.Latitude)"特别有希望,但没有运气。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-02-06 13:55:07

Storyboard.SetTargetProperty的目标是应用动画的依赖属性。所以,你想要将动画应用于‘Latitude’是不可能的。

你就得自己做了。例如,使用DispatcherTimer。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54544933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档