WP7 在地图上移动对象
我在 Windows Phone 7 MapLayer 的地图控件上有一个图像,我需要能够移动该图像。如果能对其进行改造(动画化)就好了,但不是必须的。
假设我有一个名为 pLayer
的 MapLayer,并且向其中添加了一个图像:
Image img = new Image();
img.Source = new BitmapImage(new Uri("XXX.png"));
pLayer.AddChild(img, new GeoCoordinate(LAT, LNG) );
将其添加到 MapLayer [pLayer]
后,如何移动其位置?
我可以访问 pLayer.Childeren[KEY].Location
或其他内容吗?
I have an image on a Windows Phone 7 MapLayer on a map control that I need to be able to move. It would be great to transform it (animate) but not a must.
So lets say i have a MapLayer called pLayer
and I add an image to it:
Image img = new Image();
img.Source = new BitmapImage(new Uri("XXX.png"));
pLayer.AddChild(img, new GeoCoordinate(LAT, LNG) );
how do i move its location after i've added it to the MapLayer [pLayer]
?
Can I access the pLayer.Childeren[KEY].Location
or something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道是否有更简单的方法,但一种选择是从图层中删除对象,然后将其重新添加到新位置。
这个答案还提供了一个使用绑定的更复杂的解决方案。
I don't know if there is a simpler method, but one optioin is to remove the object from the layer, and then re-add it in the new location.
This answer also give a somewhat more complicated solution using binding.
我认为您需要创建一个与地图控件大小相同的画布,然后将其添加为地图图层的子级,并将图像添加为画布的子级。这样您就可以通过处理触摸手势将图像绝对定位在画布上的任何位置。 Silverlight Toolkit for WP7 中的 GestureService.GestureListener 提供的事件使此操作变得更容易。
I think you'll need to create a Canvas the same size as the Map control, then add that as a child of a map layer and add the Image as a child of the Canvas. This should then give you the ability to position the image absolutely anywhere on the canvas by handling touch gestures. The GestureService.GestureListener in the Silverlight Toolkit for WP7 provides events that make this easier.