Get device coordinates in Xamarin forms

3267
2
Jump to solution
10-31-2017 05:40 PM
MarkCollins
Occasional Contributor

I am using the runtime in Xamarin forms and wanted to know if there is any way to easily get the current device location with out actually creating a map view?   I am familiar with using the LocationDisplay class (arcgis-runtime-samples-dotnet/src/Forms/Shared/Samples/Location/DisplayDeviceLocation at master · Es... ) to show the users location on the map but I would like to just get the coordinates without displaying the map. 

When the user presses a button on my form I would like to get the x/y for the users current location and save it to my database. I do not need to actually display a map at the time the user is clicking the button. I know its possible to use a xamarin plugin such as this:NuGet Gallery | Xam.Plugin.Geolocator 4.1.2   but I would really like to avoid adding another nuget package to my project since the the ArcGIS runtime is obviously capable of getting the device coordinates to display on the map. 

Thanks,

Mark

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RichZwaap
Occasional Contributor III

Hi Mark,

You should be able to use the SystemLocationDataSource class.  Just instantiate it, call StartAsync, and subscribe to the LocationChanged event to listen for location changes.

View solution in original post

2 Replies
RichZwaap
Occasional Contributor III

Hi Mark,

You should be able to use the SystemLocationDataSource class.  Just instantiate it, call StartAsync, and subscribe to the LocationChanged event to listen for location changes.

MarkCollins
Occasional Contributor

This seems to do exactly what I was looking for.Thanks!

0 Kudos