コード例 #1
0
        async void CenterlnglatAroundPOISearch(string cityCode, int number, string searchName)
        {
            DateTime        st = DateTime.Now;
            POISearchOption p  = new POISearchOption();

            p.CityCode = cityCode;
            //  p.SrcType = dataTypeInput.SelectedItem;
            p.SrcType    = GetValue;
            p.Number     = number;
            p.Sid        = "1005"; //服务编码 默s认为1000-关键字查询 1001-根据中心点关键字查询周边兴趣点 1002-根据中心点坐标查询周边兴趣点 1005-以拉框方式查询图形区域内的关键字信息.
            p.SearchName = searchName;
            p.Region     = "116.3544845,39.98882653;116.37010574,39.89722607;116.3544845,39.89722607;116.37010574,39.98882653";
            p.RegionType = "polygon";

            POISearchResult iop = await POISearch.PoiSearchWithOption(p);

            //   POISearchResult iop = await POISearch.PoiSearchByRegionAndKeyword("中关村", "116.204,39.9938;116.456,39.8833", "rectangle", 10);
            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                if (iop.Erro == null && iop.POIs != null)
                {
                    TimeSpan elapsedSpan = new TimeSpan(DateTime.Now.Ticks - st.Ticks);
                    int i = 0;
                    SearchTextGrid.Visibility = Visibility.Collapsed;
                    Debug.WriteLine(iop);
                    foreach (POI poi in iop.POIs)
                    {
                        i++;
                        poi.Name                      = "  " + i + "、" + poi.Name;
                        ALngLat lnglat                = new ALngLat(poi.X, poi.Y);
                        AMarker poiMarker             = new AMarker();
                        poiMarker.LngLat              = lnglat;
                        ATip tip                      = new ATip();
                        tip.Title                     = poi.Name;
                        tip.ContentText               = poi.Address;
                        poiMarker.TipFrameworkElement = tip;
                        markerList1.Add(poiMarker);
                        map.Children.Add(poiMarker);
                    }
                    PoiListView.DataContext = iop.POIs;
                    map.SetOverlaysFitView();
                    PoiListView.SelectedIndex = 0;
                    markerList1[0].OpenTip();
                    PoiListView.Visibility = Visible;
                }
                else
                {
                    MessageDialog msd = new MessageDialog(iop.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                    Debug.WriteLine(iop.Erro.Message);
                }
            });

            //  POISearchResult poiResult = POISearch.PoiSearchByRegionAndKeyword("酒店",lnglats,"Polygon",10);
        }
コード例 #2
0
        async void CenterlnglatAroundPOISearch(string searchName, string cityCode, double x, double y, int range, int number)
        {
            DateTime        st = DateTime.Now;
            POISearchOption p  = new POISearchOption();

            p.CityCode = cityCode;
            //  p.SrcType = dataTypeInput.SelectedItem;
            p.SrcType    = GetValue;
            p.CenX       = x;
            p.CenY       = y;
            p.Range      = range;
            p.Number     = number;
            p.Sid        = "1002"; //服务编码 默认为1000-关键字查询 1001-根据中心点关键字查询周边兴趣点 1002-根据中心点坐标查询周边兴趣点 1005-以拉框方式查询图形区域内的关键字信息.
            p.SearchName = searchName;


            POISearchResult iop = await POISearch.PoiSearchWithOption(p);

            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                if (iop.Erro == null)
                {
                    TimeSpan elapsedSpan = new TimeSpan(DateTime.Now.Ticks - st.Ticks);
                    int i = 0;
                    SearchTextGrid.Visibility = Visibility.Collapsed;
                    Debug.WriteLine(iop);

                    PoiListView.DataContext = iop.POIs;
                    foreach (POI poi in iop.POIs)
                    {
                        i++;
                        poi.Name                      = "  " + i + "、" + poi.Name;
                        ALngLat lnglat                = new ALngLat(poi.X, poi.Y);
                        AMarker poiMarker             = new AMarker();
                        poiMarker.LngLat              = lnglat;
                        ATip tip                      = new ATip();
                        tip.Title                     = poi.Name;
                        tip.ContentText               = poi.Address;
                        poiMarker.TipFrameworkElement = tip;
                        markerList1.Add(poiMarker);
                        map.Children.Add(poiMarker);
                    }
                    map.SetOverlaysFitView();
                    PoiListView.SelectedIndex = 0;
                    markerList1[0].OpenTip();
                    PoiListView.Visibility = Visible;
                }
                else
                {
                    MessageDialog msd = new MessageDialog(iop.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                    Debug.WriteLine(iop.Erro.Message);
                }
            });
        }
