private async void BusLineSearchTest(string stationName, string cityCode)
        {
            BusLineSearchOption rgo = new BusLineSearchOption();

            rgo.StationName = stationName;
            rgo.CityCode    = cityCode;
            //     服务编码 默认8085-根据线路ID查询Ids不能为空 8004-根据线路名称查询 8086-根据站点名称查询
            rgo.Sid = "8086";

            BusLineSearchResult rgcs = await BusLineSearch.BusLineSearchWithOption(rgo);

            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                //    ObservableCollection<ALngLat> lnglatRoute = new ObservableCollection<ALngLat>();   //线路坐标
                //    IEnumerable<String> lnglatstring;

                if (rgcs.Erro == null)
                {
                    SearchTextGrid.Visibility = Visibility.Collapsed;
                    IEnumerable <BusLine> bs  = rgcs.BusLineList;
                    PoiListView.DataContext   = bs;
                    PoiListView.Visibility    = Visible;
                }
                else
                {
                    MessageDialog msd = new MessageDialog(rgcs.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                    Debug.WriteLine(rgcs.Erro.Message);
                }
            });
        }
        private async void BusLineSearchTest(string busName, string cityCode)
        {
            //BusLineSearchOption rgo = new BusLineSearchOption();
            //rgo.BusName = busName;
            //rgo.CityCode = cityCode;
            //rgo.Sid = "8004";
            //  BusLineSearchResult rgcs = await BusLineSearch.BusLineSearchWithOption(rgo);
            BusLineSearchResult rgcs = await BusLineSearch.BusSearchByBusName(busName, cityCode);

            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                if (rgcs.Erro == null)
                {
                    SearchTextGrid.Visibility = Visibility.Collapsed;
                    IEnumerable <BusLine> bs  = rgcs.BusLineList;
                    PoiListView.DataContext   = bs;
                    PoiListView.Visibility    = Visible;
                }
                else
                {
                    MessageDialog msd = new MessageDialog(rgcs.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                    Debug.WriteLine(rgcs.Erro.Message);
                }
            });
        }
Ejemplo n.º 3
0
        private async void BusLineSearchTest(string ids, string cityCode)
        {
            BusLineSearchOption rgo = new BusLineSearchOption();

            rgo.Ids      = ids;
            rgo.CityCode = cityCode;
            BusLineSearchResult rgcs = await BusLineSearch.BusLineSearchWithOption(rgo);

            this.Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
            {
                IEnumerable <BusLine> bl = rgcs.BusLineList;

                if (rgcs.Erro == null && bl != null)
                {
                    SearchTextGrid.Visibility = Visibility.Collapsed;

                    ObservableCollection <ALngLat> lnglatRoute = new ObservableCollection <ALngLat>(); //线路坐标
                    IEnumerable <String> lnglatstring;
                    foreach (BusLine bs in bl)
                    {
                        IEnumerable <Station> ss = bs.StationList;

                        foreach (Station s in ss)
                        {
                            s.Name = s.StationNum + " " + s.Name;
                        }
                        PoiListView.DataContext = ss;
                        lnglatstring            = bs.XYs.Split(new Char[] { ';' });

                        foreach (String ssss in lnglatstring)
                        {
                            String[] lnglatds = ssss.Split(new Char[] { ',' });
                            lnglatRoute.Add(new ALngLat(Double.Parse(lnglatds[0]), Double.Parse(lnglatds[1])));
                        }
                        int i = 0;
                        foreach (Station st in ss)
                        {
                            i++;
                            String[] lnglatds             = st.XY.Split(new Char[] { ',' });
                            ALngLat markerlnglat          = new ALngLat(Double.Parse(lnglatds[0]), Double.Parse(lnglatds[1]));
                            AMarker poiMarker             = new AMarker();
                            poiMarker.Anchor              = new Point(0.5, 0.5);
                            poiMarker.LngLat              = markerlnglat;
                            ATip tip                      = new ATip();
                            tip.Title                     = st.Name;
                            tip.ContentText               = "站点序号: " + st.StationNum;
                            poiMarker.TipFrameworkElement = tip;
                            markerList.Add(poiMarker);
                        }
                        PoiListView.Visibility = Visible;
                        APolyline pol          = new APolyline();
                        pol.LineThickness      = 5;
                        pol.LngLats            = lnglatRoute;
                        markLayer.Children.Add(pol);
                        markLayer.SetOverlaysFitView();
                        try
                        {
                            PoiListView.SelectedIndex = 0;
                        }
                        catch
                        {
                        }
                    }
                }
                else
                {
                    MessageDialog msd = new MessageDialog(rgcs.Erro.Message);
                    this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
                    {
                        msd.ShowAsync();
                    });
                    Debug.WriteLine(rgcs.Erro.Message);
                }
            });
        }