Select to view content in your preferred language

Get Lat/Long of current Location

06-03-2020 10:25 AM
New Contributor II

I am writing a Windows 10 WPF .Net Core data collection application that incorporates a map. What I would like to be able to do is to collect the GPS point for the current location and use that to store the Lat/Long in a data record. All the examples I have seen thus far have used Windows Location service to display the location on the map via the LocationDataSource. I haven't seen a way to get the current location directly.

I have a couple of questions:

1. How can I get the Lat/Long of the current location along with horizontal error and such on a button click?

2. Does an attached external GPS receiver automatically work with Windows Location Services

3. Does anyone have any recommendations for Bluetooth or USB GPS receivers for use with ARCgis Runtime for WPF .Net Core?



0 Kudos
2 Replies
MVP Regular Contributor

The MapView has a LocationDisplay Class property.  Using this property you can turn on/off location collection and also adjust properties associated to displaying the location.  The class includes LocationDisplay.LocationChanged Event which is what you tie into to get the current location.

The API provides a default implementation of LocationDataSource, SystemLocationDataSource Class.  In Windows this ties into the location service.  On a non-gps device this would just be a location determined from the IP, on a device with onboard GPS it will use that.

External GPS behave differently so there is no one size fits all answer.  There are USB external devices that will tie into the location service and can just be used as is with the default implementation.  Other would require you to create your own implementation of LocationDataSource Class

Hope that helps


0 Kudos
Esri Notable Contributor

The best external GPS devices that requires the least code are ones that will drive Windows' built-in location service, and the built-in SystemLocationDataSource will "just work". 

If you have an external GPS that uses serial port or bluetooth to send NMEA messages, you can use a library I wrote on the side. You'll see how that's hooked up to ArcGIS Runtime in the documentation here: Creating a location provider for ArcGIS Runtime SDK 

(note: We hope to have built-in support for NMEA in an upcoming release really soon)

0 Kudos