2010-04-05 94 views
3

基本上我的問題是,我已經適應了一段代碼在這裏Bing地圖Silverlight控件圖釘結垢問題

http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/62e70670-f306-4bb7-8684-549979af91c1

這不正是我想要它做的發現,那就是擴大一些圖釘圖片根據地圖的縮放級別。唯一的問題是,我已經調整了這個代碼來運行bing地圖silverlight控件(不像原始示例中的虛擬地球),現在圖像縮放correclty,但它們被重新定位並且只有當我的縮放級別達到期望的位置時是最大的。任何想法爲什麼?幫助將不勝感激:)

下面

修改後的代碼:

var layer = new MapLayer(); 
map.AddChild(layer); 

//Sydney 
layer.AddChild(new Pin 
{ 
    ImageSource = new BitmapImage(new Uri("pin.png", UriKind.Relative)), 
    MapInstance = map 
}, new Location(-33.86643, 151.2062), PositionMethod.Center); 

變得像

layer.AddChild(new Pin 
{ 
    ImageSource = new BitmapImage(new Uri("pin.png", UriKind.Relative)), 
    MapInstance = map 
}, new Location(-33.92485, 18.43883), PositionOrigin.BottomCenter); 

我假定它是與在Bing地圖錨以不同的方式其UI元素。關於這方面的細節也非常有用。謝謝!

回答

1

嘗試加入自己的固定大小的BitmapImage到地圖上,而不是使用圖釘類

+0

是的,工作,抱歉的前一篇文章。這只是爲轉換設置固定大小並相應地設置centerx和centery屬性。感謝earthware :) – 2010-04-06 14:14:29

1

由於陶器的迴應,我設法解決我的問題。這只是添加圖像direclty(不涉及圖釘類)的問題,添加固定大小並相應地設置縮放的CenterX和CenterY屬性。代碼示例如下:

image.Source = new BitmapImage(new Uri("pin.png", UriKind.Relative)); 
image.Stretch = System.Windows.Media.Stretch.None; 
image.Height = 152; 
image.Width = 116; 

layer.AddChild(image, new Location(-33.86643, 151.2062), PositionOrigin.BottomCenter); 
image.RenderTransform = scaleTr; 

scaleTr.CenterX = image.Width/2; //image is alligned bottom center (see above) 
scaleTr.CenterY = image.Height;