Error CS1061 Task Position does not contain a definition

ChrisDeBrodie.OAChrisDeBrodie.OA USUniversity ✭✭
edited September 2016 in Xamarin.Forms

Hello I am working on a app in xamrian forms app that needs ask for the gelocation permission and if granted it needs to get the geolocation data from the device and then put the geolocation coordinates into the forecast.io URL I am using the Geolocator plugin by James Montemagno as well as the PermissionsPlugin by James Montemagno I am getting the same error 2 times:

Severity  Code    Description Project File    Line    Suppression State
Error CS1061  'Task<Position>' does not contain a definition for 'Longitude' and no extension method 'Longitude' accepting a first argument of type       'Task<Position>' could be found (are you missing a using directive or an assembly reference?)   ReadyMo C:\Users\debroc1\Documents\Visual Studio 2015\Projects\ReadyMo Mac\ReadyMo\ReadyMo\ReadyMo\Radar\RadarHome.xaml.cs  74  Active

I can not run my app because of these 2 errors here's my forms code:

using Xamarin.Forms;
using System;
using System.Diagnostics;
using Plugin.Geolocator;
namespace AppName.Radar
{
    public interface MyLocationTracker
    {
        void ObtainMyLocation();
        event EventHandler<MyLocationEventArgs> locationObtained;

    }

    public interface MyLocationEventArgs
    {
        double lat { get; set; }
        double lng { get; set; }
    }



    public partial class RadarHome : ContentPage
    {




        public RadarHome()
        {

            MyLocationTracker msi;


            double BetaLat;
            double BetaLog;

            var locator = CrossGeolocator.Current;

            if (locator.IsGeolocationEnabled == false)
            {

                if (Device.OS == TargetPlatform.Android)
                {


                    msi = DependencyService.Get<MyLocationTracker>();
                    msi.locationObtained += (object Esender, MyLocationEventArgs ew) => {
                        Debug.WriteLine(ew.lat);
                    };
                    msi.ObtainMyLocation();


                }

                else if (Device.OS == TargetPlatform.iOS)
                {
                    msi = DependencyService.Get<MyLocationTracker>();
                    msi.locationObtained += (object Jsender, MyLocationEventArgs je) =>
                    {
                        Debug.WriteLine(je.lat);
                    };
                    msi.ObtainMyLocation();
                }

            }

            locator.DesiredAccuracy = 50;

            var position = locator.GetPositionAsync(timeoutMilliseconds: 100000);



            BetaLat = position.Latitude; //error here 
            BetaLog = position.Longitude; // same error here

            string str = string.Format("https://forecast.io/?mobile=1#/f/Lat:{0} , Long: {1}", BetaLat, BetaLog);


            var client = new System.Net.Http.HttpClient();

            client.BaseAddress = new Uri(str);
        }
    }
    }

any ideas on what i'm missing?

Thanks in advance! :)

Sign In or Register to comment.