Created
August 7, 2017 14:36
-
-
Save juucustodio/257fa4f92c4a7dfe4bc6f4bf0235acc2 to your computer and use it in GitHub Desktop.
Demo de utilização do GPS - Xamarin.Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Plugin.Geolocator; | |
using System; | |
using Xamarin.Forms; | |
namespace DemoGPS | |
{ | |
public partial class MainPageDemoGPS : ContentPage | |
{ | |
public MainPageDemoGPS() | |
{ | |
InitializeComponent(); | |
} | |
private async void GetPosition(object sender, EventArgs e) | |
{ | |
var locator = CrossGeolocator.Current; | |
locator.DesiredAccuracy = 50; | |
var position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10)); | |
LongitudeLabel.Text = string.Format("{0:0.0000000}", position.Longitude); | |
LatitudeLabel.Text = string.Format("{0:0.0000000}", position.Latitude); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment