[Winodows Phone 7控件详解]Map-2

1. 加一个标记:

加标记,是地图中最常用的方法。它和bing map又有所不同,首先所在的命名空间不同;其次显示方式不同;但总之都是可以在模拟上运行的。

 //加标记
Pushpin pin = new Pushpin();
pin.Location = new GeoCoordinate(30.26, 120.13);
pin.Width = 300;
pin.Height = 300;
pin.Content = "某某体育馆";
pin.Background = new SolidColorBrush(Colors.Blue);
map1.Children.Add(pin);

2. 绘制多边型区域:

 //绘制多边形区域
MapPolygon polygon = new MapPolygon();
polygon.Locations = new LocationCollection() { new GeoCoordinate(30.259497, 120.129798),
new GeoCoordinate(30.359497, 120.329998),
new GeoCoordinate(30.379497, 120.529798),
new GeoCoordinate(30.389497, 120.729798) };
polygon.Stroke = new SolidColorBrush(Colors.Red);
polygon.StrokeThickness = 5;
polygon.Fill = new SolidColorBrush(Colors.Green);
map1.Children.Add(polygon);

3. 绘制多边线:

//绘制多边线
MapPolyline polyline = new MapPolyline();
polyline.Stroke = new SolidColorBrush(Colors.Yellow );
polygon.StrokeThickness = 10;
polyline.Locations = new LocationCollection() {
new GeoCoordinate(30.259497, 120.129798),
new GeoCoordinate(30.289497, 120.120998)
};
map1.Children.Add(polyline);

4.在地图上增加图片:

//在地图上加入图片
MapLayer imagelayer = new MapLayer();
Image image = new Image();
image.Width = 150;
image.Height = 150;
image.Source = new BitmapImage(new Uri("Images/1.jpg",UriKind.Relative));

imagelayer.AddChild( (UIElement)image , new GeoCoordinate(30.259497, 120.129798), PositionOrigin.BottomLeft);
map1.Children.Add(imagelayer);

 可以参考Silverlight Maps:http://www.microsoft.com/maps/isdk/silverlight/做出相应的功能。

posted @ 2012-04-04 11:43  DebugLZQ  阅读(366)  评论(0编辑  收藏  举报