Xamarin Forms - SystemLocationDataSource is not accessible

1354
5
07-31-2020 07:58 AM
KavitaPandey
New Contributor II

Hello Team,

I have a requirement to show a real-time user location trail on the ArcGIS map, and was referring to Show location history | ArcGIS for Developers to show the user's real-time location. Referring to the link I am trying to use SystemLocationDataSource but I can't access it in  Esri.ArcGISRunTime.Location. I am using Esri.ArcGISRunTime.Xamarin.Forms(100.7.0) version, and also tried with version 100.6.0 and 100.7.0 but the same issue persists. I checked Assembly Browser, and can't find this class inside Esri.ArcGISRunTime.Location in my project but when I access it through the ArcGIS git project(arcgis-runtime-samples-dotnet/src/Forms at master · Esri/arcgis-runtime-samples-dotnet · GitHub ) it is available(Attaching assembly info of both the projects).

I really can't figure out what am I missing here. Any Help will be appreciated.

Thanks,

Kavita 

0 Kudos
5 Replies
dotMorten_esri
Esri Notable Contributor
0 Kudos
KavitaPandey
New Contributor II

Hello Morten,

Thank you so much for your reply. I am able to get location coordinates with the workaround you suggested in the above link. I have few more queries based on this same real-time user location tracking:

1. I need to get the latitude, longitude coordinates from the MapPoint that I am getting from the LocationChanged event of LocationDataSource. Do you have any idea how can I achieve this?

2. Does this real-time tracking with LocationDataSource work with offline maps as well?

3. Does this real-time tracking with LocationDataSource work when the application is in the background?

 

As mentioned above, I am referring the ArcGIS Show location history | ArcGIS for Developers  for real-time user location trail and I have initialized my LocationDataSource  with below code as suggested by you:

LocationDataSource_locationDataSource = (LocationDataSource)Activator.CreateInstance(locDStype);
MyMapView.LocationDisplay.DataSource = _locationDataSource;

Can you please help me with these queries.

Thanks in advance.

0 Kudos
dotMorten_esri
Esri Notable Contributor

1. I'm not sure what you're asking? You mentioned the LocationChanged event, and that's what you'd use to get the location every time it's updated. The location is on the event arguments.

2. LocationDataSource doesn't use the map - it uses the built-in location service - if that can get a location, so can we (I think in flight mode for instance the GPS chip is off too). So it depends on the device.

3. Running applications in the background is a very platform specific question. I'd suggest you look at Android, iOS and Windows documentation regarding configuring you app to continue getting location updates while in the background.

0 Kudos
KavitaPandey
New Contributor II

Hello Morten,

1. Yes, the LocationChanged event is giving the location every time it changes, but I need latitude, longitude coordinates of every location point that I get from the LocationChanged event for another use case. So, how can I achieve that?

 

2. I checked it on IOS by switching off the internet and was getting location coordinates, will also check on Android and Windows.

 

3. I have done the backgrounding configuration for all IOS, Android, and Windows platforms and also I am able to get location points with another Xamarin service when the app is in the background but when I checked LocationDataSource I found that when the app is in background LocationChanged is not getting called, and when the app comes in the foreground again LocationChanged starts getting called. Does any other configuration need to be done for this to work in the background? Or it actually doesn't support backgrounding?

0 Kudos
dotMorten_esri
Esri Notable Contributor

 Yes, the LocationChanged event is giving the location every time it changes, but I need latitude, longitude coordinates of every location point that I get from the LocationChanged

I'm not following. The event arguments carries all that information (see the Position property): Location Class  

I'm no expert in backgrounding for apps. Again the platform documentation is likely a lot better in this regard, as it's not really an esri-runtime specific thing. They should all have examples of how to continue getting location updates while backgrounded - once enabled, our LocationDataSource should continue to work and report updates (as it's just a thin wrapper around the native built-in location APIs).

0 Kudos