/// <summary> /// Button event to get current location /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void ButtonGetLocationClicked(object sender, EventArgs e) { try { /// <summary> /// Gets the details of the location. /// </summary> /// <param name="Latitude">The current latitude [-90.0 ~ 90.0] (degrees).</param> /// <param name="Longitude">The current longitude [-180.0 ~ 180.0] (degrees).</param> /// <param name="Altitude">The current altitude (meters).</param> /// <param name="Speed">The device speed (km/h).</param> /// <param name="Direction">The direction and degrees from the north.</param> /// <param name="Accuracy">The accuracy.</param> /// <param name="Timestamp">The time value when the measurement was done.</param> Tizen.Location.Location l = locator.GetLocation(); textMessage.Text = "[GetLocation]" + "\n Timestamp : " + l.Timestamp + "\n Latitude : " + l.Latitude + "\n Longitude : " + l.Longitude; } catch (Exception ex) { /// Exception when location service is not available textMessage.Text = "[GetLocation]" + "\n Exception : " + ex.Message; } }
/// <summary> /// New page /// </summary> public PageGetLocation() { /// Text message to indicate current status textMessage.TextColor = Color.White; textMessage.Text = "[GetLocation]"; /// Content view of this page Content = new StackLayout() { VerticalOptions = LayoutOptions.Center, Children = { textMessage, } }; try { /// Gets the details of the location. Tizen.Location.Location l = locator.GetLocation(); /// Status message about current location textMessage.TextColor = Color.YellowGreen; textMessage.Text = "[GetLocation] Success\nlatitude : " + l.Latitude + "\nlongitude : " + l.Longitude; } catch (InvalidOperationException) { /// Exception handling textMessage.Text = "[GetLocation]\nService temporarily unavailable.\nPlease retry after service enabled"; } catch (Exception ex) { /// Exception handling textMessage.Text = "[GetLocation] Exception \n" + ex.Message; } }