-
Book Overview & Buying
-
Table Of Contents
Xamarin 4.x Cross-Platform Application Development - Third Edition
By :
Using Xamarin.Mobile to track a user's GPS location is as simple as accessing their contacts. There is a similar process for setting up access on iOS and Android, but in the case of location, you don't have to request permission from code. iOS will automatically show the standard alert requesting permission. Android, on the other hand, merely requires a manifest setting.
As an example, let's add functionality to our XamSnap application that tags GPS location to messages within a chat conversation. You can think of this as tagging a location to a photo, as in other apps. Make sure to add Xamarin.Mobile to the project from the Component Store.
First, let's implement a Location class for storing latitude and longitude:
public class Location
{
public double Latitude { get; set; }
public double Longitude { get; set; }
}Next, let's add a Location property to the Message class:
public Location Location { get; set; }Now, let's create a new ILocationService...
Change the font size
Change margin width
Change background colour