Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

Problem using Geolocation from Xlabs sample

$
0
0

I tryed to include in my share project the Geolocation feature from Xlabs sample but i'm having problems when it comes to call the dependencyService.

I have a content page and in there i have my button that has a command like this:

Command = new Command(async () => await GetPosition(), () => Geolocator != null)

the Command leads to:

private IGeolocator Geolocator
        {
            get
            {
                if (_geolocator == null)
                {
                    _geolocator = DependencyService.Get<IGeolocator>();
                    _geolocator.PositionError += OnListeningError;
                    _geolocator.PositionChanged += OnPositionChanged;
                }
                return _geolocator;
            }
        }

and when it should call the _geolocator = DependencyService.Get<IGeolocator>(); nothing happens and _geolocator remains null.

I have all the references from Xlabs and the interface IGeolocator is in my project so why isn't the DependencyService being called??


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>