mhamsa

Esri Runtime LocationDisplay in Xamarin Forms Apps

Discussion created by mhamsa on Feb 18, 2019
Latest reply on Mar 11, 2019 by mhamsa

Hello,

 

Initially this may be more of a confirmation that LocationDisplay works in a Xamarin Forms App. Right now I'm doing some testing in our app and when I set IsEnabled to true, I get a StatusChanged event notification, but IsStarted is set to false. It looks like IsEnabled is then set back to false as well, as if it didn't start.

 

Reading the API reference, it says that if IsEnabled gets set back to false, there was an error starting the location display and you can use StartAsync on the DataSource if you need more error information because StartAsync returns an error. I couldn't find any error information returned from this method so I tried wrapping a call to StartAsync in a try/catch, and it does catch an exception, but the exception message is "One or more errors occurred". I cannot see any additional details about the errors.

 

Code wise: Right now, I've added a new event handler for the Map.Loaded event. In my Map_Loaded event handled, I'm starting the LocationDisplay. For Android (where I'm currently testing), I've got the FINE, COARSE, and MOCK location permissions set as required.

 

Here's my Map_Loaded method - it is really pretty basic, and it gets called after the map loads.

private void Map_Loaded(object sender, EventArgs e)
{
   //EsriMap.LocationDisplay.ShowLocation = true;
   //EsriMap.LocationDisplay.AutoPanMode = LocationDisplayAutoPanMode.Off;
   EsriMap.LocationDisplay.IsEnabled = true;
}

Does LocationDisplay work in Xamarin Forms app?

If so, what is the best approach to getting this to work?

 

I really just want it to turn on as soon as the map loads up.

 

Thanks,

Mike Hamsa

Outcomes