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(开发者_C百科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.
精彩评论