private async void Walk_OnClick(object sender, RoutedEventArgs e)
        {
            baseLayer.Clear();

            var man =
                RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/man.png",
                                                                  UriKind.RelativeOrAbsolute));

            AMapRouteResults rts =
                await
                AMapNavigationSearch.WalkingNavigation(start.Longitude, start.Latitude, end.Longitude, end.Latitude,
                                                       0);

            if (rts.Erro == null)
            {
                if (rts.Count == 0)
                {
                    Debug.WriteLine("无查询结果");
                    return;
                }

                AMapRoute       route = rts.Route;
                List <AMapPath> paths = route.Paths.ToList();

                foreach (AMapPath item in paths)
                {
                    Debug.WriteLine("起点终点距离:" + item.Distance);
                    Debug.WriteLine("预计耗时:" + item.Duration / 60 + "分钟");
                    Debug.WriteLine("导航策略:" + item.Strategy);

                    //画路线
                    List <AMapStep> steps = item.Steps.ToList();
                    foreach (AMapStep st in steps)
                    {
                        var icon = new AMapIcon
                        {
                            Location = LngLatsFromString(st.Polyline).FirstOrDefault(),
                            Image    = man
                        };


                        Debug.WriteLine(st.Instruction);

                        var polyline = new AMapPolyline {
                            Path = new AGeopath(LngLatsFromString(st.Polyline))
                        };

                        await baseLayer.Add(icon);

                        await baseLayer.Add(polyline);
                    }
                }
            }
            else
            {
                Debug.WriteLine(rts.Erro.Message);
            }
        }
Exemplo n.º 2
0
        private async void IdSearch_OnClick(object sender, RoutedEventArgs e)
        {
            baselayer.Clear();
            aMapControl.HideInfoWindow();

            string id = "B000A07060";


            AMapPOIResults results = await AMapPOISearch.POIID(id);

            if (results.Erro == null)
            {
                if (results.POIList == null || results.POIList.Count == 0)
                {
                    Debug.WriteLine("无查询结果");
                    return;
                }

                foreach (AMapPOI item in results.POIList)
                {
                    var icon = new AMapIcon {
                        Location = new LngLat(item.Location.Lon, item.Location.Lat)
                    };

                    icon.Tapped += icon_Tapped;

                    icon.Data = item.Address;

                    await baselayer.Add(icon);
                }

                aMapControl.TrySetViewAsync(
                    new LngLat(results.POIList[0].Location.Lon, results.POIList[0].Location.Lat), null, null, null,
                    AMapAnimationKind.Default);
            }
            else
            {
                Debug.WriteLine(results.Erro.Message);
            }
        }
Exemplo n.º 3
0
 private async void SearchButton_OnClick(object sender, RoutedEventArgs e)
 {
     baseLayer.Clear();
     await AddressToGeoCode(addressInputTextBox.Text);
 }
 private void ClearAll_Click(object sender, RoutedEventArgs e)
 {
     baseLayer.Clear();
 }
Exemplo n.º 5
0
        private async void LineIdSearch_OnClick(object sender, RoutedEventArgs e)
        {
            baseLayer.Clear();
            string crashid = " 440100014234";

            string id = "110100013752";


            AMapBusLineResults busLines = await AMapBusSearch.BusLineIDSearch(id);

            if (busLines.Erro == null)
            {
                if (busLines.BusLineList == null || busLines.BusLineList.Count == 0)
                {
                    Debug.WriteLine("无查询结果");
                    return;
                }

                List <AMapBusLine> busLine = busLines.BusLineList.ToList();

                //Id 搜索 只会搜索到一个
                AMapBusLine bl = busLine.FirstOrDefault();

                Debug.WriteLine(bl.Name);
                List <LngLat> latlng = LngLatsFromString(bl.Polyline);

                AMapPolyline polyline = new AMapPolyline
                {
                    Path            = new AGeopath(latlng),
                    StrokeColor     = Colors.Blue,
                    StrokeThickness = 10
                };

                AMapIcon start = new AMapIcon
                {
                    Image =
                        RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/bus_start_pic.png",
                                                                          UriKind.RelativeOrAbsolute)),
                    Location = latlng.FirstOrDefault()
                };

                AMapIcon end = new AMapIcon
                {
                    Image =
                        RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/bus_end_pic.png",
                                                                          UriKind.RelativeOrAbsolute)),
                    Location = latlng.LastOrDefault()
                };

                await baseLayer.Add(start);

                await baseLayer.Add(end);

                //todo 纹理已经录入,但是为什么会crash
                await baseLayer.Add(polyline);
            }
            else
            {
                Debug.WriteLine(busLines.Erro.Message);
            }
        }