我有一个Bing地图控制器,我想动画 地图上画的插针的位置。
Ideally I d want to write code like this:
// Image myPin = some Image on the map layer;
var sb = new Storyboard();
var duration = DurationHelper.FromTimeSpan(System.TimeSpan.FromMilliseconds(1000));
sb.Duration = duration;
LocationAnimation ani = new LocationAnimation();
ani.To = new Location(33.3, 11.1); // destination lat, lng
ani.Duration = duration;
sb.Children.Add(ani);
Storyboard.SetTarget(ani, myPin);
Storyboard.SetTargetProperty(ani, "MapLayer.Position");
Resources.Add("moveMyPin", sb);
sb.Begin();
当然,在框架中没有 LobtionAnimation
类。有几类类似的东西: PointAnimation
与 >point 类型合作,而
DoubleAnimation
与单项 双
价值合作。
我假设我必须执行我的“Timeline -product class”课程,但我迄今发现的文件在这方面没有帮助,我不知道从何说起。
如何对没有动画课的财产动画?
<强> 更新 强 > : 我<他们> 认为 他们> 我可以做类似的事情
// let aniX and aniY be two DoubleAnimation objects
StoryBoard.SetTargetProperty(aniX, "(MapLayer.Position).Latitude")
StoryBoard.SetTargetProperty(aniY, "(MapLayer.Position).Longitude")
但现在我又遇到另一个问题, 因为我看不到如何动画附着的房产, 并总是得到一个例外, 比如“ 无法解决目标属性( MapLayer. possition) 。 耐心等待指定对象 ” 。
所以我猜现在的问题是: 如何为附加属性指定属性路径? em>
< 坚固 > 进一步更新 < / 坚固 > : 我可能使用“ etTagetProperty” 错误的线索, 因为这会使一个 < em > 依赖动画 < / em > (见注释中的链接) 。 是否有更好的方法将一个标记针添加到协调点?
<强度> 更新3 < /强度 > : 正如Jared指出的,我可以尝试动画 < code> Render Transform ,或者利用过渡实现我的结果。我已经这样做了,但似乎不是我的解决办法。
- Using
RepositionThemeAnimation
, it seems I have to give the new pixel position of the pin. This is problematic for a couple reasons: first, I know the lat/lng destination of the pin, but would have to work out the projection (as far as I can tell there is no public interface to work with projection). Secondly the projection itself can change as the map zooms/pans. The pixel destination at the time of the end of the animation could not be the same as the initial pixel destination. In my scenario it s a major problem as it s very likely the map is moving while the animation is occurring. - Using
RepositionThemeTransition
all the weird pixel/projection problems went away. It s the only way so far I was able to see the animation I expected. I just set the transition and set the new lat/lng position of the tag (via MapLayer.SetPosition). It has two major problems though. I can t set the duration (nor the easing functions) for the animation. And most importantly I can see no way to execute code when the pin gets to its final position.