Getting the GPS location

Getting and monitoring the GPS location for each platform is a common capability. Every smartphone in the market right now has a GPS sensor built in, but each OS has its own native APIs to retrieve the position.

The good news is that you don't have to create a plugin as there is one already created by James Montemagno from Xamarin that you can freely use.

How to do it…

  1. Create a Blank App (Xamarin.Forms Portable) cross-platform mobile solution named XamFormsQueryGps in Visual Studio with File | New | Project….
  2. Right-click all the projects one by one and choose Manage NuGet Packages to search and install Xam.Plugin.Geolocator.
  3. Go to the XamFormsQueryGps portable library and open the App.cs file; add the following code to the ...

Get Xamarin: Cross-Platform Mobile Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.