[Silverlight] Bing Map 加入標記點(pushpin)
2010/08/07
今天寫一下怎麼在Silverlight 的Bing map 中加入.. 標記點..
其實如果從XAML 中很簡單 ..
只需要在map 中加入 <m:Pushpin Location="緯度,經度" />
即可 ..
<m:Map x:Name="myMap" CredentialsProvider="AhkMeJNiD6a8JSGoC2QIHe47XzBhLqzH_y34nDsbv5kIEbBrEZ9WY_hG4x1DZnd-" Mode="Road" LogoVisibility="Collapsed" >
<m:Pushpin Location="25.02,121.56" />
</m:Map>
如果是在C# 中..
就必須要在map 中載入一層MapLayer
其實做法跟Google map 大同小異..
接下來C# code 如下..
var myLayer = new MapLayer();
//將地圖插入一個MapLayer
myMap.Children.Add(myLayer);
Pushpin ppHeeyuki = new Pushpin();
//在MapLayer加入pin並且標記位置
myLayer.AddChild(ppHeeyuki,new Location( 25.0279845,121.5683636));
//將標記位置設成地圖中央
this.myMap.SetView(new Location(25.0279845, 121.5683636), 16);
這範例是點擊按鈕後會把map移到heeyuki位置,並且把Zoomlevel 放到16並標記..
其實MapLayer這東西 很重要..
pushpin會被放在MapLayer上面..
之後很多範例也都會說到….
範例:
讚一下:
下載範例:
標籤:
Bing Map,
C#,
Silverlight
|
This entry was posted on 下午2:09
and is filed under
Bing Map
,
C#
,
Silverlight
.
You can follow any responses to this entry through
the RSS 2.0 feed.
You can leave a response,
or trackback from your own site.
訂閱:
張貼留言 (Atom)
0 意見:
張貼留言