Beispiel #1
0
        private void MGetPositionFAB_Click(object sender, EventArgs e)
        {
            if (mMyPositon != null)
            {
                mMyPositon.Remove();
            }
            // create class object
            mGps = new GPSTracker(this);

            // check if GPS enabled
            if (mGps.CanGetLocation())
            {
                double latitude  = mGps.GetLatitude();
                double longitude = mGps.GetLongitude();
                UpdateCameraPosition(new LatLng(latitude, longitude), 20);
                mMyPositon = mGoogleMap.AddMarker(new MarkerOptions()
                                                  .SetPosition(new LatLng(latitude, longitude))
                                                  .SetTitle("Аз")
                                                  .SetIcon(BitmapDescriptorFactory.FromResource(Resource.Drawable.ic_location)));
            }
            else
            {
                // can't get location because GPS or Network is not enabled
                // Ask user to enable GPS/network in settings
                mGps.ShowSettingsAlert();
            }
        }
Beispiel #2
0
        //--------------------------------------------------------------------------------------------------------------------------------
        //UI set up
        private void MGetPositionFAB_Click(object sender, EventArgs e)
        {
            // create class object
            mGps = new GPSTracker(this);

            // check if GPS enabled
            if (mGps.CanGetLocation())
            {
                double latitude  = mGps.GetLatitude();
                double longitude = mGps.GetLongitude();

                mMyLocation = new LatLng(latitude, longitude);

                string result = LatLngToString(latitude, longitude);

                mCurrentPostionString = result;

                Toast.MakeText(this, Constants.strDone, ToastLength.Long).Show();
            }
            else
            {
                // can't get location because GPS or Network is not enabled
                // Ask user to enable GPS/network in settings
                mGps.ShowSettingsAlert();
            }
        }