void aMapGeolocator_PositionChanged(AMapGeolocator sender, AMapPositionChangedEventArgs args)
        {
            trackingIcon.Location = args.LngLat;

            amapcircle.Center = args.LngLat;
            amapcircle.Radius = (float)args.Accuracy;
        }
Esempio n. 2
0
        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);
            });
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            object temp_nearbyStat;
            object temp_args;

            if (m_myService.State.ContainsKey("nearbyStats"))
            {
                if (m_myService.State.TryGetValue("nearbyStats", out temp_nearbyStat))
                {
                    m_nearbyStats = (ObservableCollection<Station>)temp_nearbyStat;
                }
            }

            if (m_myService.State.ContainsKey("args"))
            {
                if (m_myService.State.TryGetValue("args", out temp_args))
                {
                    m_args = (AMapPositionChangedEventArgs)temp_args;
                }
            }

            base.OnNavigatedTo(e);
        }
Esempio n. 5
0
        /// <summary>
        ///     用户位置改变后marker绘制函数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void mylocation_PositionChanged(AMapGeolocator sender, AMapPositionChangedEventArgs args)
        {
            _latlng = args.LngLat;//系统定位经纬度


            _amap.Dispatcher.BeginInvoke(() =>
            {
                //GeoSearch(args.LngLat);

                if (_locationMarker == null)
                {
                    //添加圆
                    _circle = _amap.AddCircle(new AMapCircleOptions
                    {
                        Center = args.LngLat, //圆点位置
                        Radius = (float)20, //半径
                        FillColor = Color.FromArgb(80, 100, 150, 255),//圆的填充颜色
                        StrokeWidth = 1, //边框粗细
                        StrokeColor = Color.FromArgb(80, 100, 150, 255) //圆的边框颜色
                    });


                    //添加点标注,用于标注地图上的点
                    _locationMarker = _amap.AddMarker(new AMapMarkerOptions
                    {
                        Position = args.LngLat, //图标的位置
                        //待修改,更换IconUri的图标//
                        IconUri = new Uri("Images/myLocationIcon.png", UriKind.RelativeOrAbsolute), //图标的URL
                        Anchor = new Point(0.5, 0.5) //图标中心点
                    });
                }
                else
                {
                    //点标注和圆的位置在当前经纬度
                    _locationMarker.Position = args.LngLat;
                    _circle.Center = args.LngLat;
                    _circle.Radius = (float)20; //圆半径
                }

                //设置当前地图的经纬度和缩放级别
                if (_cameraIsNew)
                {
                    if (_mapZoom == 0)
                    _mapZoom = 17;
                    _amap.AnimateCamera(CameraUpdateFactory.NewCameraPosition(_latlng, _mapZoom, _bearing, _tile), 2);//移动视角(动画效果)
                    _cameraIsNew = false;
                    
                }

                Debug.WriteLine("定位精度:" + args.Accuracy + "米");
                Debug.WriteLine("定位经纬度:" + args.LngLat);

            });

            AMapReGeoCodeResult currentLocationResult;//用户实时位置AMapReGeoCodeResult
            currentLocationResult = await AMapReGeoCodeSearch.GeoCodeToAddress(_latlng.longitude, _latlng.latitude, 50, "", Extensions.All);
            Dispatcher.BeginInvoke(() =>
            {
                if (currentLocationResult.Erro == null && currentLocationResult.ReGeoCode != null)
                {
                    AMapReGeoCode regeocode = currentLocationResult.ReGeoCode;
                    MakerTextBlock.Text = regeocode.Formatted_address;
                    Debug.WriteLine("道路信息");
                    foreach (var temp in regeocode.Roadslist)
                    {
                        Debug.WriteLine(temp.Id);
                        
                        _client.SendLocation(temp.Id,temp.Name, args.LngLat.latitude.ToString(CultureInfo.InvariantCulture), args.LngLat.longitude.ToString(CultureInfo.InvariantCulture));
                        break;
                    }

                }
            }
                );
        }
Esempio n. 6
0
        private async void mylocation_PositionChanged(AMapGeolocator sender, AMapPositionChangedEventArgs args)
        {
            m_location = args.LngLat;
            m_args = args;
            Debug.WriteLine("定位精度:" + args.Accuracy + "米");
            Debug.WriteLine("定位经纬度:" + args.LngLat);
            flashNearbyStat();

            //if (!m_bIsCheckedCity)
            {
                Debug.WriteLine("开始检查城市");
                await CheckCity(args.LngLat.longitude, args.LngLat.latitude);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 定位位置变化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        void geo_PositionChanged(AMapGeolocator sender, AMapPositionChangedEventArgs args)
        {
            this.Dispatcher.BeginInvoke(() =>
            {
                try
                {
                    if (myLoaction == null)
                    {
                        myLoaction = new MMarker() { LngLat = new Com.AMap.Maps.Api.BaseTypes.MLngLat(args.LngLat.longitude, args.LngLat.latitude), IconURL = "/Images/location_on.png" };

                    }
                    if (!mapLocationLayer.Children.Contains(myLoaction))
                    {
                        mapLocationLayer.Children.Add(myLoaction);
                    }
                    else
                    {
                        myLoaction.LngLat = new Com.AMap.Maps.Api.BaseTypes.MLngLat(args.LngLat.longitude, args.LngLat.latitude);
                    }
                    map.Center = new Com.AMap.Maps.Api.BaseTypes.MLngLat(args.LngLat.longitude, args.LngLat.latitude);
                   
                    SearchKeyWordToilet(myLoaction.LngLat, 1000);//搜索,默认半径1000m
               
                    geo.PositionChanged -= geo_PositionChanged;
                    geo.Stop();
                    geo = null;
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("geo_PositionChanged:" + ex.Message);
                }
            });


        }