コード例 #3
0
        async void POISearchTest(string searchName, string cityCode, string srcType, int num)
        {
            DateTime st = DateTime.Now;
            //Debug.WriteLine(DateTime.Now.Ticks);
            POISearchOption p = new POISearchOption();

            p.SearchName = searchName;
            p.CityCode   = cityCode;
            p.SrcType    = srcType;
            p.Number     = num;
            //  p.Number = dataNumber.Value;
            POISearchResult iop = await POISearch.PoiSearchWithOption(p);

            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                if (iop.Erro == null)
                {
                    // POISearchResult iop = await POISearch.PoiSearchByRegionAndKeyword("中关村", "116.204,39.9938;116.456,39.8833", "rectangle", 10);
                    TimeSpan elapsedSpan = new TimeSpan(DateTime.Now.Ticks - st.Ticks);
                    int i = 0;
                    SearchTextGrid.Visibility = Visibility.Collapsed;
                    foreach (POI poi in iop.POIs)
                    {
                        i++;
                        poi.Name                      = "  " + i + "、" + poi.Name;
                        ALngLat lnglat                = new ALngLat(poi.X, poi.Y);
                        AMarker poiMarker             = new AMarker();
                        poiMarker.LngLat              = lnglat;
                        ATip tip                      = new ATip();
                        tip.Title                     = poi.Name;
                        tip.ContentText               = poi.Address;
                        poiMarker.TipFrameworkElement = tip;
                        markerList.Add(poiMarker);
                        map.Children.Add(poiMarker);
                    }
                    PoiListView.ItemsSource = iop.POIs;

                    map.SetOverlaysFitView();
                    PoiListView.SelectedIndex = 0;
                    markerList[0].OpenTip();
                    PoiListView.Visibility = Visible;
                }
                else
                {
                    MessageDialog msd = new MessageDialog(iop.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                    Debug.WriteLine(iop.Erro.Message);
                }
            });
        }
コード例 #4
0
        private async void DriveRouteSearchTest(string cityCode, string searchName, string searchEndName)
        {
            POISearchOption pst = new POISearchOption();

            pst.SearchName = searchName;
            pst.CityCode   = cityCode;
            POISearchOption ped = new POISearchOption();

            ped.SearchName = searchEndName;
            ped.CityCode   = cityCode;

            POISearchResult iopStart = await POISearch.PoiSearchWithOption(pst); //查起点坐标

            POISearchResult iopEnd = await POISearch.PoiSearchWithOption(ped);   //查终点坐标

            if (iopStart.Erro != null || iopStart.POIs == null)
            {
                MessageDialog msd = new MessageDialog(iopStart.Erro.Message);
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    msd.ShowAsync();
                });
                return;
            }
            if (iopEnd.Erro != null || iopEnd.POIs == null)
            {
                MessageDialog msd = new MessageDialog(iopStart.Erro.Message);
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    msd.ShowAsync();
                });
                return;
            }
            POI poist = Enumerable.First <POI>(iopStart.POIs);
            POI poied = Enumerable.First <POI>(iopEnd.POIs);


            RouteSearchOption rgo = new RouteSearchOption();

            rgo.X1 = poist.X;
            rgo.Y1 = poist.Y;
            rgo.X2 = poied.X;
            rgo.Y2 = poied.Y;
            RouteSearchResult rgcs = await RouteSearch.RouteSearchWithOption(rgo);

            if (rgcs.Erro != null)
            {
                MessageDialog msd = new MessageDialog("查询公交失败!" + rgcs.Erro.Message, "提示");
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    msd.ShowAsync();
                });
                return;
            }
            else
            {
                this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    ALngLat lnglatst                = new ALngLat(poist.X, poist.Y);
                    AMarker poiMarkerst             = new AMarker();
                    poiMarkerst.IconURI             = new Uri("/Samples/qd.png", UriKind.Relative);
                    poiMarkerst.LngLat              = lnglatst;
                    ATip tipst                      = new ATip();
                    tipst.Title                     = poist.Name;
                    tipst.ContentText               = poist.Address;
                    poiMarkerst.TipFrameworkElement = tipst;
                    map.Children.Add(poiMarkerst);


                    ALngLat lnglated                = new ALngLat(poied.X, poied.Y);
                    AMarker poiMarkered             = new AMarker();
                    poiMarkered.IconURI             = new Uri("/Samples/zd.png", UriKind.Relative);
                    poiMarkered.LngLat              = lnglated;
                    ATip tiped                      = new ATip();
                    tiped.Title                     = poied.Name;
                    tiped.ContentText               = poied.Address;
                    poiMarkered.TipFrameworkElement = tiped;
                    map.Children.Add(poiMarkered);

                    APolyline pol     = new APolyline();
                    pol.LineThickness = 5;
                    ObservableCollection <ALngLat> lnglatRoute = new ObservableCollection <ALngLat>(); //线路坐标

                    IEnumerable <String> lnglatstring;
                    IEnumerable <RouteSegment> rsegment = rgcs.Segment;
                    foreach (RouteSegment rs in rsegment)
                    {
                        lnglatstring = rs.Coor.Split(new Char[] { ';' });
                        foreach (String ss in lnglatstring)
                        {
                            String[] lnglatds = ss.Split(new Char[] { ',' });
                            lnglatRoute.Add(new ALngLat(Double.Parse(lnglatds[0]), Double.Parse(lnglatds[1])));
                        }
                    }
                    pol.LngLats = lnglatRoute;
                    markLayer.Children.Add(pol);
                    map.SetOverlaysFitView();
                });
            }
        }
