Introduction
In this article demonstrates how to access GPS hardware in your device in xamarin.forms application and that we can access our location of latitude and longitude.In this function not available in xamarin.forms.So,we need to install plugin for this.
In this article demonstrates how to access GPS hardware in your device in xamarin.forms application and that we can access our location of latitude and longitude.In this function not available in xamarin.forms.So,we need to install plugin for this.
Nuget package
Xamarin.Forms = search "Xam.Plugin.Geolocator"
Xamarin.Forms = search "Xam.Plugin.Geolocator"
Xam.Plugin.Geolocator
Simple cross platform plugin to get GPS location including heading, speed and more.Additionally, you can track geolocation changes, reverse geocode and more
Simple cross platform plugin to get GPS location including heading, speed and more.Additionally, you can track geolocation changes, reverse geocode and more
Step 1
You can create xamarin.forms app by going to File >> New >> Visual C# >> Cross Platform >> Cross Platform App (Xamarin.Native or Xamarin.Forms), give the application name and click ok.
(Project name : LocationApp)
You can create xamarin.forms app by going to File >> New >> Visual C# >> Cross Platform >> Cross Platform App (Xamarin.Native or Xamarin.Forms), give the application name and click ok.
(Project name : LocationApp)
Step 2
Afterwards, add the following nuget packages for your projects.
Afterwards, add the following nuget packages for your projects.
- Xam.Plugin.Geolocator
For that, open Solution Explorer and select your solution, right click and select "Manage Nuget Packages for the Solution".In the popup window, open "Browse" tab and browse "Xam.Plugin.Geolocator" and select the following nuget packages and select your projects then install it.

Step 3
After installed nuget packges, add button with clicked event and labels to MainPage.Xaml page.For that go to Solution Explorer >> LocationApp(PCL) >>MainPage.xaml and double click to open its design view.Here is the code for this page.

Step 3
After installed nuget packges, add button with clicked event and labels to MainPage.Xaml page.For that go to Solution Explorer >> LocationApp(PCL) >>MainPage.xaml and double click to open its design view.Here is the code for this page.
Used toobox items
- Button - get GPS location with clicked event
- Label - longitude text label
- Label - longitude label
- Label - latitude text label
- Label - latitude label
Xaml code
- <?xml version="1.0" encoding="utf-8" ?>
- <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
- xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
- xmlns:local="clr-namespace:LocationApp"
- x:Class="LocationApp.MainPage">
- <StackLayout Orientation="Vertical">
- <Button Text="Get GPS location"
- Clicked="OnButtonClicked"
- TextColor="Chocolate"
- FontSize="30"/>
- <Label Text="Longitude"
- FontSize="60"
- TextColor="BlueViolet"/>
- <Label x:Name="LogitudeLabel"
- FontSize="20"/>
- <Label Text="Latitude"
- FontSize="60"
- TextColor="DarkRed"/>
- <Label x:Name="LatitudeLabel"
- FontSize="20"/>
- </StackLayout>
- </ContentPage>


Ajithkumar JPosted Jan 14, 2019, 7:49 AM
Copied from https://www.youtube.com/watch?v=cx5O9GfOnS4 :)
KarthikRaja APosted Dec 27, 2018, 3:13 AM
GetPositionAsync() returs null
Uttam PadukonePosted Nov 18, 2018, 8:55 PM
Do you have a way to set up a listener so that geolocation parameters are automatically detected every x seconds - where x can be a value in a parameter?
Abhay BhaleraoPosted Nov 14, 2018, 5:52 AM
A geolocation error occurred unauthorized xamarin
Muhammad NadeemPosted Jun 29, 2018, 6:19 AM
App exits after clicking Button
ashok yadavPosted Mar 23, 2018, 4:12 AM
It is not working for me.
Maksym SoloviovPosted Feb 5, 2018, 3:12 PM
Great tutorial. Thank you!