次のように、Silverlight bing マップ コントロールに画像を配置します。
MapLayer mapLayer = new MapLayer();
this.myMap.Children.Add(mapLayer);
Image image = new Image();
BitmapImage btm = new System.Windows.Media.Imaging.BitmapImage(new Uri("/myAssembly;component/Images/myImage.png", UriKind.Relative));
image.Source = btm;
LocationRect rect = new LocationRect(new Location(10, 12), new Location(55, 55));
mapLayer.AddChild(image, rect);
これはうまくいっています。しかし、コード内の別の場所で場所を取得する方法が見つかりません。私は試します:
var loc = MapLayer.GetPosition(image) --> Always returning null !!!
mapLayer.ParentMap.TryViewportPointToLocation
maplayer オブジェクトには子の位置を取得するメソッドがなく、画像Width
とHeight
プロパティが常に 0であるため、位置を計算できません(なぜですか??)。
これどうやってするの?