private void Button_DrawCircle_Click(object sender, RoutedEventArgs e)
 {
     circle = amap.AddCircle(new AMapCircleOptions()
     {
         Center = amap.Center,
         Radius = 2000,
     });
     this.btnVisible.IsEnabled = true;
 }
Example #2
0
        private void DrawCircle()
        {
            CircleOptions circleOptions = new CircleOptions();

            circleOptions.InvokeCenter(new LatLng(30.679879, 104.064855));
            circleOptions.InvokeRadius(9000);
            circleOptions.InvokeStrokeColor(Color.Black);
            circleOptions.InvokeFillColor(Color.Transparent);
            circleOptions.InvokeStrokeWidth(3);
            aMap.AddCircle(circleOptions);
        }
 private void Button_DrawCircle_Click(object sender, RoutedEventArgs e)
 {
     //绘圆
     circle = amap.AddCircle(new AMapCircleOptions()
     {
         Center      = amap.Center, //圆点位置
         Radius      = 1000,        //半径
         FillColor   = Color.FromArgb(70, 100, 150, 255),
         StrokeWidth = 3,
         StrokeColor = Color.FromArgb(255, 0, 0, 255)
     });
 }
        void mylocation_PositionChanged(AMapGeolocator sender, AMapPositionChangedEventArgs args)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                if (marker == null)
                {
                    //添加圆
                    circle = amap.AddCircle(new AMapCircleOptions()
                    {
                        Center      = args.LngLat,                   //圆点位置
                        Radius      = (float)args.Accuracy,          //半径
                        FillColor   = Color.FromArgb(80, 100, 150, 255),
                        StrokeWidth = 2,                             //边框粗细
                        StrokeColor = Color.FromArgb(80, 0, 0, 255), //边框颜色
                    });

                    //添加点标注,用于标注地图上的点
                    marker = amap.AddMarker(
                        new AMapMarkerOptions()
                    {
                        Position = args.LngLat,                                                   //图标的位置
                        Title    = "我的位置",
                        IconUri  = new Uri("Images/marker_gps_no_sharing.png", UriKind.Relative), //图标的URL
                        Anchor   = new Point(0.5, 0.5),                                           //图标中心点
                    });
                }
                else
                {
                    //点标注和圆的位置在当前经纬度
                    marker.Position = args.LngLat;
                    circle.Center   = args.LngLat;
                    circle.Radius   = (float)args.Accuracy;//圆半径
                }

                //设置当前地图的经纬度和缩放级别
                amap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(args.LngLat, 15));
                Debug.WriteLine("定位精度:" + args.Accuracy + "米");
                Debug.WriteLine("定位经纬度:" + args.LngLat);
            });
        }
        /// <summary>
        ///     监听位置变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnPositionChanged(AMapGeolocator sender, AMapPositionChangedEventArgs args)
        {
            Debug.WriteLine("OnPositionChanged");

            Dispatcher.BeginInvoke(() =>
            {
                if (currentLocationMarker == null)
                {
                    //添加定位精度圈,为覆盖物中的圆
                    currentLocationCircle = map.AddCircle(new AMapCircleOptions
                    {
                        Center      = args.LngLat,                  //圆点位置
                        Radius      = (float)args.Accuracy,         //半径
                        FillColor   = Color.FromArgb(80, 100, 150, 255),
                        StrokeWidth = 2,                            //边框粗细
                        StrokeColor = Color.FromArgb(80, 0, 0, 255) //边框颜色
                    });

                    currentLocationMarker = map.AddMarker(new AMapMarkerOptions
                    {
                        Position = args.LngLat,                                              //图标的位置
                        Title    = "我的位置",
                        IconUri  = new Uri("Images/current_location.png", UriKind.Relative), //图标的URL
                        //Anchor = new Point(0.5, 0.5) //图标中心点
                    });
                }
                else
                {
                    //更新当前位置
                    currentLocationMarker.Position = args.LngLat;
                    currentLocationCircle.Center   = args.LngLat;
                    currentLocationCircle.Radius   = (float)args.Accuracy;
                }
                //设置当前地图的经纬度和缩放级别
                map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(args.LngLat, 15));
                Debug.WriteLine("定位精度:{0}米", args.Accuracy);
                Debug.WriteLine("定位经纬度:{0}", args.LngLat);
            });
        }