WP7 在地图上移动对象

发布于 2024-10-07 16:47:04 字数 420 浏览 0 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

七色彩虹 2024-10-14 16:47:04

我不知道是否有更简单的方法,但一种选择是从图层中删除对象,然后将其重新添加到新位置。

Image img = ...some image loaded at a location on the map in the above code;
var ll = new GeoCoordinate(LAT, LNG);
Layer.Children.Remove(img);
Layer.AddChild(img, ll);

这个答案还提供了一个使用绑定的更复杂的解决方案。

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.

Image img = ...some image loaded at a location on the map in the above code;
var ll = new GeoCoordinate(LAT, LNG);
Layer.Children.Remove(img);
Layer.AddChild(img, ll);

This answer also give a somewhat more complicated solution using binding.

蓝天白云 2024-10-14 16:47:04

我认为您需要创建一个与地图控件大小相同的画布,然后将其添加为地图图层的子级,并将图像添加为画布的子级。这样您就可以通过处理触摸手势将图像绝对定位在画布上的任何位置。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文