BINGMAP 在某个坐标点上面显示 坐标的信息

<UserControl 
           
             
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"
 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    >

    <Grid x:Name="LayoutRoot" Background="#dae6f4">

     

 <m:Map Grid.Row="1" x:Name="myMap" Center="35,108" ZoomLevel="3.5"  NavigationVisibility="Collapsed"  CredentialsProvider="AlIyl9T8dhLKPso-zGjfeUzDjWzpmUOWyo1Z5iZuQ4OQZIqaqQQkoMPBgEn-aa40" >
            <Canvas x:Name="ca" Height="50" Width="80" m:MapLayer.Position="38,100" m:MapLayer.PositionOrigin="BottomCenter" Opacity="0.5">
                <Path Data="M 0,0 L 50,0 50,50 25,80 0,50 0,0" Fill="Red" Stroke="Wheat" StrokeThickness="2" />
                <TextBlock FontSize="10" Foreground="White" Margin="5" TextAlignment="Center">
                        Space <LineBreak />
                        Needle <LineBreak />
                </TextBlock>

            </Canvas>
        </m:Map>
           </Grid>
</UserControl>

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Maps.MapControl;
using Microsoft.Maps.MapControl.Core;
using WebFdaShow.QarWcfService;
namespace WebFdaShow
{
    public partial class BinMap : UserControl
    {
       
       
        QarServiceClient qc = new QarServiceClient();
        public BinMap()
        {
           
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(BinMap_Loaded);
        
           
          
        }

        void BinMap_Loaded(object sender, RoutedEventArgs e)
        {
            if (myMap.ZoomLevel > 8 || myMap.ZoomLevel < 3.5)
            {
                myMap.ZoomLevel = 3.5;
            }
            UriBuilder tileSourceUri = new UriBuilder("http://r2.tiles.ditu.live.com/tiles/r{quadkey}.png?g=41");  //初始化一个Uri对象,指向中文必应地图的Tile系统
            MapTileLayer tileLayer = new MapTileLayer(); //初始化一个图层
            LocationRectTileSource tileSource = new LocationRectTileSource(
                                                            tileSourceUri.Uri.ToString(),
                                                            new LocationRect(new Location(60, 60), new Location(13, 140)),
                                                            new Range<double>(1, 3)
                //new Range<double>(1, 1)
                                                            ); // 初始化LocationRectTileSource对象,设定显示范围及放大级别
            tileLayer.TileSources.Add(tileSource); //指定图层的TileSource
            tileLayer.Opacity = 1;
            myMap.Children.Add(tileLayer); //将图层叠加在地图上
           
            //fldpick.Text = DateTime.Now.ToString();
            fldpick.Text = "2010-8-13";
        }
        //private void Geocode(string strAddress, int waypointIndex)
        //{
        //    GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
        //    geocodeService.GeocodeCompleted += new EventHandler<GeocodeCompletedEventArgs>(geocodeService_GeocodeCompleted);
        //    GeocodeRequest geocodeRequest = new GeocodeRequest();
        //    geocodeRequest.Credentials = new Credentials();
        //    geocodeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)myMap.CredentialsProvider).ApplicationId;
        //    geocodeRequest.Query = strAddress;
        //    geocodeService.GeocodeAsync(geocodeRequest, waypointIndex);
        //}

 

        //private void geocodeService_GeocodeCompleted(object sender, GeocodeService.GeocodeCompletedEventArgs e)
        //{
        //    GeocodeResult result = null;
        //    if (e.Result.Results.Count > 0)
        //    {
        //        result = e.Result.Results[0];
        //        if (result != null)
        //        {
        //            this.ShowMarker(result);
        //        }
        //    }
        //}
       
       
        private void ShowMarker(double lati, double longi)
        {
           
            MapLayer myLayer = new MapLayer();
            myMap.Children.Add(myLayer);
            Ellipse point = new Ellipse();
            point.Width = 1;
            point.Height = 1;
            point.Fill = new SolidColorBrush(Colors.Blue);
            point.Opacity = 1;

            Location location = new Location(lati, longi);
            MapLayer.SetPosition(point, location);
            MapLayer.SetPositionOrigin(point, PositionOrigin.Center);
            myLayer.Children.Add(point);
        }
        Rectangle rec = new Rectangle();
       
        private void ShowMarker1(double lati, double longi,string NaviCode)
        {

          
           
            MapLayer myLayer = new MapLayer();
            myMap.Children.Add(myLayer);
            Rectangle point = new Rectangle();
           
            point.Width = 5;
            point.Height = 5;
            point.Fill = new SolidColorBrush(Colors.Black);
            point.Opacity = 1;
            //point.Tag = 1;
           

           
            Location location = new Location(lati, longi);
            MapLayer.SetPosition(point, location);
            MapLayer.SetPositionOrigin(point, PositionOrigin.Center);
            //Pushpin ps = new Pushpin();
            //ps.Location = location;
            //ps.Content = NaviCode;
            //ps.FontSize = 8;
            //ps.HorizontalContentAlignment = HorizontalAlignment.Center;
            //ps.Foreground = new SolidColorBrush(Colors.Black);
            //myLayer.Children.Add(ps);


            TextBlock tb = new TextBlock();
            Path pa = new Path();
            RectangleGeometry myrec = new RectangleGeometry();
            myrec.RadiusX = 40;
            myrec.RadiusY = 50;
           
            pa.Data = myrec;
            //pa.Data ={"M 0,0 L 50,0 50,50 25,80 0,50 0,0"};
            pa.Fill=new SolidColorBrush(Colors.Red);
            tb.Text = NaviCode;
            tb.Foreground=new SolidColorBrush(Colors.Black);
            Canvas cas = new Canvas();
            MapLayer.SetPosition(cas, location);
            cas.Children.Add(tb);
            MapLayer.SetPositionOrigin(cas, PositionOrigin.BottomLeft);
            myLayer.Children.Add(cas);
            //Rectangle rec = new Rectangle();
            //rec.Width = 100;
            //rec.Height = 50;
            //rec.Fill =
            //rec.Stroke = new SolidColorBrush(Colors.Black);
            //rec.DataContext = NaviCode;
            //rec.Tag = NaviCode;
            //rec.Name = NaviCode;
            //rec.Opacity = 1;
            //MapLayer.SetPosition(rec, location);
            //MapLayer.SetPositionOrigin(rec, PositionOrigin.BottomLeft);
            //myLayer.Children.Add(rec);
            myLayer.Children.Add(point);
           
           
          
        }

       

     

      
     