コード例 #5
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>


        private async void BusRouteSearchClick(object sender, RoutedEventArgs e)
        {
            String          startPosition = startInput.Text;
            POISearchOption p             = new POISearchOption();

            p.SearchName = startInput.Text;
            p.CityCode   = cityInput.Text;
            POISearchResult iopStart = await POISearch.PoiSearchWithOption(p);

            Double Startx = new double();
            Double Endx   = new double();
            Double Starty = new double();
            Double Endy   = new double();

            ALngLat lnglatStart;

            if (iopStart.Erro == null)
            {
                foreach (POI poi in iopStart.POIs)
                {
                    poi.Name = poi.Name;
                    Startx   = poi.X;
                    Starty   = poi.Y;
                    ALngLat lnglat    = new ALngLat(poi.X, poi.Y);
                    AMarker poiMarker = new AMarker();
                    poiMarker.LngLat = lnglat;
                    ATip tip = new ATip();
                    tip.Title       = poi.Name;
                    tip.ContentText = poi.Address;
                    poiMarker.TipFrameworkElement = tip;
                    map.Children.Add(poiMarker);
                    break;
                }
            }
            else
            {
                MessageDialog msd = new MessageDialog("起点输入有误,请重新输入!", "提示");
                msd.ShowAsync();
            }

            String endPosition = endInput.Text;

            p.SearchName = endInput.Text;
            p.CityCode   = cityInput.Text;
            POISearchResult iopEnd = await POISearch.PoiSearchWithOption(p);

            if (iopEnd.Erro == null)
            {
                foreach (POI poi in iopEnd.POIs)
                {
                    poi.Name = poi.Name;
                    Endx     = poi.X;
                    Endy     = poi.Y;
                    ALngLat lnglat    = new ALngLat(poi.X, poi.Y);
                    AMarker poiMarker = new AMarker();
                    poiMarker.LngLat = lnglat;
                    ATip tip = new ATip();
                    tip.Title       = poi.Name;
                    tip.ContentText = poi.Address;
                    poiMarker.TipFrameworkElement = tip;
                    map.Children.Add(poiMarker);
                    break;
                }
            }
            else
            {
                MessageDialog msd = new MessageDialog("终点输入有误,请重新输入!", "提示");
                msd.ShowAsync();
            }

            BusRouteSearchOption rgo = new BusRouteSearchOption();

            rgo.X1       = Startx;
            rgo.Y1       = Starty;
            rgo.X2       = Endx;
            rgo.Y2       = Endy;
            rgo.CityCode = "010";

            BusRouteSearchResult rgcs = await BusRouteSearch.BusRouteSearchWithOption(rgo);

            if (rgcs.Erro == null)
            {
                Debug.WriteLine(rgcs);
            }
            else
            {
                Debug.WriteLine(rgcs.Erro.Message);
            }
        }
