public String NiceCoordToString(LatLng location) { String sLat2 = GCStuffs.ConvertDegreesToDDMM(location.Latitude, true); String sLon2 = GCStuffs.ConvertDegreesToDDMM(location.Longitude, false); return /*"DD° MM.MMM: " + */ (sLat2 + " " + sLon2); }
// Result of an activity, back to work! protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (resultCode == Result.Ok) { if (requestCode == 10) // Map { IList <String> p = null; if (data != null) { p = data.Extras.GetStringArrayList("coordinates") ?? new string[0]; } // Check validity of parameter if ((p != null) && (p.Count == 2)) { // List is valid, populate login & password String sLat2 = GCStuffs.ConvertDegreesToDDMM(GCStuffs.ConvertToDouble(p[0]), true); String sLon2 = GCStuffs.ConvertDegreesToDDMM(GCStuffs.ConvertToDouble(p[1]), false); txtCoord.Text = /*"DD° MM.MMM: " + */ sLat2 + " " + sLon2; Toast.MakeText(this, this.Resources.GetString(Resource.String.PickDone), ToastLength.Short).Show(); } } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "MapLayout" layout resource SetContentView(Resource.Layout.MapLayout); // Get params IList <String> p = null; if (Intent.Extras != null) { p = Intent.Extras.GetStringArrayList("coordinates") ?? new string[0]; } // Check validity of parameter if (p != null) { if (p.Count >= 2) { // List is valid, populate login & password lat = p[0]; lon = p[1]; } if (p.Count >= 3) { if (!Int32.TryParse(p[2], out radius)) { radius = 0; } } } if ((lat != "") && (lon != "")) { // Textview to diplay coordinates TextView lblCoord = FindViewById <TextView>(Resource.Id.lblCoord); String sLat2 = GCStuffs.ConvertDegreesToDDMM(GCStuffs.ConvertToDouble(lat), true); String sLon2 = GCStuffs.ConvertDegreesToDDMM(GCStuffs.ConvertToDouble(lon), false); lblCoord.Text = /*"DD° MM.MMM: " + */ sLat2 + " " + sLon2; } // Create your application here var frag = FragmentManager.FindFragmentById <MapFragment>(Resource.Id.map); frag.GetMapAsync(this); Button button = FindViewById <Button>(Resource.Id.Save); button.Click += Save_Click; button = FindViewById <Button>(Resource.Id.BtnQuit); button.Click += Cancel_Click; }
// The System will call OnLocationChanged when the user's location changes enough to qualify as a location change according to the Criteria we set when requesting location updates. public void OnLocationChanged(Android.Locations.Location location) { //base.OnLocationChanged(location) // STORE VALUES and link it to GPS button !!! String sLat2 = GCStuffs.ConvertDegreesToDDMM(location.Latitude, true); String sLon2 = GCStuffs.ConvertDegreesToDDMM(location.Longitude, false); lastGPSCoords = /*"DD° MM.MMM: " + */ sLat2 + " " + sLon2; Toast.MakeText(this, this.Resources.GetString(Resource.String.GPSFix), ToastLength.Short).Show(); // If no location filled, we put it, better than nothing if (txtCoord.Text == "") { txtCoord.Text = lastGPSCoords; } }