/// <summary>
        /// Called when the location has changed.
        /// </summary>
        /// <param name="location">The new location, as a Location object.</param>
        public void OnLocationChanged(global::Android.Locations.Location l)
        {
            _location = new GPSLocation(l);
            if (_location != null)
            {
                _valid = true;
                // Check if the new location has bearing info
                if (_location.HasBearing)
                {
                    _lastGPSAzimuth = _location.Bearing;
                    SendOrientation(_lastPitch, _lastRoll);
                }
            }
            else
            {
                _valid            = false;
                _location.IsValid = false;
            }

            if (LocationChanged != null)
            {
                LocationChanged(this, new LocationChangedEventArgs(_location));
            }
            // If Google Maps is active, than send new location
            if (mapsListener != null)
            {
                mapsListener.OnLocationChanged(l);
            }
        }
Exemplo n.º 2
0
 public void OnMapClick(LatLng latLng)
 {
     if (locationChangedListener != null && !mPaused)
     {
         locationChangedListener.OnLocationChanged(GetLocation(latLng));
         Toast.MakeText(context, "Latitude =" + latLng.Latitude.ToString() + " Longitude=" + latLng.Longitude.ToString(),
                        ToastLength.Long).Show();
     }
 }
Exemplo n.º 3
0
 public void OnLocationChanged(AMapLocation aLocation)
 {
     if (mListener != null && aLocation != null)
     {
         if (aLocation.AMapException.ErrorCode == 0) //防止定位失败后,获得(0,0)坐标,跑到海里!!!!
         {
             //aLocation 包含获得的实时坐标值,可在业务逻辑中,加以利用。
             mListener.OnLocationChanged(aLocation);// 显示系统小蓝点
             if (isFirst)
             {
                 mapView.Map.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(aLocation.Latitude, aLocation.Longitude), 14));
                 isFirst = false;
             }
         }
     }
 }
Exemplo n.º 4
0
        public void OnLocationChanged(AMapLocation aLocation)
        {
            if (mListener != null && aLocation != null)
            {
                mAMapLocationManager.StartSocket();
                if (aLocation.AMapException.ErrorCode == 0) //防止定位失败后,获得(0,0)坐标,跑到海里!!!!
                {
                    mListener.OnLocationChanged(aLocation); // 显示系统小蓝点

                    if (isFirst)
                    {
                        aMap.MoveCamera(CameraUpdateFactory.NewLatLngZoom(new LatLng(aLocation.Latitude, aLocation.Longitude), 14));
                        isFirst = false;
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void OnLocationChanged(Location location)
        {
            if (mMapLocationListener != null)
            {
                mMapLocationListener.OnLocationChanged(location);
            }


            var newLocation = location;

            // Not accurate enought
            if (newLocation.Accuracy >= 1000)
            {
                return;
            }

            /*
             * If we dont have a position or there is 200 meters from the last location we update the camera
             * and the markers
             */
            if (_currentLocation == null || _currentLocation.DistanceTo(newLocation) >= 200)
            {
                _currentLocation = location;

                /*
                 * IF GPS was disabld initaly.
                 */
                if (_GPSSnackbar != null)
                {
                    _GPSSnackbar.Dismiss();
                    _GPSSnackbar = null;
                }

                PositionCamera(location);
                GetNearestStops();
            }

            _currentLocation = location;
        }