コード例 #6
0
        private async void BusRouteSearchTest(string cityCode, string searchName, string searchEndName)
        {
            POISearchOption ps = new POISearchOption();

            ps.SearchName = searchName;
            ps.CityCode   = cityCode;

            POISearchOption pe = new POISearchOption();

            pe.SearchName = searchEndName;
            pe.CityCode   = cityCode;

            POISearchResult iopStart = await POISearch.PoiSearchWithOption(ps); //查询起点坐标

            POISearchResult iopEnd = await POISearch.PoiSearchWithOption(pe);   //查询终点坐标

            if (iopEnd.Erro != null || iopEnd.POIs == null)
            {
                MessageDialog msd = new MessageDialog(iopStart.Erro.Message);
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    msd.ShowAsync();
                });
                return;
            }

            POI poist = Enumerable.First <POI>(iopStart.POIs);
            POI poied = Enumerable.First <POI>(iopEnd.POIs);
            BusRouteSearchOption rgo = new BusRouteSearchOption();

            rgo.X1       = poist.X;
            rgo.Y1       = poist.Y;
            rgo.X2       = poied.X;
            rgo.Y2       = poied.Y;
            rgo.CityCode = cityCode;
            BusRouteSearchResult rgcs = await BusRouteSearch.BusRouteSearchWithOption(rgo);//根据起点重点坐标查公交

            if (rgcs.Erro != null)
            {
                MessageDialog msd = new MessageDialog("查询公交失败!" + rgcs.Erro.Message, "提示");
                this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                {
                    msd.ShowAsync();
                });
                return;
            }
            else
            {
                this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
                {
                    markLayer.Children.Clear();
                    ALngLat lnglat                = new ALngLat(poist.X, poist.Y);
                    AMarker poiMarker             = new AMarker();
                    poiMarker.IconURI             = new Uri("/Samples/qd.png", UriKind.Relative);
                    poiMarker.LngLat              = lnglat;
                    ATip tip                      = new ATip();
                    tip.Title                     = poist.Name;
                    tip.ContentText               = poist.Address;
                    poiMarker.TipFrameworkElement = tip;
                    markLayer.Children.Add(poiMarker);

                    ALngLat lnglated                = new ALngLat(poied.X, poied.Y);
                    AMarker poiMarkered             = new AMarker();
                    poiMarkered.IconURI             = new Uri("/Samples/zd.png", UriKind.Relative);
                    poiMarkered.LngLat              = lnglated;
                    ATip tiped                      = new ATip();
                    tiped.Title                     = poied.Name;
                    tiped.ContentText               = poied.Address;
                    poiMarkered.TipFrameworkElement = tiped;
                    markLayer.Children.Add(poiMarkered);


                    ObservableCollection <ALngLat> lnglatRoute = new ObservableCollection <ALngLat>(); //线路坐标
                    APolyline pol     = new APolyline();
                    pol.LineThickness = 5;

                    IEnumerable <Bus> busInfo = rgcs.Routes;
                    IEnumerable <String> lnglatstring;
                    IEnumerable <String> passdeportstring;
                    //画公交线路和公交站点
                    foreach (Bus bus in busInfo)
                    {
                        IEnumerable <BusSegment> bussegmentInfo = bus.SegmentArray;
                        foreach (BusSegment bs in bussegmentInfo)
                        {
                            lnglatstring      = bs.CoordinateList.Split(new Char[] { ';' });
                            passdeportstring  = bs.PassDeportCoordinate.Split(new Char[] { ';' });
                            String[] passport = bs.PassDeportName.Split(' ');
                            int i             = 0;
                            foreach (String ss in lnglatstring)
                            {
                                String[] lnglatds = ss.Split(new Char[] { ',' });
                                lnglatRoute.Add(new ALngLat(Double.Parse(lnglatds[0]), Double.Parse(lnglatds[1])));
                            }

                            foreach (String ss in passdeportstring)
                            {
                                String[] lnglatds        = ss.Split(new Char[] { ',' });
                                ALngLat lnglatpassdeport = new ALngLat(Double.Parse(lnglatds[0]), Double.Parse(lnglatds[1]));
                                ATip tipStart            = new ATip();
                                // tipStart.Anchor = new Point(0,1);
                                tipStart.Title             = passport[i];
                                AMarker marker             = new AMarker();
                                marker.Anchor              = new Point(0.46, 1);
                                marker.IconURI             = new Uri("http://api.amap.com/webapi/static/Images/bx11.png");
                                marker.LngLat              = lnglatpassdeport;
                                marker.TipFrameworkElement = tipStart;
                                markLayer.Children.Add(marker);
                                //  Canvas.SetTop(marker,100);
                                marker.TipAnchor = new Point(0.35, 1);
                            }
                        }
                        break;
                    }


                    pol.LngLats = lnglatRoute;
                    markLayer.Children.Insert(0, pol);

                    map.SetOverlaysFitView();
                });
            }
        }