简体   繁体   中英

WP7 Moving Objects on a Map

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?

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM