WP7 开发学习之 Map 地图小应用

用map控件 首先要先注册一个key ,我这就提供一个:AtRuCBJsbAjxD3KJI0o_UDxxQqf7_J4pF-SXlgtub4oSsOssKM_coU0XEe4c7oa8。

 

xaml:

 

<my:Map Height="558"
                    HorizontalAlignment="Left"
                    Margin="21,6,0,0"
                    Name="map1"
                    VerticalAlignment="Top"
                    Width="429"
                    CredentialsProvider="AtRuCBJsbAjxD3KJI0o_UDxxQqf7_J4pF-SXlgtub4oSsOssKM_coU0XEe4c7oa8"
                     ZoomBarVisibility="Visible"
                    ScaleVisibility="Visible"
                    Mode="aerial"
                    />

zoomBarvisibility 设置是否显示变焦按钮  zoom就是变焦的意思嘛,scale是规模的意思,所以就会知道scalevisibilty是显示比列条的。 Mode 是设置地图形式,有两个值,road 道路形式,aerila 空中俯瞰。

 

cs:

 

public partial class Map : PhoneApplicationPage
    {
        public Map()
        {
            InitializeComponent();
            //设置地图的中心位置
            map1.Center = new GeoCoordinate(30.259497, 120.129798);
            //变焦到多少
            map1.ZoomLevel = 15;

            //创建一个图钉
            Pushpin pin = new Pushpin();
            //给图钉设置地理坐标
            pin.Location = new GeoCoordinate(30.259497, 120.129798);
            //显示的内容
            pin.Content = "I am  jacklai";
            pin.Height = 200;
            pin.Width = 200;
            //背景形式
            pin.Background = new SolidColorBrush(Colors.Red);
            //把这个加到地图中
            map1.Children.Add(pin);

 


            //创建一个多边形
            //MapPolygon polygon = new MapPolygon();
            //polygon.Fill = new SolidColorBrush(Colors.Red);
            //polygon.Stroke = new SolidColorBrush(Colors.Yellow);
            //polygon.StrokeThickness = 5;
            //polygon.Opacity = 0.5;
            //polygon.Locations = new LocationCollection()
            //{
            //     new GeoCoordinate(30.259497, 120.129798),
            //     new GeoCoordinate(30.299497, 120.129998),
            //     new GeoCoordinate(30.379497, 120.329798),
            //     new GeoCoordinate(30.389497, 120.429798)


            //};
            //map1.Children.Add(polygon);

            //MapPolyline polyline = new MapPolyline();
            //polyline.Stroke = new SolidColorBrush(Colors.Red);
            //polyline.StrokeThickness = 5;
            //polyline.Locations = new LocationCollection()
            //{
            //    new GeoCoordinate(30.259497, 120.129798),
            //new GeoCoordinate(30.359497, 120.120798)
            //};

            //map1.Children.Add(polyline);

//创建图片

            Image img = new Image();
            img.Height = 100;
            img.Width = 100;
            img.Source = new BitmapImage(new Uri("/Image/1.jpg", UriKind.Relative));

            MapLayer layer = new MapLayer();

//把图片加到层中
            layer.AddChild(img, new GeoCoordinate(30.259497, 120.129798), PositionOrigin.BottomLeft);

//通过层加到地图中去显示

            map1.Children.Add(layer);

        }
    }

 

 

你可能感兴趣的:(map,wp7)