Exemplo n.º 1
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.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            AMapPolyline line = new AMapPolyline();

            pointsOfLine     = new[] { new LngLat(116.48236, 39.987326), new LngLat(116.450712, 39.93041) };
            line.Path        = new AGeopath(pointsOfLine);
            line.StrokeColor = Colors.Red;
            baseLayer.Add(line);

            AMapPolygon rectRectangle = new AMapPolygon();

            pointsOfRect       = new[] { new LngLat(116.438764, 39.96041), new LngLat(116.438764, 39.963728), new LngLat(116.453712, 39.963728), new LngLat(116.453712, 39.96041) };
            rectRectangle.Path = new AGeopath(pointsOfRect);

            baseLayer.Add(rectRectangle);
        }
Exemplo n.º 2
0
        private void Button_DrawPolygon_Click(object sender, RoutedEventArgs e)
        {
            //绘多边形
            List <LatLng> lnglats = new List <LatLng>();

            lnglats.Add(new LatLng(amap.Center.latitude + 0.02, amap.Center.longitude + 0.03));
            lnglats.Add(new LatLng(amap.Center.latitude + 0.03, amap.Center.longitude - 0.03));
            lnglats.Add(new LatLng(amap.Center.latitude - 0.026, amap.Center.longitude - 0.03));
            lnglats.Add(amap.Center);
            lnglats.Add(new LatLng(amap.Center.latitude - 0.04, amap.Center.longitude + 0.035));
            polylgon = amap.AddPolygon(new AMapPolygonOptions()
            {
                FillColor   = Color.FromArgb(30, 255, 0, 255),
                Points      = lnglats,
                StrokeColor = Color.FromArgb(255, 102, 136, 255),
                StrokeWidth = 2
            });
        }
        private void Polygon_OnClick(object sender, RoutedEventArgs e)
        {
            double        interval = 0.02;
            List <LngLat> lnglats  = new List <LngLat>();

            lnglats.Add(new LngLat(aMapControl.Center.Longitude - interval, aMapControl.Center.Latitude + interval));
            lnglats.Add(new LngLat(aMapControl.Center.Longitude + interval, aMapControl.Center.Latitude + interval));
            lnglats.Add(new LngLat(aMapControl.Center.Longitude + interval, aMapControl.Center.Latitude - interval));
            lnglats.Add(aMapControl.Center);
            lnglats.Add(new LngLat(aMapControl.Center.Longitude - interval, aMapControl.Center.Latitude - interval));

            polygon = new AMapPolygon
            {
                FillColor       = Colors.Red,
                Path            = new AGeopath(lnglats),
                StrokeColor     = Colors.Blue,
                Joint           = Joint.CLIPPED,
                StrokeThickness = 10
            };

            baseLayer.Add(polygon);
        }
Exemplo n.º 4
0
        private async void PolygonSearch_OnClick(object sender, RoutedEventArgs e)
        {
            baselayer.Clear();
            aMapControl.HideInfoWindow();


            string keywords = "肯德基";
            string types    = "快餐厅";
            uint   offset   = 50;
            string city     = "北京";

            var lngLats = new List <LngLat>
            {
                new LngLat(aMapControl.Center.Longitude + 0.03, aMapControl.Center.Latitude + 0.02),
                new LngLat(aMapControl.Center.Longitude - 0.03, aMapControl.Center.Latitude + 0.03),
                new LngLat(aMapControl.Center.Longitude - 0.03, aMapControl.Center.Latitude - 0.026),
                new LngLat(aMapControl.Center.Longitude + 0.035, aMapControl.Center.Latitude - 0.04),
                new LngLat(aMapControl.Center.Longitude + 0.045, aMapControl.Center.Latitude - 0.046)
            };

            var polygon = new AMapPolygon
            {
                FillColor       = Color.FromArgb(30, 255, 0, 255),
                Path            = new AGeopath(lngLats),
                StrokeColor     = Color.FromArgb(255, 102, 136, 255),
                StrokeThickness = 2
            };

            await baselayer.Add(polygon);


            SearchPolygon searchpolygon = new SearchPolygon();

            icons = new List <AMapIcon>();
            //多边形
            searchpolygon.Points = new List <AMapLocation>
            {
                new AMapLocation()
                {
                    Lon = lngLats[0].Longitude, Lat = lngLats[0].Latitude
                },
                new AMapLocation()
                {
                    Lon = lngLats[1].Longitude, Lat = lngLats[1].Latitude
                },
                new AMapLocation()
                {
                    Lon = lngLats[2].Longitude, Lat = lngLats[2].Latitude
                },
                new AMapLocation()
                {
                    Lon = lngLats[3].Longitude, Lat = lngLats[3].Latitude
                },
                new AMapLocation()
                {
                    Lon = lngLats[4].Longitude, Lat = lngLats[4].Latitude
                }
            };

            AMapPOIResults result = await AMapPOISearch.POIPolygon(keywords, types, searchpolygon, null, 0, offset, 1, Extensions.All, city);

            if (result.Erro == null)
            {
                if (result.POIList == null || result.POIList.Count == 0)
                {
                    Debug.WriteLine("无查询结果");
                    return;
                }
                IEnumerable <AMapPOI> pois = result.POIList;
                foreach (AMapPOI item in pois)
                {
                    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);;
                }

                LngLatBoundingBoxBuilder builder = new LngLatBoundingBoxBuilder(lngLats);


                aMapControl.TrySetViewBoundsAsync(builder.Build(), AMapAnimationKind.Default);
            }
            else
            {
                Debug.WriteLine(result.Erro.Message);
            }
        }