        private void ShowLine(double lati1, double longi1, double lati2, double longi2)
        {
            MapPolyline line = new MapPolyline();
            line.Stroke = new SolidColorBrush(Colors.Blue);
            line.StrokeThickness = 2;
            line.Opacity = 0.65;
            line.Locations = new LocationCollection() { new Location(lati1, longi1),new Location( lati2, longi2) };
            myMap.Children.Add(line);
        }
        private void ShowLine1(double lati1, double longi1, double lati2, double longi2)
        {
            MapPolyline line = new MapPolyline();
            line.Stroke = new SolidColorBrush(Colors.Black);
            line.StrokeThickness = 2;
            line.Opacity = 0.65;
            line.Locations = new LocationCollection() { new Location(lati1, longi1), new Location(lati2, longi2) };
            myMap.Children.Add(line);
        }
        private void Search_Click(object sender, RoutedEventArgs e)
        {
           
            Window.ShowLoading(BinMapUC, "");
          
            tbArri.Text = tbArri.Text.ToUpper();
            tbDepa.Text = tbDepa.Text.ToUpper();
            tbFlno.Text = tbFlno.Text.ToUpper();
            if (!tbFlno.Text.StartsWith("MF"))
            {
                tbFlno.Text = "MF" + tbFlno.Text;
            }
            myMap.Children.Clear();
            qc.GetFlightAltitudeDeDataCompleted += new EventHandler<GetFlightAltitudeDeDataCompletedEventArgs>(qc_GetFlightAltitudeDeDataCompleted);
            qc.GetFlightAltitudeDeDataAsync(DateTime.Parse(fldpick.Text), tbFlno.Text,tbDepa.Text,tbArri.Text);
            QarServiceClient qc1 = new QarServiceClient();
            qc1.GetFrameDataCompleted += new EventHandler<GetFrameDataCompletedEventArgs>(qc1_GetFrameDataCompleted);
            qc1.GetFrameDataAsync(DateTime.Parse(fldpick.Text), tbFlno.Text, tbDepa.Text, tbArri.Text);
            UriBuilder tileSourceUri = new UriBuilder("http://r2.tiles.ditu.live.com/tiles/r{quadkey}.png?g=41");  //初始化一个Uri对象,指向中文必应地图的Tile系统
            MapTileLayer tileLayer = new MapTileLayer(); //初始化一个图层
            LocationRectTileSource tileSource = new LocationRectTileSource(
                                                            tileSourceUri.Uri.ToString(),
                                                            new LocationRect(new Location(60, 60), new Location(13, 140)),
                                                            new Range<double>(1, 3)
                //new Range<double>(1, 1)
                                                            ); // 初始化LocationRectTileSource对象,设定显示范围及放大级别
            tileLayer.TileSources.Add(tileSource); //指定图层的TileSource
            tileLayer.Opacity = 1;
           
            myMap.Children.Add(tileLayer); //将图层叠加在地图上
            if (myMap.ZoomLevel > 8 || myMap.ZoomLevel < 3.5)
            {
                myMap.ZoomLevel = 3.5;
            }
         
        }

        void qc1_GetFrameDataCompleted(object sender, GetFrameDataCompletedEventArgs e)
        {
            if (e.Result != null&&e.Result.Count>0)
            {
                List<FrameData> fds = new List<FrameData>();
                foreach (FrameData fd in e.Result)
                {
                    ShowMarker(fd.Latitude, fd.Longitude);
                    fds.Add(fd);
                }
                for (int i = 0; i < fds.Count - 1; i++)
                {
                    ShowLine(fds[i].Latitude, fds[i].Longitude, fds[i + 1].Latitude, fds[i + 1].Longitude);
                }
            }
            Window.HideLoading();
        }

        void qc_GetFlightAltitudeDeDataCompleted(object sender, GetFlightAltitudeDeDataCompletedEventArgs e)
        {
            if (e.Result != null && e.Result.Count > 0)
            {
                List<FlightAltitude> fas = new List<FlightAltitude>();
                foreach (FlightAltitude fa in e.Result)
                {
                    ShowMarker1(fa.Latitude, fa.Longitude,fa.NaviCode);
                    fas.Add(fa);
                }
                for (int i = 0; i < fas.Count - 1; i++)
                {
                    ShowLine1(fas[i].Latitude, fas[i].Longitude, fas[i + 1].Latitude, fas[i + 1].Longitude);
                }
            }
          
        }


    

 

    }
}

转载于:https://www.cnblogs.com/MK_SUN/archive/2010/11/16/1822180.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值